package com.yida.data.attendance.controller;

import com.yida.data.attendance.dto.AddAttendanceReportStrategyDTO;
import com.yida.data.attendance.service.AttendanceReportStrategyService;
import com.yida.data.common.core.common.ModuleName;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.attendance.attendance.AttendanceReportStrategy;
import com.yida.data.common.core.entity.system.enums.OperationLogTypeEnum;
import com.yida.data.log.annotation.OperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
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
 *
 * @date 2023-08-09 11:37:25
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/attendanceReportStrategy")
@RequiredArgsConstructor
@Api(tags = "考勤-推送策略", value = "推送策略")
public class AttendanceReportStrategyController {

    private final AttendanceReportStrategyService attendanceReportStrategyService;


    @ApiOperation("获取推送策略详情")
    @GetMapping("/get")
    public ResultBean<List<AttendanceReportStrategy>> getStrategy() {
        return ResultBean.buildSuccess(attendanceReportStrategyService.getList());
    }

    @ApiOperation("新增/编辑推送策略")
    @PostMapping("/save")
    @OperationLog(module = ModuleName.ATTENDANCE, methods = "新增/编辑推送策略", type = OperationLogTypeEnum.SAVE)
    public ResultBean saveStrategy(@RequestBody List<AddAttendanceReportStrategyDTO> strategyList) {
        attendanceReportStrategyService.saveStrategy(strategyList);
        return ResultBean.buildSuccess();
    }
}
