# SvaDepartmentIgnoreConfigController.java

    package cloud.wconnect.workperformance.controller.sva.employees;

    import cloud.wconnect.commonlib.annotation.ApiId;
    import cloud.wconnect.commonlib.component.SessionContext;
    import cloud.wconnect.commonlib.pojo.dto.ListPagedDTO;
    import cloud.wconnect.workperformance.entity.sva.employees.SvaDepartmentIgnoreConfig;
    import cloud.wconnect.workperformance.pojo.dto.sva.employee.SvaDepartmentIgnoreConfigDTO;
    import cloud.wconnect.workperformance.pojo.query.sva.employee.SvaDepartmentIgnoreConfigQuery;
    import cloud.wconnect.workperformance.service.sva.employees.ISvaDepartmentIgnoreConfigService;
    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;

    /**
     * 忽略部门配置 前端控制器
     *
     * @author zc
     * @date 2024/02/23
     */
    @RestController
    @RequestMapping("/sva/employees/department/ignore-config")
    public class SvaDepartmentIgnoreConfigController {
        @Resource
        private ISvaDepartmentIgnoreConfigService ignoreConfigService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取忽略更新部门数据配置
         *
         * @param property 资产标识
         * @param query    查询条件
         * @return SvaDepartmentIgnoreConfigDTO 集合
         * @author zc
         * @date 2023/11/25
         */
        @ApiId(1025)
        @GetMapping
        public ListPagedDTO<SvaDepartmentIgnoreConfigDTO> list(@RequestParam String property, SvaDepartmentIgnoreConfigQuery query) {
            int propertyId = sessionContext.getPropertyId(property);
            return ignoreConfigService.list(propertyId, query);
        }

        /**
         * 保存过滤配置
         *
         * @param property        资产标识
         * @param ignoreConfigDTO 配置信息
         * @return empty map
         * @author zc
         * @date 2023/11/25
         */
        @ApiId(1026)
        @PostMapping
        public Map<Object, Object> save(@RequestParam String property,
                                        @RequestBody @Valid SvaDepartmentIgnoreConfigDTO ignoreConfigDTO) {
            int propertyId = sessionContext.getPropertyId(property);

            if (Objects.isNull(ignoreConfigDTO.getId())) {
                // 校验过滤配置信息是否重复
                ignoreConfigService.checkRepeat(propertyId, null, ignoreConfigDTO.getCode());
                // 新增配置
                ignoreConfigService.add(propertyId, sessionContext.getLoginUserId(), ignoreConfigDTO.getCode());
            } else {
                // 校验配置是否存在
                SvaDepartmentIgnoreConfig originConfig = ignoreConfigService.checkExist(ignoreConfigDTO.getId());
                // 校验归属
                ignoreConfigService.checkBelong(propertyId, originConfig);
                // 校验过滤配置信息是否重复
                ignoreConfigService.checkRepeat(propertyId, ignoreConfigDTO.getId(), ignoreConfigDTO.getCode());
                // 编辑配置
                ignoreConfigService.update(sessionContext.getLoginUserId(), ignoreConfigDTO.getId(), ignoreConfigDTO.getCode());
            }

            return Collections.emptyMap();
        }

        /**
         * 删除配置
         *
         * @param property 资产标识
         * @param id       配置 id
         * @return empty map
         * @author zc
         * @date 2023/11/27
         */
        @ApiId(1027)
        @DeleteMapping("/{id:\\d+}")
        public Map<Object, Object> delete(@RequestParam String property, @PathVariable int id) {
            int propertyId = sessionContext.getPropertyId(property);

            // 校验配置是否存在
            SvaDepartmentIgnoreConfig originConfig = ignoreConfigService.checkExist(id);
            // 校验归属
            ignoreConfigService.checkBelong(propertyId, originConfig);
            // 删除配置
            ignoreConfigService.removeById(id);

            return Collections.emptyMap();
        }
    }