gonglilong
2024-09-13 0cf306a80a8f189a2a664cf447cc0fbef5684bf8
skjcmanager/skjcmanager-service/skjcmanager-system/src/main/java/cn/gistack/system/controller/DeptController.java
@@ -16,6 +16,9 @@
 */
package cn.gistack.system.controller;
import cn.gistack.common.node.DeptUserTreeNode;
import cn.gistack.common.node.TreeNode;
import cn.gistack.common.utils.NodeTreeUtil;
import cn.gistack.system.vo.DeptVO;
import cn.gistack.system.wrapper.DeptWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -45,6 +48,8 @@
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -60,7 +65,7 @@
@AllArgsConstructor
@RequestMapping("/dept")
@Api(value = "部门", tags = "部门")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
//@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class DeptController extends BladeController {
   private final IDeptService deptService;
@@ -120,13 +125,21 @@
      return R.data(tree);
   }
   @GetMapping("/treeByParentId")
   @ApiOperationSupport(order = 10)
   @ApiOperation(value = "树形结构", notes = "树形结构")
   public R<List<DeptVO>> treeByParentId(String parentId) {
      List<DeptVO> tree = deptService.treeByParentId(parentId);
      return R.data(tree);
   }
   /**
    * 懒加载获取部门树形结构
    */
   @GetMapping("/lazy-tree")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "懒加载树形结构", notes = "树形结构")
   public R<List<DeptVO>> lazyTree(String tenantId, Long parentId, BladeUser bladeUser) {
   public R<List<DeptVO>> lazyTree(String tenantId, String parentId, BladeUser bladeUser) {
      List<DeptVO> tree = deptService.lazyTree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()), parentId);
      return R.data(tree);
   }
@@ -176,4 +189,40 @@
   }
   /**
    * 查询组织机构树数据(下级包含人员信息)
    * @param treeNode
    * @return
    */
   @GetMapping("/getDeptAndUserTree")
   @ApiOperation(value = "查询组织机构树数据(下级包含人员信息)")
   public R getDeptAndUserTree(DeptUserTreeNode treeNode) {
      return R.data(deptService.getDeptAndUserTree(treeNode));
   }
   @GetMapping("updateAllDept")
   public R updateAllDept(){
      int number = deptService.updateAllDept();
      return R.data(number);
   }
   @GetMapping("/getDwByParentId")
   @ApiOperationSupport(order = 10)
   @ApiOperation(value = "获取单位树形结构", notes = "获取单位树形结构")
   public R<Map<String,List<DeptVO>>> getDwByParentId(String precinct) {
      Map<String,List<DeptVO>> map=new HashMap<>();
      if(precinct==null||precinct.equals("")){
         map.put("one",new ArrayList<>());
         map.put("two",new ArrayList<>());
         map.put("three",new ArrayList<>());
      }else {
         List<DeptVO> tree1 = deptService.treeByParentIdNew("1821370772215062530", precinct);
         List<DeptVO> tree2 = deptService.treeByParentIdNew("1821370871330660353", precinct);
         List<DeptVO> tree3 = deptService.treeByParentIdNew("1806175841028685826", precinct);
         map.put("one", tree1);
         map.put("two", tree2);
         map.put("three", tree3);
      }
      return R.data(map);
   }
}