mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	🔧 简化 post 和 dept 模块的 VO
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.api.dept;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
@@ -24,13 +24,13 @@ public class DeptApiImpl implements DeptApi {
 | 
			
		||||
    @Override
 | 
			
		||||
    public DeptRespDTO getDept(Long id) {
 | 
			
		||||
        DeptDO dept = deptService.getDept(id);
 | 
			
		||||
        return DeptConvert.INSTANCE.convert03(dept);
 | 
			
		||||
        return BeanUtils.toBean(dept, DeptRespDTO.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<DeptRespDTO> getDeptList(Collection<Long> ids) {
 | 
			
		||||
        List<DeptDO> depts = deptService.getDeptList(ids);
 | 
			
		||||
        return DeptConvert.INSTANCE.convertList03(depts);
 | 
			
		||||
        return BeanUtils.toBean(depts, DeptRespDTO.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -17,11 +17,6 @@ import javax.annotation.Resource;
 | 
			
		||||
import javax.annotation.security.PermitAll;
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 验证码
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@Tag(name = "管理后台 - 验证码")
 | 
			
		||||
@RestController("adminCaptchaController")
 | 
			
		||||
@RequestMapping("/system/captcha")
 | 
			
		||||
 
 | 
			
		||||
@@ -2,20 +2,22 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.*;
 | 
			
		||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Parameter;
 | 
			
		||||
import io.swagger.v3.oas.annotations.tags.Tag;
 | 
			
		||||
import org.springframework.security.access.prepost.PreAuthorize;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
import java.util.Comparator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
@@ -32,16 +34,16 @@ public class DeptController {
 | 
			
		||||
    @PostMapping("create")
 | 
			
		||||
    @Operation(summary = "创建部门")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:dept:create')")
 | 
			
		||||
    public CommonResult<Long> createDept(@Valid @RequestBody DeptCreateReqVO reqVO) {
 | 
			
		||||
        Long deptId = deptService.createDept(reqVO);
 | 
			
		||||
    public CommonResult<Long> createDept(@Valid @RequestBody DeptSaveReqVO createReqVO) {
 | 
			
		||||
        Long deptId = deptService.createDept(createReqVO);
 | 
			
		||||
        return success(deptId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PutMapping("update")
 | 
			
		||||
    @Operation(summary = "更新部门")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:dept:update')")
 | 
			
		||||
    public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptUpdateReqVO reqVO) {
 | 
			
		||||
        deptService.updateDept(reqVO);
 | 
			
		||||
    public CommonResult<Boolean> updateDept(@Valid @RequestBody DeptSaveReqVO updateReqVO) {
 | 
			
		||||
        deptService.updateDept(updateReqVO);
 | 
			
		||||
        return success(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -59,20 +61,15 @@ public class DeptController {
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:dept:query')")
 | 
			
		||||
    public CommonResult<List<DeptRespVO>> getDeptList(DeptListReqVO reqVO) {
 | 
			
		||||
        List<DeptDO> list = deptService.getDeptList(reqVO);
 | 
			
		||||
        list.sort(Comparator.comparing(DeptDO::getSort));
 | 
			
		||||
        return success(DeptConvert.INSTANCE.convertList(list));
 | 
			
		||||
        return success(BeanUtils.toBean(list, DeptRespVO.class));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/list-all-simple")
 | 
			
		||||
    @GetMapping(value = {"/list-all-simple", "/simple-list"})
 | 
			
		||||
    @Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
 | 
			
		||||
    public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
 | 
			
		||||
        // 获得部门列表,只要开启状态的
 | 
			
		||||
        DeptListReqVO reqVO = new DeptListReqVO();
 | 
			
		||||
        reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
 | 
			
		||||
        List<DeptDO> list = deptService.getDeptList(reqVO);
 | 
			
		||||
        // 排序后,返回给前端
 | 
			
		||||
        list.sort(Comparator.comparing(DeptDO::getSort));
 | 
			
		||||
        return success(DeptConvert.INSTANCE.convertList02(list));
 | 
			
		||||
        List<DeptDO> list = deptService.getDeptList(
 | 
			
		||||
                new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
 | 
			
		||||
        return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/get")
 | 
			
		||||
@@ -80,7 +77,8 @@ public class DeptController {
 | 
			
		||||
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
 | 
			
		||||
    @PreAuthorize("@ss.hasPermission('system:dept:query')")
 | 
			
		||||
    public CommonResult<DeptRespVO> getDept(@RequestParam("id") Long id) {
 | 
			
		||||
        return success(DeptConvert.INSTANCE.convert(deptService.getDept(id)));
 | 
			
		||||
        DeptDO dept = deptService.getDept(id);
 | 
			
		||||
        return success(BeanUtils.toBean(dept, DeptRespVO.class));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ public class PostController {
 | 
			
		||||
        return success(BeanUtils.toBean(post, PostRespVO.class));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/list-all-simple")
 | 
			
		||||
    @GetMapping(value = {"/list-all-simple", "simple-list"})
 | 
			
		||||
    @Operation(summary = "获取岗位全列表", description = "只包含被开启的岗位,主要用于前端的下拉选项")
 | 
			
		||||
    public CommonResult<List<PostSimpleRespVO>> getSimplePostList() {
 | 
			
		||||
        // 获得岗位列表,只要开启状态的
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
import lombok.ToString;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - 部门创建 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
@ToString(callSuper = true)
 | 
			
		||||
public class DeptCreateReqVO extends DeptBaseVO {
 | 
			
		||||
}
 | 
			
		||||
@@ -2,19 +2,35 @@ package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - 部门信息 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
public class DeptRespVO extends DeptBaseVO {
 | 
			
		||||
public class DeptRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    @Schema(description = "部门编号", example = "1024")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "父部门 ID", example = "1024")
 | 
			
		||||
    private Long parentId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    private Integer sort;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "负责人的用户编号", example = "2048")
 | 
			
		||||
    private Long leaderUserId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "联系电话", example = "15601691000")
 | 
			
		||||
    private String phone;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "邮箱", example = "yudao@iocoder.cn")
 | 
			
		||||
    private String email;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
@@ -8,19 +10,19 @@ import javax.validation.constraints.NotBlank;
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import javax.validation.constraints.Size;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 部门 Base VO,提供给添加、修改、详细的子 VO 使用
 | 
			
		||||
 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
 | 
			
		||||
 */
 | 
			
		||||
@Schema(description = "管理后台 - 部门创建/修改 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class DeptBaseVO {
 | 
			
		||||
public class DeptSaveReqVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "菜单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
 | 
			
		||||
    @Schema(description = "部门编号", example = "1024")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
 | 
			
		||||
    @NotBlank(message = "部门名称不能为空")
 | 
			
		||||
    @Size(max = 30, message = "部门名称长度不能超过30个字符")
 | 
			
		||||
    @Size(max = 30, message = "部门名称长度不能超过 30 个字符")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "父菜单 ID", example = "1024")
 | 
			
		||||
    @Schema(description = "父部门 ID", example = "1024")
 | 
			
		||||
    private Long parentId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
@@ -36,12 +38,12 @@ public class DeptBaseVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "邮箱", example = "yudao@iocoder.cn")
 | 
			
		||||
    @Email(message = "邮箱格式不正确")
 | 
			
		||||
    @Size(max = 50, message = "邮箱长度不能超过50个字符")
 | 
			
		||||
    @Size(max = 50, message = "邮箱长度不能超过 50 个字符")
 | 
			
		||||
    private String email;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @NotNull(message = "状态不能为空")
 | 
			
		||||
//    @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
 | 
			
		||||
    @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.EqualsAndHashCode;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - 部门更新 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
@EqualsAndHashCode(callSuper = true)
 | 
			
		||||
public class DeptUpdateReqVO extends DeptBaseVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
    @NotNull(message = "部门编号不能为空")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.controller.admin.dept.vo.post;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
 | 
			
		||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
 | 
			
		||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 | 
			
		||||
import com.alibaba.excel.annotation.ExcelProperty;
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
@@ -10,6 +12,7 @@ import java.time.LocalDateTime;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - 岗位信息 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
@ExcelIgnoreUnannotated
 | 
			
		||||
public class PostRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "岗位序号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
 | 
			
		||||
@@ -29,6 +32,7 @@ public class PostRespVO {
 | 
			
		||||
    private Integer sort;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @ExcelProperty(value = "状态", converter = DictConvert.class)
 | 
			
		||||
    @DictFormat(DictTypeConstants.COMMON_STATUS)
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,34 +0,0 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.convert.dept;
 | 
			
		||||
 | 
			
		||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 | 
			
		||||
import org.mapstruct.Mapper;
 | 
			
		||||
import org.mapstruct.factory.Mappers;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface DeptConvert {
 | 
			
		||||
 | 
			
		||||
    DeptConvert INSTANCE = Mappers.getMapper(DeptConvert.class);
 | 
			
		||||
 | 
			
		||||
    List<DeptRespVO> convertList(List<DeptDO> list);
 | 
			
		||||
 | 
			
		||||
    List<DeptSimpleRespVO> convertList02(List<DeptDO> list);
 | 
			
		||||
 | 
			
		||||
    DeptRespVO convert(DeptDO bean);
 | 
			
		||||
 | 
			
		||||
    DeptDO convert(DeptCreateReqVO bean);
 | 
			
		||||
 | 
			
		||||
    DeptDO convert(DeptUpdateReqVO bean);
 | 
			
		||||
 | 
			
		||||
    List<DeptRespDTO> convertList03(List<DeptDO> list);
 | 
			
		||||
 | 
			
		||||
    DeptRespDTO convert03(DeptDO bean);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,13 +1,14 @@
 | 
			
		||||
package cn.iocoder.yudao.module.system.service.dept;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 部门 Service 接口
 | 
			
		||||
@@ -19,17 +20,17 @@ public interface DeptService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建部门
 | 
			
		||||
     *
 | 
			
		||||
     * @param reqVO 部门信息
 | 
			
		||||
     * @param createReqVO 部门信息
 | 
			
		||||
     * @return 部门编号
 | 
			
		||||
     */
 | 
			
		||||
    Long createDept(DeptCreateReqVO reqVO);
 | 
			
		||||
    Long createDept(DeptSaveReqVO createReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新部门
 | 
			
		||||
     *
 | 
			
		||||
     * @param reqVO 部门信息
 | 
			
		||||
     * @param updateReqVO 部门信息
 | 
			
		||||
     */
 | 
			
		||||
    void updateDept(DeptUpdateReqVO reqVO);
 | 
			
		||||
    void updateDept(DeptSaveReqVO updateReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除部门
 | 
			
		||||
@@ -69,9 +70,6 @@ public interface DeptService {
 | 
			
		||||
     * @return 部门 Map
 | 
			
		||||
     */
 | 
			
		||||
    default Map<Long, DeptDO> getDeptMap(Collection<Long> ids) {
 | 
			
		||||
        if (CollUtil.isEmpty(ids)) {
 | 
			
		||||
            return Collections.emptyMap();
 | 
			
		||||
        }
 | 
			
		||||
        List<DeptDO> list = getDeptList(ids);
 | 
			
		||||
        return CollectionUtils.convertMap(list, DeptDO::getId);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,10 @@ package cn.iocoder.yudao.module.system.service.dept;
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.hutool.core.util.ObjectUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 | 
			
		||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptCreateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptUpdateReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.convert.dept.DeptConvert;
 | 
			
		||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
 | 
			
		||||
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
 | 
			
		||||
@@ -41,7 +40,7 @@ public class DeptServiceImpl implements DeptService {
 | 
			
		||||
    @Override
 | 
			
		||||
    @CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
 | 
			
		||||
            allEntries = true) // allEntries 清空所有缓存,因为操作一个部门,涉及到多个缓存
 | 
			
		||||
    public Long createDept(DeptCreateReqVO createReqVO) {
 | 
			
		||||
    public Long createDept(DeptSaveReqVO createReqVO) {
 | 
			
		||||
        if (createReqVO.getParentId() == null) {
 | 
			
		||||
            createReqVO.setParentId(DeptDO.PARENT_ID_ROOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -51,7 +50,7 @@ public class DeptServiceImpl implements DeptService {
 | 
			
		||||
        validateDeptNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
 | 
			
		||||
 | 
			
		||||
        // 插入部门
 | 
			
		||||
        DeptDO dept = DeptConvert.INSTANCE.convert(createReqVO);
 | 
			
		||||
        DeptDO dept = BeanUtils.toBean(createReqVO, DeptDO.class);
 | 
			
		||||
        deptMapper.insert(dept);
 | 
			
		||||
        return dept.getId();
 | 
			
		||||
    }
 | 
			
		||||
@@ -59,7 +58,7 @@ public class DeptServiceImpl implements DeptService {
 | 
			
		||||
    @Override
 | 
			
		||||
    @CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
 | 
			
		||||
            allEntries = true) // allEntries 清空所有缓存,因为操作一个部门,涉及到多个缓存
 | 
			
		||||
    public void updateDept(DeptUpdateReqVO updateReqVO) {
 | 
			
		||||
    public void updateDept(DeptSaveReqVO updateReqVO) {
 | 
			
		||||
        if (updateReqVO.getParentId() == null) {
 | 
			
		||||
            updateReqVO.setParentId(DeptDO.PARENT_ID_ROOT);
 | 
			
		||||
        }
 | 
			
		||||
@@ -71,7 +70,7 @@ public class DeptServiceImpl implements DeptService {
 | 
			
		||||
        validateDeptNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
 | 
			
		||||
 | 
			
		||||
        // 更新部门
 | 
			
		||||
        DeptDO updateObj = DeptConvert.INSTANCE.convert(updateReqVO);
 | 
			
		||||
        DeptDO updateObj = BeanUtils.toBean(updateReqVO, DeptDO.class);
 | 
			
		||||
        deptMapper.updateById(updateObj);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -165,7 +164,9 @@ public class DeptServiceImpl implements DeptService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<DeptDO> getDeptList(DeptListReqVO reqVO) {
 | 
			
		||||
        return deptMapper.selectList(reqVO);
 | 
			
		||||
        List<DeptDO> list = deptMapper.selectList(reqVO);
 | 
			
		||||
        list.sort(Comparator.comparing(DeptDO::getSort));
 | 
			
		||||
        return list;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user