Эх сурвалжийг харах

fix(调用app-service不提供orgId字段修改): 调用app-service不提供orgId字段修改

调用app-service不提供orgId字段修改
mazq 3 жил өмнө
parent
commit
72ca506436

+ 2 - 2
dcuc-auth-api/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/IRoleAuthInfoFacade.java

@@ -63,12 +63,12 @@ public interface IRoleAuthInfoFacade {
     /**
      *
      * @param appId
-     * @param orgId
+     * @param orgCode
      * @return
      */
     @RequestMapping(value = "getRoleTjInfo")
     Map<String,Object> getRoleTjInfo(@RequestParam("appId")String appId,
-                                     @RequestParam("orgId")String orgId);
+                                     @RequestParam("orgCode")String orgCode);
 
     /**
      * @param appId

+ 5 - 5
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/facade/RoleAuthInfoFacade.java

@@ -46,15 +46,15 @@ public class RoleAuthInfoFacade implements IRoleAuthInfoFacade {
     public Page<TreeInfoVO> getRptList(SearchDTO searchDTO) {
         Searchable searchable = Searchable.toSearchable(searchDTO);
         String appId = searchable.getSearchFilterByKey("appId_eq").getValue().toString();
-        String orgId = searchable.getSearchFilterByKey("appOrgId_eq").getValue().toString();
+        String orgCode = searchable.getSearchFilterByKey("appOrgCode_eq").getValue().toString();
         searchable.removeSearchFilter("appId_eq");
-        searchable.removeSearchFilter("appOrgId_eq");
-        return roleAuthInfoService.getRptList(appId, orgId, searchable);
+        searchable.removeSearchFilter("appOrgCode_eq");
+        return roleAuthInfoService.getRptList(appId, orgCode, searchable);
     }
 
     @Override
-    public Map<String, Object> getRoleTjInfo(String appId,String orgId) {
-        return roleAuthInfoService.getRoleTjInfo(appId,orgId);
+    public Map<String, Object> getRoleTjInfo(String appId,String orgCode) {
+        return roleAuthInfoService.getRoleTjInfo(appId, orgCode);
     }
 
     @Override

+ 1 - 1
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/IRoleAuthInfoService.java

@@ -20,7 +20,7 @@ public interface IRoleAuthInfoService extends IOldBaseService<RoleAuthInfo, Stri
 
     Page<TreeInfoVO> getRptList(String orgId, Searchable searchable);
 
-    Page<TreeInfoVO> getRptList( String appId, String orgId,
+    Page<TreeInfoVO> getRptList( String appId, String orgCode,
                                 Searchable searchable);
 //
 //    List<TreeInfoVO> getRptOrgListByPid(String appId, String orgId);

+ 11 - 21
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/OrgQuotaAuthService.java

@@ -56,9 +56,6 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
     @Autowired
     private OrgQuotaRepository orgQuotaRepository;
 
-    @Autowired
-    private IStaffAssignAuthInfoService staffAssignAuthInfoService;
-
     @Autowired
     private IOrgQuotaAuthLogService iOrgQuotaAuthLogService;
 
@@ -185,23 +182,13 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
         }
     }
 
-//    @Override
-//    public void updateParentQuotaWhileAuth(String appId, String orgId, String roleId, String appOrgId, SecurityUser user,
-//                                           int diffNum, int dxfNum, OrgQuotaAuthInfo orgQuotaAuthInfo) {
-//        if (orgQuotaAuthInfo == null) {
-//            orgQuotaAuthInfo = this.setOrgQuotaAuthInfo(appId, roleId, orgId, 0, diffNum, 0, "10", user.getId(), user.getDeptId());
-//            orgQuotaRepository.save(orgQuotaAuthInfo);
-//        } else {
-//            orgQuotaAuthInfo.setYxfNum(orgQuotaAuthInfo.getYxfNum() + diffNum);
-//            orgQuotaRepository.update(orgQuotaAuthInfo);
-//        }
-//    }
 
     @Override
     public ResponseStatus authCancelChild(String appId, String roleId, String orgId) {
         long time = System.currentTimeMillis();
 
         ApplyInfo applyInfo = applyInfoFacade.applyDetail(appId);
+        AuthOrgInfo appOrgInfo = authOrgInfoService.getByOrgCode(applyInfo.getOrgCode());
         long time1 = System.currentTimeMillis();
         logger.info("authCancelChild:applyInfoFacade.applyDetail耗时:{} ms", (time1 - time));
 
@@ -247,14 +234,14 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
 
         OrgQuotaAuthInfo orgQuotaAuthInfo = orgQuotaAuthInfoMap.get(orgId);
         orgQuotaAuthInfo.setYxfNum(orgQuotaAuthInfo.getYxfNum() - cancelNum);
-        if (!orgId.equals(applyInfo.getOrgId())) {
+        if (!orgInfo.getCode().equals(applyInfo.getOrgCode())) {
             orgQuotaAuthInfo.setDfpNum(orgQuotaAuthInfo.getDfpNum() + cancelNum);
         }
         updateList.add(orgQuotaAuthInfo);
         //添加日志
         List<OrgQuotaAuthLog> orgQuotaAuthLogs = new ArrayList<OrgQuotaAuthLog>();
         for (OrgQuotaAuthInfo quotaAuthInfo : updateList) {
-            OrgQuotaAuthLog orgQuotaAuthLog = setOrgQuotaAuthLog(appId, roleId, applyInfo.getOrgId(), quotaAuthInfo.getTargetOrgId(),
+            OrgQuotaAuthLog orgQuotaAuthLog = setOrgQuotaAuthLog(appId, roleId, appOrgInfo.getId(), quotaAuthInfo.getTargetOrgId(),
                     quotaAuthInfo.getDfpNum() + quotaAuthInfo.getYxfNum() + quotaAuthInfo.getBjNum(), ContextUtils.getUserInfo().getId());
             orgQuotaAuthLogs.add(orgQuotaAuthLog);
         }
@@ -356,7 +343,7 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
     public ResponseStatus authCancelSelf(String applicationId, String roleId, String orgId, String appMtAuthOrgIds) {
 
         ApplyInfo applyInfo = applyInfoFacade.applyDetail(applicationId);
-
+        AuthOrgInfo appOrgInfo = authOrgInfoService.getByOrgCode(applyInfo.getOrgCode());
         //查询用户拥有的应用机构管理权限范围机构
 
         AuthOrgInfo orgInfo = authOrgInfoService.findById(orgId);
@@ -370,7 +357,7 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
         boolean isRootUser = authUserInfoService.isRootUser(userId);
 
 
-        if ((haveParentAuth || isRootUser) && !orgId.equals(applyInfo.getOrgId())) {
+        if ((haveParentAuth || isRootUser) && !orgId.equals(appOrgInfo.getId())) {
             List<OrgQuotaAuthLog> orgQuotaAuthLogs = getChangeLogs(roleId, orgId, pOrgId, applyInfo);
             iOrgQuotaAuthLogService.saveAll(orgQuotaAuthLogs);
             return ResponseStatus.success("回收成功");
@@ -391,7 +378,8 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
         parent.setDfpNum(parent.getDfpNum() + changeNum);
         parent.setYxfNum(parent.getYxfNum() - changeNum);
 
-        String orgId = applyInfo.getOrgId();
+        AuthOrgInfo appOrgInfo = authOrgInfoService.getByOrgCode(applyInfo.getOrgCode());
+        String orgId = appOrgInfo.getId();
 
         OrgQuotaAuthLog curOrgQuotaAuthLog = setOrgQuotaAuthLog(appId, roleId, orgId,
                 curOrgId, cur.getDfpNum() + cur.getYxfNum() + cur.getBjNum(), ContextUtils.getUserInfo().getId());
@@ -425,12 +413,14 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
         OrgQuotaNumDTO orgQuotaNumDTO = authOrgBusiness.searchOrg(userId, rootId, unitClass, roleLevel);
 
         ApplyInfo applyInfo = applyInfoFacade.applyDetail(appId);
+        AuthOrgInfo appOrgInfo = authOrgInfoService.getByOrgCode(applyInfo.getOrgCode());
+        String appOrgId = appOrgInfo.getId();
 
         AuthOrgInfo rootOrg = authOrgInfoService.findById(rootId);
         int count = orgQuotaNumDTO.getCount();
         OrgQuotaAuthInfo rootOrgQuota = getOrgQuotaAuthInfo(appId, roleId, rootId);//获取当前本级机构配额信息
         //判断空闲名额是否足够
-        if (!rootId.equals(applyInfo.getOrgId()) && (rootOrgQuota == null || rootOrgQuota.getDfpNum() < count * addNum)) {
+        if (!rootId.equals(appOrgId) && (rootOrgQuota == null || rootOrgQuota.getDfpNum() < count * addNum)) {
             int kxme = rootOrgQuota == null ? 0 : rootOrgQuota.getDfpNum();
             return ResponseStatus.fail("机构【" + rootOrg.getFullName() + "】空闲名额不足,当前空闲名额为:" + kxme + ",所需下发名额为:" + addNum * count);
         }
@@ -456,7 +446,7 @@ public class OrgQuotaAuthService implements IOrgQuotaAuthService {
         //修改根节点
         boolean flag = StringUtils.isNotBlank(targetOrgLevel) && StringUtils.isNotBlank(orgLevel)
                 && Integer.parseInt(orgLevel) == Integer.parseInt(targetOrgLevel); //根节点机构层级与分配范围的层级相等
-        if (rootId.equals(applyInfo.getOrgId())) {   //根节点为应用所属机构
+        if (rootId.equals(appOrgId)) {   //根节点为应用所属机构
             OrgTreeNodeDTO rootOrgTreeNode = new OrgTreeNodeDTO();
             rootOrgTreeNode.setIsParent(false);
             rootOrgTreeNode.setId(rootId);

+ 6 - 109
dcuc-auth-service/src/main/java/com/dragoninfo/dcuc/auth/auth/service/impl/RoleAuthInfoService.java

@@ -34,116 +34,11 @@ public class RoleAuthInfoService extends BaseService<RoleAuthInfo, String> imple
 
     @Autowired
     private RoleAuthInfoBPO roleAuthInfoBPO;
-//    @Autowired
-//    private IStaffAssignAuthInfoService staffAssignAuthInfoService;
-//    @Autowired
-//    private IStaffAssignAuthLogService staffAssignAuthLogService;
-//    @Autowired
-//    private IRoleInfoService roleInfoService;
-//    @Autowired
-//    private IOrgQuotaAuthService iOrgQuotaAuthService;
 
     @Autowired
     private IAuthOrgInfoService authOrgInfoService;
 
 
-//    public boolean isStaffPass(String appId, String staffId, String orgId, Searchable searchable, String[] roleList, Long roleListSize) {
-//        boolean pass = false;
-//
-//        for (String roleId : roleList) {
-//            List<String> roleSize = new ArrayList<String>();
-//            roleSize.add(roleId);
-//            Searchable searchableNew = Searchable.newSearchable().addSearchFilter(SearchFilterHelper.newCondition("id", SearchOperator.eq, roleId)).setPage(1, 1);
-//            Page<RoleInfoVO> page = roleInfoService.getOrgRoleQuotaList(appId, orgId, searchableNew);
-//            long initQuotaSold = page.getContent().get(0).getTotalQuotas() - page.getContent().get(0).getQuotaed();
-//            if (roleSize.size() > initQuotaSold) {
-//
-//                return true;
-//            }
-//        }
-//
-//        //删除已保存角色记录
-//        roleAuthInfoBPO.deleteOldRole(appId, staffId, orgId);
-//        return pass;
-//    }
-//
-//    private void updateOrgQuotaAuthInfoRoleNoLimitCount(String appId, String roleId, String orgId, int staffSize, int delTotal, List<String> parentList) {
-//        int difNum = staffSize - delTotal;
-//        OrgQuotaAuthInfo orgQuotoAuthInfo = iOrgQuotaAuthService.getOrgQuotaAuthInfo(appId, roleId, orgId);
-//        SecurityUser userInfo = UserContextUtils.getCurrentUser();
-//        if (orgQuotoAuthInfo == null) {
-//            orgQuotoAuthInfo = iOrgQuotaAuthService.setOrgQuotaAuthInfo(appId, roleId, orgId, staffSize, 0, 0, "20", userInfo.getUserName(), userInfo.getDeptId());
-//        } else {
-//
-//            if (staffSize == 0) {
-//                orgQuotoAuthInfo.setBjNum(0);
-//            } else {
-//                orgQuotoAuthInfo.setBjNum(staffSize);
-//            }
-//        }
-//        iOrgQuotaAuthService.saveOrUpdate(orgQuotoAuthInfo);
-//
-//        for (String parentId : parentList) {
-//            OrgQuotaAuthInfo parentOrgQuotoAuthInfo = iOrgQuotaAuthService.getOrgQuotaAuthInfo(appId, roleId, parentId);
-//            if (parentOrgQuotoAuthInfo == null) {
-//                parentOrgQuotoAuthInfo = iOrgQuotaAuthService.setOrgQuotaAuthInfo(appId, roleId, parentId, 0, staffSize, 0, "20", userInfo.getUserName(), userInfo.getDeptId());
-//            } else {
-//                parentOrgQuotoAuthInfo.setYxfNum(parentOrgQuotoAuthInfo.getYxfNum() + difNum);
-//            }
-//            iOrgQuotaAuthService.saveOrUpdate(parentOrgQuotoAuthInfo);
-//        }
-//    }
-//
-//    public void saveStaff(String[] roleList, String staffId, String appId, String orgId, Long roleListSize, Searchable searchable) throws Exception {
-//        SecurityUser currentUser = UserContextUtils.getCurrentUser();//当前登录账号
-//        String managerId = currentUser.getUserName();
-//        StringBuffer errorMsg = new StringBuffer();
-//        int roleSize = roleList.length;
-//
-//        if (this.isStaffPass(appId, staffId, orgId, searchable, roleList, roleListSize)) {
-//            throw new Exception("超出待分配数额");
-//        } else {
-//            //删除已保存角色记录
-//            roleAuthInfoBPO.deleteOldRole(appId, staffId, orgId);
-//
-//            //重新保存角色记录
-//            if (roleList.length > 0) {
-//                for (String roleId : roleList) {
-//
-//                    if (roleAuthInfoBPO.isStaffQuota(appId, orgId, roleId) <= 0) {
-//                        throw new Exception("该机构未分配名额");
-//                    }
-//
-//                    StaffAssignAuthInfo staffAssignAuthInfo = new StaffAssignAuthInfo();
-//                    StaffAssignAuthLog staffAssignAuthLog = new StaffAssignAuthLog();
-//                    staffAssignAuthInfo.setAppId(appId);
-//                    staffAssignAuthInfo.setRoleId(roleId);
-//                    staffAssignAuthInfo.setStaffOrgId(orgId);
-//                    staffAssignAuthInfo.setStaffId(staffId);
-//                    staffAssignAuthInfo.setManagerId(managerId);
-//                    staffAssignAuthInfo.setMgeOrgId(currentUser.getDeptId()); // 之后取appOrgId
-//                    staffAssignAuthInfo.setCreateTime(new Date());
-//                    staffAssignAuthInfoService.save(staffAssignAuthInfo);
-//
-//                    //保存T_STAFF_ASSIGN_AUTH_INFO表
-//                    staffAssignAuthLog.setAppId(appId);
-//                    staffAssignAuthLog.setRoleId(roleId);
-//                    staffAssignAuthLog.setStaffId(staffId);
-//                    staffAssignAuthLog.setCreateTime(new Date());
-//                    staffAssignAuthLog.setStaffOrgId(orgId);
-//                    staffAssignAuthLog.setManagerId(managerId);
-//                    staffAssignAuthLog.setAppOrgId(currentUser.getDeptId()); // 之后取appOrgId
-//                    staffAssignAuthLogService.save(staffAssignAuthLog);
-//
-//                    //更新角色总额表
-//                    roleAuthInfoBPO.updateOrgQuotaAuthInfoStaff(appId, roleId, orgId);
-//
-//                }
-//            }
-//        }
-//
-//    }
-
     @Override
     public List<StaffAssignAuthInfo> getStaff(String roleId, String orgId) {
         return roleAuthInfoBPO.getStaff(roleId, orgId);
@@ -155,8 +50,9 @@ public class RoleAuthInfoService extends BaseService<RoleAuthInfo, String> imple
     }
 
     @Override
-    public Page<TreeInfoVO> getRptList(String appId, String orgId, Searchable searchable) {
-        return roleAuthInfoBPO.getRptList(appId, orgId, searchable);
+    public Page<TreeInfoVO> getRptList(String appId, String orgCode, Searchable searchable) {
+        AuthOrgInfo orgInfo = authOrgInfoService.getByOrgCode(orgCode);
+        return roleAuthInfoBPO.getRptList(appId, orgInfo.getId(), searchable);
     }
 
     @Override
@@ -172,8 +68,9 @@ public class RoleAuthInfoService extends BaseService<RoleAuthInfo, String> imple
      * @return
      */
     @Override
-    public Map<String, Object> getRoleTjInfo(String appId, String orgId) {
-        return roleAuthInfoBPO.getRoleTjInfo(appId, orgId);
+    public Map<String, Object> getRoleTjInfo(String appId, String orgCode) {
+        AuthOrgInfo authOrgInfo = authOrgInfoService.getByOrgCode(orgCode);
+        return roleAuthInfoBPO.getRoleTjInfo(appId, authOrgInfo.getId());
     }
 
     @Override