黎星凯
2024-04-15 62b6a7fac3f2acde70b578431147c4a01f19c182
consum-base/src/main/java/com/consum/base/controller/FinSysTenantDepartmentController.java
@@ -2,6 +2,7 @@
import java.util.List;
import cn.hutool.core.collection.CollectionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@@ -70,7 +71,13 @@
        if (department != null) {
            return ResponseValue.error("部门名称已存在");
        }
        // 部门编号
        FinSysTenantDepartmentParam finSysTenantDepartmentParam1 = new FinSysTenantDepartmentParam();
        finSysTenantDepartmentParam1.setCode(param.getCode());
        List<FinSysTenantDepartment> datas = departmentService.queryDataList(finSysTenantDepartmentParam1);
        if(!CollectionUtil.isEmpty(datas)){
            return ResponseValue.error("此编号已存在");
        }
        int result = this.departmentService.add(param, this.getSysInfo());
        if (result > 0) {
            return ResponseValue.success();
@@ -144,7 +151,17 @@
        FinSysTenantDepartment tenantDepartment =
            this.departmentService.getTenantDepartment(null, param.getTenantId(), param.getCode());
        if (tenantDepartment != null) {
            return ResponseValue.error("部门编号已存在");
            //return ResponseValue.error("部门编号已存在");
        }
        // 部门编号
        FinSysTenantDepartmentParam finSysTenantDepartmentParam1 = new FinSysTenantDepartmentParam();
        finSysTenantDepartmentParam1.setCode(param.getCode());
        List<FinSysTenantDepartment> datas = departmentService.queryDataList(finSysTenantDepartmentParam1);
        if(!CollectionUtil.isEmpty(datas)){
            FinSysTenantDepartment finSysTenantDepartment1 = datas.get(0);
            if(!finSysTenantDepartment1.getId().equals(param.getId())){
                return ResponseValue.error("此编号已存在");
            }
        }
        int num = this.departmentService.updateFinSysTenantDepartment(param, sysInfo);
        return num > 0 ? ResponseValue.success() : ResponseValue.error("编辑失败!");