Browse Source

Merge branches 'dev' and 'dev_voice' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_voice

 Conflicts:
	epmet-module/gov-access/gov-access-server/deploy/docker-compose-dev.yml
	epmet-module/gov-access/gov-access-server/pom.xml
dev_shibei_match
yinzuomei 5 years ago
parent
commit
1a39c57ba3
  1. 2
      epmet-auth/deploy/docker-compose-dev.yml
  2. 2
      epmet-auth/pom.xml
  3. 10
      epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java
  4. 2
      epmet-auth/src/test/java/com/epmet/TokenGenTest.java
  5. 15
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java
  6. 5
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/LoginUserDetailsResultDTO.java
  7. 4
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java
  8. 4
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java
  9. 2
      epmet-module/gov-access/gov-access-server/deploy/docker-compose-dev.yml
  10. 2
      epmet-module/gov-access/gov-access-server/pom.xml
  11. 27
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java
  12. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/CustomerAgencyRedis.java
  13. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java
  14. 2
      epmet-user/epmet-user-server/deploy/docker-compose-dev.yml
  15. 2
      epmet-user/epmet-user-server/pom.xml
  16. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java

2
epmet-auth/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-auth-server: epmet-auth-server:
container_name: epmet-auth-server-dev container_name: epmet-auth-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.16 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-auth:0.3.17
ports: ports:
- "8081:8081" - "8081:8081"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-auth/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>0.3.16</version> <version>0.3.17</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId> <artifactId>epmet-cloud</artifactId>

10
epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java

