WangHan
2025-04-02 a8ba678a3fe5a39da2c732014cebbb66e408e97c
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;
@@ -10,6 +11,7 @@
import org.springframework.web.bind.annotation.RestController;
import com.consum.base.BaseController;
import com.consum.base.core.type.StatesType;
import com.consum.base.core.utils.CommonUtil;
import com.consum.base.pojo.FinSysTenantDepartmentParam;
import com.consum.base.service.FinSysTenantDepartmentService;
@@ -19,17 +21,12 @@
import com.walker.infrastructure.utils.StringUtils;
import com.walker.web.ResponseValue;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
/**
 * @Description 部门管理
 * @Author 卢庆阳
 * @Date 2023/10/26
 */
@Api(value = "部门管理", tags = "部门管理")
// @Api(value = "部门管理", tags = "部门管理")
@RestController
@RequestMapping("/pc/fin/sys/tenant/department")
public class FinSysTenantDepartmentController extends BaseController {
@@ -42,9 +39,9 @@
     * @Author 卢庆阳
     * @Date 2023/10/26
     */
    @ApiOperation(value = "新增", notes = "新增")
    @ApiImplicitParams(value = {
        @ApiImplicitParam(name = "param", value = "部门信息", required = true, dataType = "FinSysTenantDepartmentParam")})
    // @ApiOperation(value = "新增", notes = "新增")
//    @ApiImplicitParams(value = {
//        @ApiImplicitParam(name = "param", value = "部门信息", required = true, dataType = "FinSysTenantDepartmentParam")})
    @PostMapping("/add")
    public ResponseValue add() {
        FinSysTenantDepartmentParam param = CommonUtil.getObjFromReqBody(FinSysTenantDepartmentParam.class);
@@ -69,7 +66,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();
@@ -98,9 +101,9 @@
        return ResponseValue.success(pager);
    }
    @ApiOperation(value = "根据机构id查询所有部门列表信息", notes = "根据机构id查询所有部门列表信息")
    @ApiImplicitParams(value = {
        @ApiImplicitParam(name = "param", value = "部门信息", required = true, dataType = "FinSysTenantDepartmentParam")})
    // @ApiOperation(value = "根据机构id查询所有部门列表信息", notes = "根据机构id查询所有部门列表信息")
//    @ApiImplicitParams(value = {
//        @ApiImplicitParam(name = "param", value = "部门信息", required = true, dataType = "FinSysTenantDepartmentParam")})
    @GetMapping("/list/all")
    public ResponseValue queryAllDepartment(Long tenantId) {
        FinSysTenantUser sysInfo = this.getSysInfo();
@@ -109,6 +112,7 @@
        }
        FinSysTenantDepartment finSysTenantDepartment = new FinSysTenantDepartment();
        finSysTenantDepartment.setTenantId(tenantId);
        finSysTenantDepartment.setStatus(StatesType.NORMAL.getValue());
        List<FinSysTenantDepartment> finSysTenantDepartments = this.departmentService.select(finSysTenantDepartment);
        return ResponseValue.success(finSysTenantDepartments);
    }
@@ -142,7 +146,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("编辑失败!");