# SvaEmployeesImportFilterConfigController.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.SvaEmployeesImportFilterConfig;
    import cloud.wconnect.workperformance.pojo.dto.sva.employee.EmployeeFilterConfigDTO;
    import cloud.wconnect.workperformance.pojo.query.sva.employee.SvaEmployeesFilterConfigQuery;
    import cloud.wconnect.workperformance.service.sva.employees.ISvaEmployeesImportFilterConfigService;
    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: Employee Import Filter Config
     *
     * @author zc
     * @date 2023/10/18
     */
    @RestController
    @RequestMapping("/sva/employees/report/filter-config")
    public class SvaEmployeesImportFilterConfigController {
        @Resource
        private ISvaEmployeesImportFilterConfigService filterConfigService;
        @Resource
        private SessionContext sessionContext;

        /**
         * 获取员工报告导入过滤配置
         *
         * @param property          资产标识
         * @param query 查询条件
         * @return EmployeeFilterConfigDTO 集合
         * @author zc
         * @date 2023/10/18
         */
        @ApiId(859)
        @GetMapping
        public ListPagedDTO<EmployeeFilterConfigDTO> list(@RequestParam String property, SvaEmployeesFilterConfigQuery query) {
            int propertyId = sessionContext.getPropertyId(property);
            return filterConfigService.list(propertyId, query);
        }

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

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

            return Collections.emptyMap();
        }

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

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

            return Collections.emptyMap();
        }
    }