@ -8,6 +8,7 @@ import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -175,7 +176,7 @@ public class GovLoginServiceImpl implements GovLoginService {
govTokenDto.setGridIdList(getGridIdList(staffLatestAgency.getStaffId())); govTokenDto.setGridIdList(getGridIdList(staffLatestAgency.getStaffId()));
CustomerAgencyDTO agency = getAgencyByStaffId(staffLatestAgency.getStaffId()); CustomerAgencyDTO agency = getAgencyByStaffId(staffLatestAgency.getStaffId());
if (agency != null) { if (agency != null) {
govTokenDto.setRoleIdList(queryGovStaffRoleIds(staffLatestAgency.getStaffId(), agency.getId())); govTokenDto.setRoleList(queryGovStaffRoles(staffLatestAgency.getStaffId(), agency.getId()));
} }
govTokenDto.setOrgIdPath(getOrgIdPath(staffLatestAgency.getStaffId())); govTokenDto.setOrgIdPath(getOrgIdPath(staffLatestAgency.getStaffId()));
@ -189,13 +190,14 @@ public class GovLoginServiceImpl implements GovLoginService {
* @param orgId * @param orgId
* @return * @return
*/ */
public Set<String> queryGovStaffRoleIds(String staffId, String orgId) { public List<GovTokenDto.Role> queryGovStaffRoles(String staffId, String orgId) {
StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); StaffRoleFormDTO formDTO = new StaffRoleFormDTO();
formDTO.setStaffId(staffId); formDTO.setStaffId(staffId);
formDTO.setOrgId(orgId); formDTO.setOrgId(orgId);
Result<List<GovStaffRoleDTO>> gridResult = epmetUserFeignClient.getRolesOfStaff(formDTO); Result<List<GovStaffRoleDTO>> gridResult = epmetUserFeignClient.getRolesOfStaff(formDTO);
if (!CollectionUtils.isEmpty(gridResult.getData())) { if (!CollectionUtils.isEmpty(gridResult.getData())) {
return gridResult.getData().stream().map(role -> role.getId()).collect(Collectors.toSet()); //return gridResult.getData().stream().map(role -> role.getId()).collect(Collectors.toSet());
return ConvertUtils.sourceToTarget(gridResult.getData(), GovTokenDto.Role.class);
} }
return null; return null;
} }
@ -352,7 +354,7 @@ public class GovLoginServiceImpl implements GovLoginService {
govTokenDto.setGridIdList(getGridIdList(staffId)); govTokenDto.setGridIdList(getGridIdList(staffId));
CustomerAgencyDTO agency = getAgencyByStaffId(staffId); CustomerAgencyDTO agency = getAgencyByStaffId(staffId);
if (agency != null) { if (agency != null) {
govTokenDto.setRoleIdList(queryGovStaffRoleIds(staffId, agency.getId())); govTokenDto.setRoleList(queryGovStaffRoles(staffId, agency.getId()));
} }
govTokenDto.setOrgIdPath(getOrgIdPath(staffId)); govTokenDto.setOrgIdPath(getOrgIdPath(staffId));

2
epmet-auth/src/test/java/com/epmet/TokenGenTest.java

@ -78,7 +78,7 @@ public class TokenGenTest {
govTokenDto.setGridIdList(govLoginService.getGridIdList(staffId)); govTokenDto.setGridIdList(govLoginService.getGridIdList(staffId));
CustomerAgencyDTO agency = govLoginService.getAgencyByStaffId(staffId); CustomerAgencyDTO agency = govLoginService.getAgencyByStaffId(staffId);
if (agency != null) { if (agency != null) {
govTokenDto.setRoleIdList(govLoginService.queryGovStaffRoleIds(staffId, agency.getId())); govTokenDto.setRoleList(govLoginService.queryGovStaffRoles(staffId, agency.getId()));
} }
govTokenDto.setOrgIdPath(govLoginService.getOrgIdPath(staffId)); govTokenDto.setOrgIdPath(govLoginService.getOrgIdPath(staffId));

15
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/dto/GovTokenDto.java

@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -77,7 +79,18 @@ public class GovTokenDto extends BaseTokenDto implements Serializable {
/** /**
* 角色ID列表 * 角色ID列表
*/ */
private Set<String> roleIdList; private List<Role> roleList;
@Data
public static class Role {
private String id;
private String roleKey;
private String roleName;
public Role() {
}
}
@Override @Override
public String toString() { public String toString() {

5
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/result/LoginUserDetailsResultDTO.java

@ -1,7 +1,9 @@
package com.epmet.dto.result; package com.epmet.dto.result;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import lombok.Data; import lombok.Data;
import java.util.List;
import java.util.Set; import java.util.Set;
@Data @Data
@ -25,7 +27,8 @@ public class LoginUserDetailsResultDTO {
/** /**
* 角色列表 * 角色列表
*/ */
private Set<String> roleIdList; //private Set<String> roleIdList;
private List<GovTokenDto.Role> roleList;
/** /**
* 部门id列表 * 部门id列表

4
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/feign/GovAccessFeignClient.java → epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/GovAccessFeignClient.java

@ -1,9 +1,9 @@
package com.epmet.dto.feign; package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.feign.fallback.GovAccessFeignClientFallBack;
import com.epmet.dto.form.InitDefaultOperationsFormDTO; import com.epmet.dto.form.InitDefaultOperationsFormDTO;
import com.epmet.feign.fallback.GovAccessFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;

4
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/feign/fallback/GovAccessFeignClientFallBack.java → epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/feign/fallback/GovAccessFeignClientFallBack.java

@ -1,10 +1,10 @@
package com.epmet.dto.feign.fallback; package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.feign.GovAccessFeignClient;
import com.epmet.dto.form.InitDefaultOperationsFormDTO; import com.epmet.dto.form.InitDefaultOperationsFormDTO;
import com.epmet.feign.GovAccessFeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**

2
epmet-module/gov-access/gov-access-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
gov-access-server: gov-access-server:
container_name: gov-access-server-dev container_name: gov-access-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-access-server:0.3.23 image: 192.168.1.130:10080/epmet-cloud-dev/gov-access-server:0.3.25
ports: ports:
- "8099:8099" - "8099:8099"
network_mode: host # 使用现有网络 network_mode: host # 使用现有网络

2
epmet-module/gov-access/gov-access-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<version>0.3.23</version> <version>0.3.25</version>
<parent> <parent>
<artifactId>gov-access</artifactId> <artifactId>gov-access</artifactId>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>

27
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessServiceImpl.java

@ -5,6 +5,7 @@ import com.epmet.bean.OpeScopeFilterResultBean;
import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -89,15 +90,15 @@ public class AccessServiceImpl implements AccessService {
if (userDetails == null) { if (userDetails == null) {
return false; return false;
} }
Set<String> roleIdList = userDetails.getRoleIdList(); List<GovTokenDto.Role> roleList = userDetails.getRoleList();
if (CollectionUtils.isEmpty(roleIdList)) { if (CollectionUtils.isEmpty(roleList)) {
return false; return false;
} }
final Set<String> operationKeys = new HashSet<>(); final Set<String> operationKeys = new HashSet<>();
roleIdList.stream().forEach(roleId -> { roleList.stream().forEach(role -> {
List<RoleOpeScopeResultDTO> opeAndScopes = listAllRoleOperationScopesByRoleId(roleId); List<RoleOpeScopeResultDTO> opeAndScopes = listAllRoleOperationScopesByRoleId(role.getId());
operationKeys.addAll(opeAndScopes.stream().map(opeAndScope -> opeAndScope.getOperationKey()).collect(Collectors.toSet())); operationKeys.addAll(opeAndScopes.stream().map(opeAndScope -> opeAndScope.getOperationKey()).collect(Collectors.toSet()));
}); });
@ -118,12 +119,12 @@ public class AccessServiceImpl implements AccessService {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (CollectionUtils.isEmpty(userDetails.getRoleIdList())) { if (CollectionUtils.isEmpty(userDetails.getRoleList())) {
//logger.warn("用户{}没有配置任何角色,无法执行{}操作", form.getUserId(), form.getOperationKey()); //logger.warn("用户{}没有配置任何角色,无法执行{}操作", form.getUserId(), form.getOperationKey());
throw new RenException(String.format("用户%s没有配置任何角色,无法执行%s操作", form.getUserId(), form.getOperationKey())); throw new RenException(String.format("用户%s没有配置任何角色,无法执行%s操作", form.getUserId(), form.getOperationKey()));
} }
OpeScopeFilterResultBean effectiveOpeScopes = getEffectiveOpeScopes(userDetails.getRoleIdList(), form.getOperationKey()); OpeScopeFilterResultBean effectiveOpeScopes = getEffectiveOpeScopes(userDetails.getRoleList(), form.getOperationKey());
if (effectiveOpeScopes.isAllScopes()) { if (effectiveOpeScopes.isAllScopes()) {
return sb.toString(); return sb.toString();
} }
@ -235,12 +236,12 @@ public class AccessServiceImpl implements AccessService {
/** /**
* 计算有效操作范围 * 计算有效操作范围
*/ */
public OpeScopeFilterResultBean getEffectiveOpeScopes(Set<String> roleIds, String reqiurePermission) { public OpeScopeFilterResultBean getEffectiveOpeScopes(List<GovTokenDto.Role> roles, String reqiurePermission) {
// 根据角色列表查询操作范围列表 // 根据角色列表查询操作范围列表
Set<RoleOpeScopeResultDTO> opeAndScopesOfThisOperation = new HashSet<>(); Set<RoleOpeScopeResultDTO> opeAndScopesOfThisOperation = new HashSet<>();
roleIds.forEach(roleId -> { roles.forEach(role -> {
List<RoleOpeScopeResultDTO> opes = listAllRoleOperationScopesByRoleId(roleId); List<RoleOpeScopeResultDTO> opes = listAllRoleOperationScopesByRoleId(role.getId());
if (!CollectionUtils.isEmpty(opes)) { if (!CollectionUtils.isEmpty(opes)) {
opes.forEach(ope -> { opes.forEach(ope -> {
if (reqiurePermission.equals(ope.getOperationKey())) { if (reqiurePermission.equals(ope.getOperationKey())) {
@ -441,7 +442,7 @@ public class AccessServiceImpl implements AccessService {
// 获取机关单位中的角色 // 获取机关单位中的角色
// 目前一个人只在一个单位下,所以不动态查询,如果后面需要一个人在多个单位,再改这里 // 目前一个人只在一个单位下,所以不动态查询,如果后面需要一个人在多个单位,再改这里
//List<GovStaffRoleDTO> roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId()); //List<GovStaffRoleDTO> roleDTOS = queryGovStaffRoles(staffId, belongAgency.getId());
Set<String> roleIdList = userDetails.getRoleIdList(); List<GovTokenDto.Role> roleList = userDetails.getRoleList();
// 当前组织和所属组织的orgId路径,以及他们的上下级关系 // 当前组织和所属组织的orgId路径,以及他们的上下级关系
String belongOrgIdPath = getOrgIdPath(belongAgency); String belongOrgIdPath = getOrgIdPath(belongAgency);
@ -450,9 +451,9 @@ public class AccessServiceImpl implements AccessService {
Set<String> filtedOps = new HashSet<>(); Set<String> filtedOps = new HashSet<>();
if (!CollectionUtils.isEmpty(roleIdList)) { if (!CollectionUtils.isEmpty(roleList)) {
roleIdList.forEach(roleId -> { roleList.forEach(role -> {
List<RoleOpeScopeResultDTO> opeAndScopeDTO = listAllRoleOperationScopesByRoleId(roleId); List<RoleOpeScopeResultDTO> opeAndScopeDTO = listAllRoleOperationScopesByRoleId(role.getId());
filtedOps.addAll(filterOpesByScope(currOrgRelation, opeAndScopeDTO)); filtedOps.addAll(filterOpesByScope(currOrgRelation, opeAndScopeDTO));
}); });
} }

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/CustomerAgencyRedis.java

@ -42,6 +42,11 @@ public class CustomerAgencyRedis {
} }
public void delete(String agencyId) {
String key = RedisKeys.getAgencyByIdKey(agencyId);
redisUtils.delete(key);
}
public void set(String agencyId, CustomerAgencyDTO value){ public void set(String agencyId, CustomerAgencyDTO value){
String key = RedisKeys.getAgencyByIdKey(agencyId); String key = RedisKeys.getAgencyByIdKey(agencyId);
Map<String, Object> map = BeanUtil.beanToMap(value, false, true); Map<String, Object> map = BeanUtil.beanToMap(value, false, true);

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java

@ -151,6 +151,9 @@ public class AgencyServiceImpl implements AgencyService {
log.error(CustomerAgencyConstant.UPDATE_EXCEPTION); log.error(CustomerAgencyConstant.UPDATE_EXCEPTION);
throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION);
} }
//5.redis缓存
customerAgencyRedis.delete(formDTO.getAgencyId());
return result; return result;
} }

2
epmet-user/epmet-user-server/deploy/docker-compose-dev.yml

@ -2,7 +2,7 @@ version: "3.7"
services: services:
epmet-user-server: epmet-user-server:
container_name: epmet-user-server-dev container_name: epmet-user-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.55 image: 192.168.1.130:10080/epmet-cloud-dev/epmet-user-server:0.3.56
ports: ports:
- "8087:8087" - "8087:8087"
network_mode: host # 不会创建新的网络 network_mode: host # 不会创建新的网络

2
epmet-user/epmet-user-server/pom.xml

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>0.3.55</version> <version>0.3.56</version>
<parent> <parent>
<groupId>com.epmet</groupId> <groupId>com.epmet</groupId>
<artifactId>epmet-user</artifactId> <artifactId>epmet-user</artifactId>

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java

@ -28,10 +28,10 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.GovStaffRoleDao; import com.epmet.dao.GovStaffRoleDao;
import com.epmet.dao.GovStaffRoleTemplateDao; import com.epmet.dao.GovStaffRoleTemplateDao;
import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.GovStaffRoleDTO;
import com.epmet.dto.feign.GovAccessFeignClient;
import com.epmet.dto.form.InitDefaultOperationsFormDTO; import com.epmet.dto.form.InitDefaultOperationsFormDTO;
import com.epmet.dto.result.GovStaffRoleTemplateDTO; import com.epmet.dto.result.GovStaffRoleTemplateDTO;
import com.epmet.entity.GovStaffRoleEntity; import com.epmet.entity.GovStaffRoleEntity;
import com.epmet.feign.GovAccessFeignClient;
import com.epmet.redis.GovStaffRoleRedis; import com.epmet.redis.GovStaffRoleRedis;
import com.epmet.service.GovStaffRoleService; import com.epmet.service.GovStaffRoleService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;

Loading…
Cancel
Save