package com.yida.data.attendance.controller;

import com.yida.data.attendance.dto.AddLeaveRequestStrategyDTO;
import com.yida.data.attendance.service.EduAttendanceStrategyService;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.user.EduFaceGroupStrategy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备策略Controller
 * 未鉴权
 *
 * @author ZYJ
 * @date 2022-12-13 11:04:39
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/in/deviceStrategy")
@Api(tags = "考勤-设备-策略", value = "考勤")
public class EduAttendanceStrategyController {

    private final EduAttendanceStrategyService eduAttendanceStrategyService;

    @PostMapping("saveStrategyAndUser")
    @ApiOperation("保存策略并绑定人员信息")
    public ResultBean<String> saveStrategyAndUser(@RequestBody EduFaceGroupStrategy eduFaceGroupStrategy) {
        eduAttendanceStrategyService.saveStrategyAndUser(eduFaceGroupStrategy);
        return ResultBean.buildSuccess();
    }

    @PostMapping("deleteStrategy")
    @ApiOperation("删除策略")
    public ResultBean<String> deleteStrategy(@RequestBody EduFaceGroupStrategy eduFaceGroupStrategy) {
        eduAttendanceStrategyService.deleteStrategy(eduFaceGroupStrategy);
        return ResultBean.buildSuccess();
    }

    @PostMapping("bindUserStrategy")
    @ApiOperation("绑定对应的人员-策略信息")
    public ResultBean<String> bindUserStrategy(@RequestBody EduFaceGroupStrategy eduFaceGroupStrategy) {
        eduAttendanceStrategyService.bindUserStrategy(eduFaceGroupStrategy);
        return ResultBean.buildSuccess();
    }

    @PostMapping("unBindUserStrategy")
    @ApiOperation("解绑对应的人员-策略信息")
    public ResultBean<String> unBindUserStrategy(@RequestBody EduFaceGroupStrategy eduFaceGroupStrategy) {
        eduAttendanceStrategyService.unBindUserStrategy(eduFaceGroupStrategy);
        return ResultBean.buildSuccess();
    }

    @PostMapping("deleteAndSaveStrategy")
    @ApiOperation("删除并保存策略(包含人员信息)")
    public ResultBean<String> deleteAndSaveStrategy(@RequestBody EduFaceGroupStrategy eduFaceGroupStrategy) {
        eduAttendanceStrategyService.deleteAndSaveStrategy(eduFaceGroupStrategy);
        return ResultBean.buildSuccess();
    }

    @PostMapping("addLeaveRequestStrategy")
    @ApiOperation("添加请假类型短策略")
    public ResultBean<String> addLeaveRequestStrategy(@RequestBody AddLeaveRequestStrategyDTO dto) {
        eduAttendanceStrategyService.addLeaveRequestStrategy(dto);
        return ResultBean.buildSuccess();
    }
}
