# MorOvertimeReportFilterConfigController.java

    package cloud.wconnect.workperformance.controller.mor.overtime;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.workperformance.entity.mor.MorOvertimeReportFilterConfig;
    import cloud.wconnect.workperformance.pojo.dto.mor.overtime.filterconfig.MorOvertimeReportFilterConfigDTO;
    import cloud.wconnect.workperformance.pojo.query.mor.overtime.MorOvertimeReportFilterConfigQuery;
    import cloud.wconnect.workperformance.service.mor.IMorOvertimeReportFilterConfigService;
    import com.google.common.collect.ImmutableMap;
    import org.springframework.web.bind.annotation.*;

    import jakarta.annotation.Resource;
    import jakarta.validation.Valid;
    import java.util.Collections;
    import java.util.Map;
    import java.util.Objects;

    /**
     * Controller: Monthly OT Report Overtime Report Filter Config
     *
     * @author zc
     * @date 2025/03/14
     */
    @RestController
    @RequestMapping("/mor/overtime/report/filter-config")
    public class MorOvertimeReportFilterConfigController {
        @Resource
        private IMorOvertimeReportFilterConfigService configService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取配置
         *
         * @param property    资产标识
         * @param query 查询条件
         * @return 配置集合
         * @author zc
         * @date 2025/3/14
         */
        @ApiId(1347)
        @GetMapping
        public ListPagedDTO<MorOvertimeReportFilterConfigDTO> list(@RequestParam String property, MorOvertimeReportFilterConfigQuery query) {
            int propertyId = sessionContext.getPropertyId(property);
            return configService.list(propertyId, query);
        }

        /**
         * 保存配置
         *
         * @param property  资产标识
         * @param configDTO 配置信息
         * @return 配置 id
         * @author zc
         * @date 2025/3/14
         */
        @ApiId(1348)
        @PostMapping
        public Map<String, Integer> save(@RequestParam String property, @RequestBody @Valid MorOvertimeReportFilterConfigDTO configDTO) {
            int propertyId = sessionContext.getPropertyId(property);
            if (Objects.isNull(configDTO.getId())) {
                // 校验配置信息是否重复
                configService.checkRepeat(propertyId, null, configDTO.getPayCode());
                // 新增配置
                return ImmutableMap.of("id", configService.add(propertyId, configDTO.getPayCode(), sessionContext.getLoginUserId()));
            }
            // 校验配置是否存在
            MorOvertimeReportFilterConfig originConfig = configService.checkExist(configDTO.getId());
            // 校验归属
            configService.checkBelong(propertyId, originConfig);
            // 校验配置信息是否重复
            configService.checkRepeat(propertyId, configDTO.getId(), configDTO.getPayCode());
            // 编辑配置
            configService.update(configDTO.getId(), configDTO.getPayCode(), sessionContext.getLoginUserId());
            return ImmutableMap.of("id", configDTO.getId());
        }

        /**
         * 删除配置
         *
         * @param property 资产标识
         * @param id       配置 id
         * @return empty map
         * @author zc
         * @date 2025/3/14
         */
        @ApiId(1349)
        @DeleteMapping("/{id:\\d+}")
        public Map<Object, Object> delete(@RequestParam String property, @PathVariable int id) {
            int propertyId = sessionContext.getPropertyId(property);
            // 校验配置是否存在
            MorOvertimeReportFilterConfig originConfig = configService.checkExist(id);
            // 校验归属
            configService.checkBelong(propertyId, originConfig);
            // 删除配置
            configService.removeById(id);
            return Collections.emptyMap();
        }
    }