|
|
@@ -54,22 +54,23 @@ import java.util.stream.Collectors;
|
|
|
public class RoleServiceImpl extends SuperService {
|
|
|
|
|
|
@Autowired
|
|
|
- RoleDao roleDao;
|
|
|
+ private RoleDao roleDao;
|
|
|
|
|
|
@Autowired
|
|
|
- com.github.microservice.auth.client.service.RoleService roleService;
|
|
|
+ private com.github.microservice.auth.client.service.RoleService roleService;
|
|
|
|
|
|
@Autowired
|
|
|
- OrganizationDao organizationDao;
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
|
|
|
@Autowired
|
|
|
private AuthResourcesNameService authResourcesNameService;
|
|
|
|
|
|
@Autowired
|
|
|
- UserCountDao userCountDao;
|
|
|
+ private UserCountDao userCountDao;
|
|
|
|
|
|
@Autowired
|
|
|
- OrganizationUserDao organizationUserDao;
|
|
|
+ private OrganizationUserDao organizationUserDao;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 添加/编辑角色
|
|
|
@@ -550,6 +551,50 @@ public class RoleServiceImpl extends SuperService {
|
|
|
return roles;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断用户是否是项目管理员
|
|
|
+ *
|
|
|
+ * @param projectOid 项目oid
|
|
|
+ * @param userId 用户userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean userIsProjectManager(String projectOid, String userId) {
|
|
|
+ Organization organization = organizationDao.findTopByOid(projectOid);
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ UserAccount userAccount = userCountDao.findTopByUserId(userId);
|
|
|
+ if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ OrganizationUser organizationUser = organizationUserDao.findTopByOrganizationAndUser(
|
|
|
+ organization, userAccount);
|
|
|
+ if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (organizationUser.getIsAdmin() != null && organizationUser.getIsAdmin()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean userIsSuperAdmin(String userId) {
|
|
|
+ UserAccount userAccount = userCountDao.findTopByUserId(userId);
|
|
|
+ if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Organization organization = organizationDao.findTopByAuthType(AuthType.Platform);
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ OrganizationUser organizationUser = organizationUserDao.findTopByOrganizationAndUser(
|
|
|
+ organization, userAccount);
|
|
|
+ if (ObjectUtils.isNotEmpty(organizationUser)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
public List<RoleModel> toModels(List<Role> roles) {
|
|
|
if (ObjectUtils.isNotEmpty(roles)) {
|
|
|
return roles.stream().map(this::toModel).collect(Collectors.toList());
|
|
|
@@ -564,4 +609,5 @@ public class RoleServiceImpl extends SuperService {
|
|
|
}
|
|
|
return roleModel;
|
|
|
}
|
|
|
+
|
|
|
}
|