src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -33,7 +33,9 @@ import org.springblade.core.tool.support.Kv; import org.springblade.core.tool.utils.Func; import org.springblade.modules.system.entity.Dept; import org.springblade.modules.system.entity.User; import org.springblade.modules.system.service.IDeptService; import org.springblade.modules.system.service.IUserService; import org.springblade.modules.system.vo.DeptVO; import org.springblade.modules.system.wrapper.DeptWrapper; import org.springframework.web.bind.annotation.*; @@ -59,6 +61,8 @@ public class DeptController extends BladeController { private final IDeptService deptService; private final IUserService userService; /** * 详情 @@ -142,8 +146,17 @@ * @return */ @GetMapping("/lazy-tree-user-app") public List<DeptVO> lazyTreeUser(Integer type) { return deptService.lazyTreeUserApp(type); public List<DeptVO> lazyTreeUser(Integer type,String userId) { if (null!=userId && userId!=""){ //查询用户信息 User user = userService.getById(userId); type = 4; if (null!=user.getJurisdiction() && user.getJurisdiction()!="") { return deptService.lazyTreeUserApp(type, user.getJurisdiction()); } return deptService.lazyTreeUserApp(type,null); } return deptService.lazyTreeUserApp(type,null); } /** src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -107,5 +107,5 @@ * @return */ @SqlParser(filter=true) List<DeptVO> lazyTreeUserApp(Integer type); List<DeptVO> lazyTreeUserApp(@Param("type")Integer type,@Param("jurisdiction")String jurisdiction); } src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -172,10 +172,14 @@ FROM blade_dept WHERE parent_id = dept.id and is_deleted = 0 parent_id = dept.id and dept.is_deleted = 0 ) AS "has_children" FROM blade_dept dept left join blade_user bu on bu.dept_id = dept.id WHERE dept.is_deleted = 0 <if test="type==1"> @@ -185,6 +189,11 @@ <if test="type==2 or type==3"> and dept_category=2 AND dept.parent_id = "1123598813738675201" </if> <if test="type==4 and jurisdiction!=null and jurisdiction!=''"> and dept_category=1 AND dept.parent_id = "1413470343230877697" and bu.jurisdiction = #{jurisdiction} </if> ) @@ -209,6 +218,10 @@ <if test="type==2 or type==3"> and dept_category=2 </if> <if test="type==4 and jurisdiction!=null and jurisdiction!=''"> and dept_category=1 and bu.jurisdiction = #{jurisdiction} </if> ) )c </select> src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -149,5 +149,5 @@ * @param type 1:保安对保安 2:保安向民警 3:民警向民警 * @return */ List<DeptVO> lazyTreeUserApp(Integer type); List<DeptVO> lazyTreeUserApp(Integer type,String jurisdiction); } src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -228,10 +228,11 @@ /** * 懒加载获取部门树形结构(包含用户数据)app * @param type 1:保安对保安 2:保安向民警 3:民警向民警 * @param jurisdiction 辖区id * @return */ @Override public List<DeptVO> lazyTreeUserApp(Integer type) { return ForestNodeMerger.merge(baseMapper.lazyTreeUserApp(type)); public List<DeptVO> lazyTreeUserApp(Integer type,String jurisdiction) { return ForestNodeMerger.merge(baseMapper.lazyTreeUserApp(type,jurisdiction)); } } src/main/java/org/springblade/modules/system/vo/DeptAndUserVO.java
@@ -20,5 +20,4 @@ using = ToStringSerializer.class ) private Long value; }