|  | @@ -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));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |