|
@@ -3,6 +3,7 @@ package com.bosshand.virgo.core.service;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bosshand.virgo.core.dao.*;
|
|
|
import com.bosshand.virgo.core.model.*;
|
|
|
+import com.bosshand.virgo.core.utils.StringUtil;
|
|
|
import com.bosshand.virgo.core.utils.Utils;
|
|
|
import com.bosshand.virgo.core.utils.WeChatUtil;
|
|
|
import com.bosshand.virgo.exception.Constant;
|
|
@@ -19,6 +20,9 @@ import java.util.*;
|
|
|
@Service
|
|
|
public class MgrUserService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MgrRoleDao mgrRoleDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private MgrUserDao mgrUserDao;
|
|
|
|
|
@@ -250,25 +254,44 @@ public class MgrUserService {
|
|
|
*/
|
|
|
private Map<Long, Set<JSONObject>> getProjectIdentity(long organizationId, MgrUser user) {
|
|
|
Map<Long, Set<JSONObject>> map = new HashMap<>();
|
|
|
- List<MgrOrganizationProject> list = mgrOrganizationProjectDao.get(organizationId, user.getId());
|
|
|
+
|
|
|
+ Set<Long> projectIds = new HashSet<>();
|
|
|
+
|
|
|
+ long userId = user.getId();
|
|
|
+
|
|
|
+ // 根据部门ids查找出部门树下的项目id
|
|
|
+ MgrUserRole mgrUserRole = mgrUserRoleDao.getUser(userId, organizationId);
|
|
|
+ if (mgrUserRole != null & StringUtil.notBlank(mgrUserRole.getRoles())) {
|
|
|
+ List<Long> roleIds = new ArrayList<>();
|
|
|
+ for (String roleId : mgrUserRole.getRoles().split(",")) {
|
|
|
+ roleIds.add(Long.parseLong(roleId));
|
|
|
+ }
|
|
|
+ List<MgrRole> mgrRoleList = mgrRoleDao.getIds(roleIds);
|
|
|
+ for (MgrRole role : mgrRoleList) {
|
|
|
+ projectIds.add(role.getProjectId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<MgrOrganizationProject> list = mgrOrganizationProjectDao.get(organizationId, userId);
|
|
|
if (list != null & list.size() > 0) {
|
|
|
- Set<Long> projectIds = new HashSet<>();
|
|
|
for (MgrOrganizationProject mop : list) {
|
|
|
projectIds.add(mop.getProjectId());
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (projectIds.size() > 0) {
|
|
|
- for (Long projectId : projectIds) {
|
|
|
- Set<JSONObject> identityList = new HashSet<>();
|
|
|
- if (isAdmin(user, organizationId)) {
|
|
|
- identityList.add(convert(Identity.DEFAULT_OWNER_ID));
|
|
|
- } else {
|
|
|
- identityList.add(convert(Identity.DEFAULT_MEMBER_ID));
|
|
|
- }
|
|
|
- map.put(projectId, identityList);
|
|
|
+ if (projectIds.size() > 0) {
|
|
|
+ for (Long projectId : projectIds) {
|
|
|
+ Set<JSONObject> identityList = new HashSet<>();
|
|
|
+ if (isAdmin(user, organizationId)) {
|
|
|
+ identityList.add(convert(Identity.DEFAULT_OWNER_ID));
|
|
|
+ } else {
|
|
|
+ identityList.add(convert(Identity.DEFAULT_MEMBER_ID));
|
|
|
}
|
|
|
+ map.put(projectId, identityList);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ if (list != null & list.size() > 0) {
|
|
|
for (MgrOrganizationProject mop : list) {
|
|
|
map.forEach((key, value) -> {
|
|
|
if (mop.getProjectId() == key) {
|
|
@@ -277,6 +300,7 @@ public class MgrUserService {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return map;
|
|
|
}
|
|
|
|