瀏覽代碼

Merge remote-tracking branch 'origin/dev/ez-security210625' into dev/ez-security210625

rengb 3 年之前
父節點
當前提交
c2f885ead6

+ 3 - 0
common/src/main/java/com/lantone/common/vo/GetDeptListVO.java

@@ -15,6 +15,9 @@ public class GetDeptListVO {
     @ApiModelProperty(value = "医院ID",hidden = true)
     private Long hospitalId;
 
+    @ApiModelProperty(value = "用户ID",hidden = true)
+    private Long userId;
+
     @ApiModelProperty(value = "科室名称")
     private String deptName;
 }

+ 18 - 6
security-center/src/main/java/com/lantone/security/facade/RegionManagementFacade.java

@@ -132,11 +132,16 @@ public class RegionManagementFacade {
      */
     public Boolean deleteRegion(Integer id) {
         Long hospitalId = SysUserUtils.getCurrentHospitalId();
-        boolean flag = regionFacade.lambdaUpdate()
+                       regionFacade.lambdaUpdate()
                 .eq(Region::getId,id)
                 .eq(Region::getHospitalId, hospitalId)
                 .set(Region::getIsDeleted,IsDeleteEnum.Y.getKey())
                 .update();
+        boolean flag = regionDeptService.lambdaUpdate()
+                .eq(RegionDept::getRegionId, id)
+                .eq(RegionDept::getHospitalId, hospitalId)
+                .set(RegionDept::getIsDeleted,IsDeleteEnum.Y.getKey())
+                .update();
         return flag;
     }
 
@@ -150,16 +155,14 @@ public class RegionManagementFacade {
     public void getCheckRegion(SaveRegionVO saveRegionVo) {
         saveRegionVo.setHospitalId(SysUserUtils.getCurrentHospitalId());
         saveRegionVo.setUserId(SysUserUtils.getCurrentPrincipleId());
-        if (null == saveRegionVo.getId()) {
-            Region region = regionFacade.lambdaQuery()
+            int count = regionFacade.lambdaQuery()
                     .eq(Region::getIsDeleted, IsDeleteEnum.N.getKey())
                     .eq(Region::getName, saveRegionVo.getName())
                     .eq(Region::getHospitalId, saveRegionVo.getHospitalId())
-                    .one();
-            if(null != region && null != region.getId()){
+                    .count();
+            if(count>0){
                 throw new ApiException("当前组织和病区已重复");
             }
-        }
     }
 
     /**
@@ -277,10 +280,19 @@ public class RegionManagementFacade {
      */
     public  List<DeptListDTO> getDept(GetDeptListVO getDeptListVO){
         getDeptListVO.setHospitalId(SysUserUtils.getCurrentHospitalId());
+        getDeptListVO.setUserId(SysUserUtils.getCurrentPrincipleId());
         List<DeptListDTO> deptListDTOS = new ArrayList<>();
+        List<Long> depts = regionDeptService.lambdaQuery()
+                .eq(RegionDept::getHospitalId, getDeptListVO.getHospitalId())
+                .eq(RegionDept::getIsDeleted,IsDeleteEnum.N.getKey())
+                .eq(RegionDept::getCreator, getDeptListVO.getUserId())
+                .list().stream().map(RegionDept::getDeptId).collect(Collectors.toList());
         LambdaQueryChainWrapper<Dept> lambdaQueryChainWrapper = deptFacade.lambdaQuery();
         lambdaQueryChainWrapper.eq(Dept::getHospitalId,getDeptListVO.getHospitalId());
         lambdaQueryChainWrapper.eq(Dept::getIsDeleted,IsDeleteEnum.N.getKey());
+        if(ListUtil.isNotEmpty(depts)){
+            lambdaQueryChainWrapper.in(Dept::getId,depts);
+        }
         if(StringUtil.isNotEmpty(getDeptListVO.getDeptName())){
             lambdaQueryChainWrapper.like(Dept::getName,getDeptListVO.getDeptName());
         }

+ 42 - 6
security-center/src/main/java/com/lantone/security/facade/RoleManagementFacade.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.google.common.collect.Lists;
 import com.lantone.common.dto.GetCreateRoleDTO;
 import com.lantone.common.dto.GetDictionaryInfoByTypeDTO;
 import com.lantone.common.dto.GetRoleDTO;
@@ -51,6 +52,7 @@ import com.lantone.dblayermbg.service.impl.RoleSoftwareResourceServiceImpl;
 import com.lantone.common.enums.IsDeleteEnum;
 import com.lantone.security.enums.DictionaryEnum;
 import com.lantone.security.enums.RelationEnum;
+import com.lantone.security.enums.ReturnTypeEnum;
 import com.lantone.security.enums.SoftwareEnum;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,7 +148,7 @@ public class RoleManagementFacade {
      */
     public Boolean addRole(AddRoleVO addRoleVO) {
         //校验
-        checkRole(null,addRoleVO.getName(), addRoleVO.getSoftwares());
+        checkRole(null, addRoleVO.getName(), addRoleVO.getSoftwares());
 
         //1.角色表插入角色信息
         addRoleVO.setCreator(SysUserUtils.getCurrentPrincipleId());
@@ -184,7 +186,7 @@ public class RoleManagementFacade {
         } else {
             if (ListUtil.isNotEmpty(roles)) {
                 roles.stream().forEach(role -> {
-                    if (!id.equals( role.getId())) {
+                    if (!id.equals(role.getId())) {
                         Asserts.fail("该角色已存在请重新输入");
                     }
                 });
@@ -243,11 +245,30 @@ public class RoleManagementFacade {
     public Boolean saveRoleSoftwareMenu(List<AddRoleSoftwareVO> softwares, Long roleId) {
         //插入sys_role_software_menu,sys_role_software_resource
         AtomicReference<Boolean> out = new AtomicReference<>(false);
+        //获取角色必备的权限添加给用户
+        String hasMenuResourceStr = dictionaryInfoFacade.getDicMap(ReturnTypeEnum.INTERFACE.getKey(),
+                Lists.newArrayList(DictionaryEnum.MANAGE_HIDE_MENU.getKey() + ""))
+                .get(DictionaryEnum.MANAGE_HIDE_MENU.getKey() + "").get("hasMenuResource");
+
         softwares.stream().forEach(addRoleSoftwareVO -> {
+            JSONObject hasMenuResourceJSON = null;
+            if (StringUtil.isNotEmpty(hasMenuResourceStr)) {
+                hasMenuResourceJSON = JSONObject.parseObject(hasMenuResourceStr);
+            }
             if (ListUtil.isNotEmpty(addRoleSoftwareVO.getSoftwareMenuIds())) {
                 //1.添加该角色对应的系统功能菜单关系sys_role_software_menu
                 List<RoleSoftwareMenu> roleSoftwareMenus = new ArrayList<>();
-                addRoleSoftwareVO.getSoftwareMenuIds().stream().forEach(softwareMenuId -> {
+                //去重
+                Set<Long> softwareMenus = new HashSet(addRoleSoftwareVO.getSoftwareMenuIds());
+                try {
+                    if (hasMenuResourceJSON != null) {
+                        softwareMenus.addAll(hasMenuResourceJSON.getJSONObject(addRoleSoftwareVO.getId() + "")
+                                .getJSONArray("menu").toJavaList(Long.class));
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                softwareMenus.stream().forEach(softwareMenuId -> {
                     RoleSoftwareMenu roleSoftwareMenu = new RoleSoftwareMenu();
                     roleSoftwareMenu.setRoleId(roleId);
                     roleSoftwareMenu.setSoftwareMenuId(softwareMenuId);
@@ -260,6 +281,14 @@ public class RoleManagementFacade {
                 List<RoleSoftwareResource> roleSoftwareResources = new ArrayList<>();
                 //资源去重
                 Set<Long> softwareResourceIds = new HashSet(addRoleSoftwareVO.getSoftwareResourceIds());
+                try {
+                    if (hasMenuResourceJSON != null) {
+                        softwareResourceIds.addAll(hasMenuResourceJSON.getJSONObject(addRoleSoftwareVO.getId() + "")
+                                .getJSONArray("resource").toJavaList(Long.class));
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
                 softwareResourceIds.stream().forEach(softwareResourceId -> {
                     RoleSoftwareResource roleSoftwareResource = new RoleSoftwareResource();
                     roleSoftwareResource.setRoleId(roleId);
@@ -331,7 +360,7 @@ public class RoleManagementFacade {
 
     /**
      * @param roleId
-     * @param type 区分组织管理添加角色、普通添加角色的功能菜单不同
+     * @param type   区分组织管理添加角色、普通添加角色的功能菜单不同
      * @Description通过角色id获取角色详情
      * @Return com.lantone.common.dto.GetRoleDTO
      */
@@ -464,8 +493,15 @@ public class RoleManagementFacade {
         //获取type下要隐藏的菜单
         List<GetDictionaryInfoByTypeDTO> configHideMenus = dictionaryInfoFacade.getBaseMapper()
                 .getDictionaryInfoByType(DictionaryEnum.MANAGE_HIDE_MENU.getKey());
-        if (ListUtil.isNotEmpty(configHideMenus)) {
-            hideMenus = JSONArray.parseArray(JSONObject.parseObject(configHideMenus.get(0).getVal()).getString(type));
+        String dictionaryInfoStr  = dictionaryInfoFacade.getDicMap(ReturnTypeEnum.INTERFACE.getKey(),
+                Lists.newArrayList(DictionaryEnum.MANAGE_HIDE_MENU.getKey() + ""))
+                .get(DictionaryEnum.MANAGE_HIDE_MENU.getKey() + "").get("manageHideMenu");
+        if (StringUtil.isNotEmpty(dictionaryInfoStr)) {
+            try {
+                hideMenus = JSONObject.parseObject(dictionaryInfoStr).getJSONArray(type).toJavaList(Long.class);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
         }
         List<UserMenuResourceTreeDTO> userMenuResourceTree = roleSoftwareMenuFacade.getBaseMapper().getMenuResourceRelation(loginRoles, selectRoles, hideMenus);
         return getTree(userMenuResourceTree);

+ 2 - 2
security-center/src/main/java/com/lantone/security/web/RegionManagementController.java

@@ -71,9 +71,9 @@ public class RegionManagementController {
         return CommonResult.success(sysRegionFacade.deleteRegion(id));
     }
 
-    @ApiOperation(value = "获取科室列表[by:cy]")
+  /*  @ApiOperation(value = "获取科室列表[by:cy]")
     @PostMapping("/getDeptList")
     public CommonResult<List<DeptListDTO>> getDeptList(@RequestBody GetDeptListVO getDeptListVO) {
         return CommonResult.success(sysRegionFacade.getDept(getDeptListVO));
-    }
+    }*/
 }