Browse Source

Merge branch 'dev' into release

dev_shibei_match
wxz 5 years ago
parent
commit
dfbfc6775d
  1. 10
      epmet-commons/epmet-commons-dynamic-datasource/src/main/java/com/epmet/commons/dynamic/datasource/annotation/DataSource.java
  2. 42
      epmet-commons/epmet-commons-dynamic-datasource/src/main/java/com/epmet/commons/dynamic/datasource/aspect/DataSourceAspect.java
  3. 12
      epmet-commons/epmet-commons-dynamic-datasource/src/main/java/com/epmet/commons/dynamic/datasource/bean/DataSourceParam.java
  4. 54
      epmet-commons/epmet-commons-extapp-auth/pom.xml
  5. 32
      epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/annotation/ExternalAppRequestAuth.java
  6. 99
      epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java
  7. 12
      epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/bean/ExternalAppRequestParam.java
  8. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java
  9. 5
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  10. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  11. 1
      epmet-commons/pom.xml
  12. 2
      epmet-gateway/deploy/docker-compose-dev.yml
  13. 13
      epmet-gateway/pom.xml
  14. 8
      epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java
  15. 5
      epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java
  16. 15
      epmet-gateway/src/main/resources/bootstrap.yml
  17. 5
      epmet-module/data-report/data-report-server/pom.xml
  18. 19
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/test/TestController.java
  19. 18
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppAuthFormDTO.java
  20. 25
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java
  21. 30
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java
  22. 10
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalAppAuthResultDTO.java
  23. 29
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalAppResultDTO.java
  24. 46
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java
  25. 11
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  26. 7
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  27. 2
      epmet-module/epmet-common-service/common-service-server/deploy/docker-compose-dev.yml
  28. 8
      epmet-module/epmet-common-service/common-service-server/pom.xml
  29. 98
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java
  30. 69
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java
  31. 42
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java
  32. 43
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java
  33. 56
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java
  34. 51
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppEntity.java
  35. 51
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppSecretEntity.java
  36. 46
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java
  37. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppAuthService.java
  38. 28
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppSecretService.java
  39. 35
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
  40. 14
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java
  41. 115
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppAuthServiceImpl.java
  42. 31
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppSecretServiceImpl.java
  43. 133
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
  44. 64
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java
  45. 93
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java
  46. 64
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml
  47. 37
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml
  48. 45
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml
  49. 41
      epmet-module/epmet-ext/epmet-ext-client/pom.xml
  50. 25
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/StaffSinAgencyFormDTO.java
  51. 25
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/StaffSinDeptFormDTO.java
  52. 26
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/StaffSinGridFormDTO.java
  53. 32
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/RoleResultDTO.java
  54. 42
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/StaffSinDeptResultDTO.java
  55. 11
      epmet-module/epmet-ext/epmet-ext-server/Dockerfile
  56. 17
      epmet-module/epmet-ext/epmet-ext-server/deploy/docker-compose-dev.yml
  57. 17
      epmet-module/epmet-ext/epmet-ext-server/deploy/docker-compose-prod.yml
  58. 17
      epmet-module/epmet-ext/epmet-ext-server/deploy/docker-compose-test.yml
  59. 272
      epmet-module/epmet-ext/epmet-ext-server/pom.xml
  60. 17
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/EpmetExtApplication.java
  61. 40
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/aspect/RequestLogAspect.java
  62. 26
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/config/ModuleConfigImpl.java
  63. 17
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/constant/ModuleConstant.java
  64. 105
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java
  65. 44
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpUserController.java
  66. 41
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java
  67. 126
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java
  68. 100
      epmet-module/epmet-ext/epmet-ext-server/src/main/resources/bootstrap.yml
  69. 1
      epmet-module/epmet-ext/epmet-ext-server/src/main/resources/db/migration/V0.0.1__demo.sql
  70. 164
      epmet-module/epmet-ext/epmet-ext-server/src/main/resources/logback-spring.xml
  71. 21
      epmet-module/epmet-ext/pom.xml
  72. 29
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerAccessTokenInfoFormDTO.java
  73. 4
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ModifyDomainFormDTO.java
  74. 4
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/WebviewDomainFormDTO.java
  75. 56
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerAccessTokenInfoResultDTO.java
  76. 2
      epmet-module/epmet-third/epmet-third-server/deploy/docker-compose-dev.yml
  77. 2
      epmet-module/epmet-third/epmet-third-server/pom.xml
  78. 17
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AppLetAuthorizationController.java
  79. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
  80. 12
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/AppLetAuthorizationService.java
  81. 17
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java
  82. 21
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
  83. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SettingServiceImpl.java
  84. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java
  85. 22
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
  86. 20
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyIdFormDTO.java
  87. 21
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerIdFormDTO.java
  88. 20
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentIdFormDTO.java
  89. 20
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GridIdFormDTO.java
  90. 31
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UpdateCustomerParameterFormDTO.java
  91. 20
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridCountResultDTO.java
  92. 26
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtDeptResultDTO.java
  93. 26
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtGridResultDTO.java
  94. 26
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtRoleMapResultDTO.java
  95. 86
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtStaffInfoResultDTO.java
  96. 43
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtStaffPermissionResultDTO.java
  97. 82
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtUserInfoResultDTO.java
  98. 73
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java
  99. 40
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java
  100. 2
      epmet-module/gov-org/gov-org-server/deploy/docker-compose-dev.yml

10
epmet-commons/epmet-commons-dynamic-datasource/src/main/java/com/epmet/commons/dynamic/datasource/annotation/DataSource.java

@ -21,5 +21,15 @@ import java.lang.annotation.*;
@Documented
@Inherited
public @interface DataSource {
/**
* 直接指定数据源名称
* @return
*/
String value() default "";
/**
* 是否从参数中获取数据源名称优先级高于value
* @return
*/
boolean datasourceNameFromArg() default false;
}

42
epmet-commons/epmet-commons-dynamic-datasource/src/main/java/com/epmet/commons/dynamic/datasource/aspect/DataSourceAspect.java

@ -9,7 +9,9 @@
package com.epmet.commons.dynamic.datasource.aspect;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.dynamic.datasource.bean.DataSourceParam;
import com.epmet.commons.dynamic.datasource.config.DynamicContextHolder;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@ -22,6 +24,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
/**
* 多数据源切面处理类
@ -52,9 +55,9 @@ public class DataSourceAspect {
if(targetDataSource != null || methodDataSource != null){
String value;
if(methodDataSource != null){
value = methodDataSource.value();
value = getDatasourceName(methodDataSource, signature.getMethod().getParameters(), point.getArgs());
}else {
value = targetDataSource.value();
value = getDatasourceName(targetDataSource, signature.getMethod().getParameters(), point.getArgs());
}
DynamicContextHolder.push(value);
@ -68,4 +71,39 @@ public class DataSourceAspect {
logger.debug("clean datasource");
}
}
/**
* 获取要用到的数据源名称
* @param dataSource
* @return
*/
public String getDatasourceName(DataSource dataSource, Parameter[] methodParameters, Object[] methodArgValues) {
if (dataSource.datasourceNameFromArg()) {
// 1.从参数中动态获取数据源名称
String datasourceNameFromParam = getDatasourceNameFromArg(methodParameters, methodArgValues);
if (StringUtils.isNotBlank(datasourceNameFromParam)) {
// 如果有DatasourceParam类型的参数并且设置了datasourceName值,那么返回这个值,否则使用硬编码的
return datasourceNameFromParam;
}
}
// 2.硬编码指定数据源名称
return dataSource.value();
}
/**
* 从参数中取数据源名称
* @param parameters
* @param argsObject
* @return
*/
public String getDatasourceNameFromArg(Parameter[] parameters, Object[] argsObject) {
for (int i = 0; i < parameters.length; i++) {
if (parameters[i].getType() == DataSourceParam.class) {
DataSourceParam param = (DataSourceParam) argsObject[i];
return param.getDatasourceName();
}
}
return null;
}
}

12
epmet-commons/epmet-commons-dynamic-datasource/src/main/java/com/epmet/commons/dynamic/datasource/bean/DataSourceParam.java

@ -0,0 +1,12 @@
package com.epmet.commons.dynamic.datasource.bean;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class DataSourceParam {
private String datasourceName;
}

54
epmet-commons/epmet-commons-extapp-auth/pom.xml

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>epmet-commons-extapp-auth</artifactId>
<packaging>jar</packaging>
<properties>
<hibernate.validator.version>6.0.17.Final</hibernate.validator.version>
<commons.lang.version>3.7</commons.lang.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.io.version>2.6</commons.io.version>
<hutool.version>4.6.1</hutool.version>
<easypoi.version>4.1.0</easypoi.version>
<joda.time.version>2.9.9</joda.time.version>
<fastjson.version>1.2.60</fastjson.version>
<gson.version>2.8.6</gson.version>
<jsoup.version>1.11.3</jsoup.version>
<lombok.version>1.18.4</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>

32
epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/annotation/ExternalAppRequestAuth.java

@ -0,0 +1,32 @@
/**
* Copyright 2018 人人开源 http://www.renren.io
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.epmet.commons.extappauth.annotation;
import java.lang.annotation.*;
/**
* 需要认证的外部请求
* @Author wxz
* @Description
* @Date 2020/4/23 16:17
**/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExternalAppRequestAuth {
}

99
epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java

@ -0,0 +1,99 @@
package com.epmet.commons.extappauth.aspect;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Parameter;
/**
* 外部应用请求认证切面
*/
@Aspect
@Component
@Order(100)
public class ExternalAppRequestAuthAspect {
private static Logger logger = LoggerFactory.getLogger(ExternalAppRequestAuthAspect.class);
public static final String ACCESS_TOKEN_HEADER_KEY = "AccessToken";
public static final String APP_ID_HEADER_KEY = "appId";
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
/**
* 拦截加了ExternalRequestAuth注解的方法
*
* @param point
* @throws Throwable
*/
@Before("@annotation(com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth)")
public void auth(JoinPoint point) throws Throwable {
HttpServletRequest request = getRequest();
String token = request.getHeader(ACCESS_TOKEN_HEADER_KEY);
String appId = request.getHeader(APP_ID_HEADER_KEY);
if (StringUtils.isAnyBlank(token, appId)) {
throw new RenException("请求头中的token和appId不能为空");
}
logger.info("外部应用请求认证拦截Aspect执行,appId:{}, token:{}", appId, token);
ExternalAppAuthFormDTO form = new ExternalAppAuthFormDTO();
form.setAppId(appId);
form.setToken(token);
Result<ExternalAppAuthResultDTO> result = commonServiceOpenFeignClient.externalAppAuth(form);
if (result == null) {
throw new RenException("调用服务进行外部应用认证,返回null");
}
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
ExternalAppAuthResultDTO authResult = result.getData();
if (!authResult.getSuccess()) {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_AUTH_ERROR.getCode(),
result.getData().getMessage());
}
// header参数赋值
MethodSignature signature = (MethodSignature) point.getSignature();
Parameter[] parameters = signature.getMethod().getParameters();
if (parameters != null && parameters.length != 0) {
for (int i = 0; i < parameters.length; i++) {
if (parameters[i].getType() == ExternalAppRequestParam.class) {
ExternalAppRequestParam requestParam = (ExternalAppRequestParam) point.getArgs()[i];
requestParam.setAppId(appId);
requestParam.setCustomerId(authResult.getCustomerId());
}
}
}
}
public HttpServletRequest getRequest() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) requestAttributes;
return sra.getRequest();
}
}

12
epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/bean/ExternalAppRequestParam.java

@ -0,0 +1,12 @@
package com.epmet.commons.extappauth.bean;
import lombok.Data;
/**
* 外部应用请求信息
*/
@Data
public class ExternalAppRequestParam {
private String customerId;
private String appId;
}

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ServiceConstant.java

@ -133,4 +133,9 @@ public interface ServiceConstant {
* 积分银行
* */
String EPMET_POINT_SERVER = "epmet-point-server";
/**
* 开放接口服务
*/
String EPMET_EXT_SERVER = "epmet-ext-server";
}

5
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -75,6 +75,8 @@ public enum EpmetErrorCode {
STAFF_ADD_FAILED(8403,"人员添加失败"),
STAFF_EDIT_FAILED(8404,"人员编辑失败"),
CANNOT_DISABLE_YOURSELF(8405,"您不能禁用自己"),
NO_SET_GRID_COUNT(8406,"您还未设置创建网格数量上限,请联系管理员设置"),
GRID_COUNT_UP(8407,"您的创建网格数量已到达上限,请联系管理员设置"),
ALREADY_EVALUATE(8501,"您已评价"),
ALREADY_VOTE(8502,"您已表态"),
@ -99,6 +101,9 @@ public enum EpmetErrorCode {
OPER_ADD_CUSTOMER_MANAGER_ERROR(8706, "新增客户管理员失败"),
OPER_UPLOAD_FILE_OVER_SIZE(8707, "文件体积过大"),
OPER_UPLOAD_FILE_TYPE_ERROR(8708, "文件类型错误"),
OPER_EXTERNAL_APP_AUTH_ERROR(8709, "外部应用认证失败"),
OPER_EXTERNAL_CUSTOMER_NOT_EXISTS(8710, "该客户不存在"),
OPER_EXTERNAL_APP_EXISTS(8711, "应用已存在"),
// 党建声音 前端提示 88段
DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"),

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -288,4 +288,13 @@ public class RedisKeys {
public static String getVolunteerSmsCodeKey(String phone) {
return String.format(rootPrefix+"smscode:regvolunteer:%s",phone);
}
/**
* 外部应用的secret key
* @param appId
* @return
*/
public static String getExternalAppSecretKey(String appId) {
return String.format(rootPrefix+"externalapp:secret:%s",appId);
}
}

1
epmet-commons/pom.xml

@ -22,6 +22,7 @@
<module>epmet-commons-tools-wx-ma</module>
<module>epmet-commons-tools-wx-mp</module>
<module>epmet-commons-service-call</module>
<module>epmet-commons-extapp-auth</module>
</modules>
</project>

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

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-gateway-server:
container_name: epmet-gateway-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-gateway:0.3.31
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-gateway:0.3.32
ports:
- "8080:8080"
network_mode: host # 使用现有网络

13
epmet-gateway/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"
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>
<version>0.3.31</version>
<version>0.3.32</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-cloud</artifactId>
@ -190,12 +190,15 @@
<gateway.routes.epmet-third-server.uri>lb://epmet-third-server</gateway.routes.epmet-third-server.uri>
<!-- <gateway.routes.epmet-third-server.uri>http://localhost:8110</gateway.routes.epmet-third-server.uri>-->
<!-- 爱心互助 -->
<!-- 32、爱心互助 -->
<gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url>
<!-- <gateway.routes.epmet-heart-server.url>http://127.0.0.1:8111</gateway.routes.epmet-heart-server.url>-->
<!-- 32、 积分银行 -->
<!-- 33、 积分银行 -->
<gateway.routes.epmet-point-server.url>lb://epmet-point-server</gateway.routes.epmet-point-server.url>
<!-- <gateway.routes.epmet-point-server.url>http://127.0.0.1:8112</gateway.routes.epmet-point-server.url>-->
<!-- 34、 开放接口服务 -->
<gateway.routes.epmet-ext-server.url>lb://epmet-ext-server</gateway.routes.epmet-ext-server.url>
<!-- <gateway.routes.epmet-ext-server.url>http://127.0.0.1:8113</gateway.routes.epmet-ext-server.url>-->
</properties>
</profile>
<profile>
@ -284,6 +287,8 @@
<gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url>
<!-- 33、积分银行 -->
<gateway.routes.epmet-point-server.url>lb://epmet-point-server</gateway.routes.epmet-point-server.url>
<!-- 34、开放接口服务 -->
<gateway.routes.epmet-ext-server.url>lb://epmet-ext-server</gateway.routes.epmet-ext-server.url>
</properties>
</profile>
<profile>
@ -369,6 +374,8 @@
<gateway.routes.epmet-heart-server.url>lb://epmet-heart-server</gateway.routes.epmet-heart-server.url>
<!-- 33、 积分银行 -->
<gateway.routes.epmet-point-server.url>lb://epmet-point-server</gateway.routes.epmet-point-server.url>
<!-- 34、开放接口服务 -->
<gateway.routes.epmet-ext-server.url>lb://epmet-ext-server</gateway.routes.epmet-ext-server.url>
</properties>
</profile>
</profiles>

8
epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java

@ -208,11 +208,19 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
* @return
*/
private boolean needAuth(String requestUri) {
// 优先判断白名单,在白名单中的就直接放行
for (String url : cpProperty.getUrlWhiteList()) {
if (antPathMatcher.match(url, requestUri)) {
return false;
}
}
for (String url : cpProperty.getSwaggerUrls()) {
if (antPathMatcher.match(url, requestUri)) {
return false;
}
}
for (String url : cpProperty.getUrls()) {
if (antPathMatcher.match(url, requestUri)) {
return true;

5
epmet-gateway/src/main/java/com/epmet/filter/CpProperty.java

@ -19,6 +19,11 @@ public class CpProperty {
private List<String> urls;
/**
* 白名单
*/
private List<String> urlWhiteList;
/**
* 不处理token直接通过
*/

15
epmet-gateway/src/main/resources/bootstrap.yml

@ -313,6 +313,15 @@ spring:
filters:
- StripPrefix=1
- CpAuth=true
# 开放接口服务
- id: epmet-ext-server
uri: @gateway.routes.epmet-ext-server.url@
order: 34
predicates:
- Path=${server.servlet.context-path}/epmet/ext/**
filters:
- StripPrefix=1
- CpAuth=true
nacos:
discovery:
server-addr: @nacos.server-addr@
@ -427,6 +436,12 @@ epmet:
- /gov/issue/**
- /gov/project/**
- /resi/home/**
- /data/report/**
# url认证白名单,先判断白名单,在白名单中的url直接放行,不再判断上述需要认证的名单
urlWhiteList:
- /data/report/test/test
swaggerUrls:
jwt:

5
epmet-module/data-report/data-report-server/pom.xml

@ -62,6 +62,11 @@
<version>0.3.1</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-extapp-auth</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>

19
epmet-module/data-report/data-report-server/src/main/java/com/epmet/controller/test/TestController.java

@ -0,0 +1,19 @@
package com.epmet.controller.test;
import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("test")
public class TestController {
@ExternalAppRequestAuth
@RequestMapping("/test")
public Result test(ExternalAppRequestParam externalAppRequestParam, String ext) {
return new Result().ok("调用成功,客户信息:"+externalAppRequestParam);
}
}

18
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppAuthFormDTO.java

@ -0,0 +1,18 @@
package com.epmet.dto.form;
import lombok.Data;
@Data
public class ExternalAppAuthFormDTO {
/**
* 应用ID
*/
private String appId;
/**
* token字符串
*/
private String token;
}

25
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class ExternalAppFormDTO {
public interface AddExternalApp {}
public interface UpdateExternalApp {}
@NotBlank(message = "缺少应用ID", groups = { UpdateExternalApp.class })
private String appId;
@NotBlank(message = "缺少应用名称", groups = { AddExternalApp.class, UpdateExternalApp.class })
private String appName;
@NotBlank(message = "缺少所属客户ID", groups = { AddExternalApp.class, UpdateExternalApp.class })
private String customerId;
private Integer pageNo = 1;
private Integer pageSize = 10;
}

30
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalCustomerFormDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
@Data
public class ExternalCustomerFormDTO {
public interface ListExternalCustomerGroup {}
public interface AddExternalCustomerGroup {}
public interface UpdateExternalCustomerGroup {}
@NotBlank(message = "缺少客户ID参数", groups = { UpdateExternalCustomerGroup.class })
private String customerId;
/**
* 客户名称
*/
@NotBlank(message = "请填写客户名称", groups = { AddExternalCustomerGroup.class, UpdateExternalCustomerGroup.class })
private String customerName;
@Min(value = 0, groups = { ListExternalCustomerGroup.class })
private Integer pageNo = 1;
@Min(value = 0, groups = { ListExternalCustomerGroup.class })
private Integer pageSize = 10;
}

10
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalAppAuthResultDTO.java

@ -0,0 +1,10 @@
package com.epmet.dto.result;
import lombok.Data;
@Data
public class ExternalAppAuthResultDTO {
private Boolean success;
private String message;
private String customerId;
}

29
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalAppResultDTO.java

@ -0,0 +1,29 @@
package com.epmet.dto.result;
import lombok.Data;
@Data
public class ExternalAppResultDTO {
public String appId;
/**
* APP名字
*/
private String appName;
/**
* 客户ID
*/
private String customerId;
/**
* 客户名称
*/
private String customerName;
/**
* 秘钥
*/
private String secret;
}

46
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ExternalCustomerResultDTO.java

@ -0,0 +1,46 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.result;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
public class ExternalCustomerResultDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 客户名称
*/
private String customerName;
}

11
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -2,7 +2,9 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.fallback.EpmetCommonServiceOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
@ -18,6 +20,7 @@ import java.util.List;
* @date 2020/6/4 10:28
*/
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103")
public interface EpmetCommonServiceOpenFeignClient {
/**
* @param formDTO
@ -28,4 +31,12 @@ public interface EpmetCommonServiceOpenFeignClient {
**/
@PostMapping("commonservice/workday/detentiondays")
Result<List<WorkDayResultDTO>> detentionDays(@RequestBody List<WorkDayFormDTO> formDTO);
/**
* 外部应用认证接口
* @param formDTO
* @return
*/
@PostMapping("/commonservice/externalapp/auth")
Result<ExternalAppAuthResultDTO> externalAppAuth(@RequestBody ExternalAppAuthFormDTO formDTO);
}

7
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -3,7 +3,9 @@ package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import org.springframework.stereotype.Component;
@ -22,4 +24,9 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result<List<WorkDayResultDTO>> detentionDays(List<WorkDayFormDTO> formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "detentionDays", formDTO);
}
@Override
public Result<ExternalAppAuthResultDTO> externalAppAuth(ExternalAppAuthFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "externalAppAuth", formDTO);
}
}

2
epmet-module/epmet-common-service/common-service-server/deploy/docker-compose-dev.yml

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

8
epmet-module/epmet-common-service/common-service-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"
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>
<version>0.3.9</version>
<version>0.3.16</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-common-service</artifactId>
@ -58,6 +58,12 @@
<artifactId>feign-httpclient</artifactId>
<version>10.3.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
<build>

98
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java

@ -0,0 +1,98 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.ExternalAppFormDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.service.ExternalAppAuthService;
import com.epmet.service.ExternalAppService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/externalapp")
public class ExternalAppController {
private static Logger logger = LoggerFactory.getLogger(ExternalAppController.class);
@Autowired
private ExternalAppAuthService externalAppAuthService;
@Autowired
private ExternalAppService externalAppService;
/**
* 外部请求认证
* @param formDTO
* @return
*/
@PostMapping("/auth")
public Result<ExternalAppAuthResultDTO> auth(@RequestBody ExternalAppAuthFormDTO formDTO) {
String appId = formDTO.getAppId();
String token = formDTO.getToken();
if (StringUtils.isAnyBlank(token, appId)) {
throw new RenException("请求头中的token和appId不能为空");
}
logger.info("外部应用请求认证拦截Aspect。appId:{}, token:{}", appId, token);
ExternalAppAuthResultDTO auth = externalAppAuthService.auth(appId, token);
return new Result<ExternalAppAuthResultDTO>().ok(auth);
}
/**
* 添加应用
* @param formDTO
* @return
*/
@PostMapping("/add")
public Result<ExternalAppResultDTO> add(@RequestBody ExternalAppFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalAppFormDTO.AddExternalApp.class);
String appName = formDTO.getAppName();
String customerId = formDTO.getCustomerId();
ExternalAppResultDTO dto = externalAppService.add(appName, customerId);
return new Result<ExternalAppResultDTO>().ok(dto);
}
/**
* 修改应用
* @param formDTO
* @return
*/
@PostMapping("/update")
public Result<ExternalAppResultDTO> update(@RequestBody ExternalAppFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalAppFormDTO.UpdateExternalApp.class);
String appId = formDTO.getAppId();
String appName = formDTO.getAppName();
String customerId = formDTO.getCustomerId();
ExternalAppResultDTO dto = externalAppService.updateById(appId, appName, customerId);
return new Result<ExternalAppResultDTO>().ok(dto);
}
/**
* 查询列表
* @param formDTO
* @return
*/
@PostMapping("/list")
public Result<PageData<ExternalAppResultDTO>> list(@RequestBody ExternalAppFormDTO formDTO) {
PageData<ExternalAppResultDTO> page = externalAppService.listPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getCustomerId());
return new Result<PageData<ExternalAppResultDTO>>().ok(page);
}
}

69
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalCustomerController.java

@ -0,0 +1,69 @@
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ExternalCustomerFormDTO;
import com.epmet.dto.result.ExternalCustomerResultDTO;
import com.epmet.service.ExternalCustomerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 外部客户管理
*/
@RestController
@RequestMapping("/externalcustomer")
public class ExternalCustomerController {
private static Logger logger = LoggerFactory.getLogger(ExternalCustomerController.class);
@Autowired
private ExternalCustomerService externalCustomerService;
/**
* 外部客户管理
* @return
*/
@PostMapping("/list")
public Result<PageData<ExternalCustomerResultDTO>> list(@RequestBody ExternalCustomerFormDTO form) {
ValidatorUtils.validateEntity(form, ExternalCustomerFormDTO.ListExternalCustomerGroup.class);
Integer pageNo = form.getPageNo();
Integer pageSize = form.getPageSize();
PageData<ExternalCustomerResultDTO> page = externalCustomerService.listPage(pageNo, pageSize);
return new Result<PageData<ExternalCustomerResultDTO>>().ok(page);
}
/**
* 添加外部客户
* @param formDTO
* @return
*/
@PostMapping("add")
public Result<ExternalCustomerResultDTO> add(@RequestBody ExternalCustomerFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalCustomerFormDTO.AddExternalCustomerGroup.class);
String customerName = formDTO.getCustomerName();
ExternalCustomerResultDTO result = externalCustomerService.add(customerName);
return new Result<ExternalCustomerResultDTO>().ok(result);
}
/**
* 更新客户信息
* @param formDTO
* @return
*/
@PostMapping("update")
public Result<ExternalCustomerResultDTO> update(@RequestBody ExternalCustomerFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ExternalCustomerFormDTO.UpdateExternalCustomerGroup.class);
String customerId = formDTO.getCustomerId();
String customerName = formDTO.getCustomerName();
ExternalCustomerResultDTO result = externalCustomerService.update(customerId, customerName);
return new Result<ExternalCustomerResultDTO>().ok(result);
}
}

42
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java

@ -0,0 +1,42 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.entity.ExternalAppEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 外部应用列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Mapper
public interface ExternalAppDao extends BaseDao<ExternalAppEntity> {
Integer countByAppNameAndCustomerId(@Param("appName") String appName, @Param("customerId") String customerId);
ExternalAppResultDTO getByNameAndCustomerId(@Param("appName") String appName, @Param("customerId") String customerId);
List<ExternalAppResultDTO> list(@Param("customerId") String customerId);
}

43
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java

@ -0,0 +1,43 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.ExternalAppSecretEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 外部应用秘钥列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Mapper
public interface ExternalAppSecretDao extends BaseDao<ExternalAppSecretEntity> {
/**
* 查询app对应的秘钥
* @param appId
* @return
*/
ExternalAppSecretEntity getSecretsByAppId(@Param("appId") String appId);
}

56
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalCustomerDao.java

@ -0,0 +1,56 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.result.ExternalCustomerResultDTO;
import com.epmet.entity.ExternalCustomerEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Mapper
public interface ExternalCustomerDao extends BaseDao<ExternalCustomerEntity> {
/**
* 列出客户基本信息
* @return
*/
List<ExternalCustomerResultDTO> listBaseInfo();
/**
* 根据名称查询客户
* @param customerName
* @return
*/
ExternalCustomerResultDTO getByCustomerName(@Param("customerName") String customerName);
/**
* 根据客户名称计数
* @param customerName
* @return
*/
Integer countByCustomerName(@Param("customerName") String customerName);
}

51
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppEntity.java

@ -0,0 +1,51 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 外部应用列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("external_app")
public class ExternalAppEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* APP名字
*/
private String appName;
/**
* 客户ID
*/
private String customerId;
}

51
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalAppSecretEntity.java

@ -0,0 +1,51 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 外部应用秘钥列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("external_app_secret")
public class ExternalAppSecretEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* APP ID
*/
private String appId;
/**
* 秘钥
*/
private String secret;
}

46
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ExternalCustomerEntity.java

@ -0,0 +1,46 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-19
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("external_customer")
public class ExternalCustomerEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户名称
*/
private String customerName;
}

10
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppAuthService.java

@ -0,0 +1,10 @@
package com.epmet.service;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
public interface ExternalAppAuthService {
ExternalAppAuthResultDTO auth(String appId, String token);
}

28
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppSecretService.java

@ -0,0 +1,28 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
/**
* 外部应用秘钥列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
public interface ExternalAppSecretService {
}

35
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java

@ -0,0 +1,35 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.result.ExternalAppResultDTO;
/**
* 外部应用列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
public interface ExternalAppService {
ExternalAppResultDTO add(String appName, String customerId);
ExternalAppResultDTO updateById(String appId, String appName, String customerId);
PageData<ExternalAppResultDTO> listPage(Integer pageNo, Integer pageSize, String customerId);
}

14
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalCustomerService.java

@ -0,0 +1,14 @@
package com.epmet.service;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.result.ExternalCustomerResultDTO;
import com.epmet.entity.ExternalCustomerEntity;
public interface ExternalCustomerService {
PageData<ExternalCustomerResultDTO> listPage(Integer pageNo, Integer pageSize);
ExternalCustomerResultDTO add(String customerName);
ExternalCustomerResultDTO update(String customerId, String customerName);
}

115
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppAuthServiceImpl.java

@ -0,0 +1,115 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dao.ExternalAppDao;
import com.epmet.dao.ExternalAppSecretDao;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.entity.ExternalAppEntity;
import com.epmet.entity.ExternalAppSecretEntity;
import com.epmet.service.ExternalAppAuthService;
import com.epmet.utils.externalapp.ExtAppJwtTokenUtils;
import io.jsonwebtoken.Claims;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ExternalAppAuthServiceImpl implements ExternalAppAuthService {
private static Logger logger = LoggerFactory.getLogger(ExternalAppAuthServiceImpl.class);
@Autowired
private RedisUtils redisUtils;
@Autowired
private ExtAppJwtTokenUtils jwtTokenUtils;
@Autowired
private ExternalAppSecretDao externalAppSecretDao;
@Autowired
private ExternalAppDao externalAppDao;
private int diffMillins = 1000 * 60 * 5;
@Override
public ExternalAppAuthResultDTO auth(String appId, String token) {
String secret;
if (StringUtils.isBlank(secret = getTokenByAppId(appId))) {
return fillAuthResult(false, String.format("根据AppId:%s没有找到对应的秘钥", appId), null);
}
Claims claim;
try {
claim = jwtTokenUtils.getClaimByToken(token, secret);
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
logger.error("解析token失败:{}", errorStackTrace);
return fillAuthResult(false, "解析token失败", null);
}
String appIdIn = (String)claim.get("appId");
String customerId = (String)claim.get("customerId");
Long timestamp = (Long)claim.get("ts");
//校验时间戳,允许5分钟误差
if (StringUtils.isAnyBlank(appIdIn, customerId) || timestamp == null) {
logger.error("access token不完整。{},{},{}", appIdIn, customerId, timestamp);
return fillAuthResult(false, "access token不完整。", null);
}
// TODO
// if (!validTimeStamp(timestamp)) {
// logger.error("服务器存在时差过大,请求被拒绝", appId, appIdIn);
// return fillAuthResult(false, "服务器存在时差过大,请求被拒绝", null);
// }
if (!appId.equals(appIdIn)) {
logger.error("AppId不对应,token外部的:{}, token内部解析出来的:{}", appId, appIdIn);
return fillAuthResult(false, "Header中的AppId不匹配", null);
}
return fillAuthResult(true, "解析成功", customerId);
}
private boolean validTimeStamp(Long timestamp) {
long now = System.currentTimeMillis();
// System.out.println(new Date(timestamp));
if (Math.abs(now - timestamp) > diffMillins) {
return false;
}
return true;
}
/**
* 通过APP ID查询对应的秘钥
* @param appId
* @return
*/
public String getTokenByAppId(String appId) {
String secret = (String)redisUtils.get(RedisKeys.getExternalAppSecretKey(appId));
if (StringUtils.isBlank(secret)) {
ExternalAppSecretEntity secretEntity = externalAppSecretDao.getSecretsByAppId(appId);
if (secretEntity == null) {
return null;
}
secret = secretEntity.getSecret();
redisUtils.set(RedisKeys.getExternalAppSecretKey(appId), secret);
}
return secret;
}
public ExternalAppAuthResultDTO fillAuthResult(Boolean result, String message, String customerId) {
ExternalAppAuthResultDTO authResult = new ExternalAppAuthResultDTO();
authResult.setSuccess(result);
authResult.setMessage(message);
authResult.setCustomerId(customerId);
return authResult;
}
}

31
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppSecretServiceImpl.java

@ -0,0 +1,31 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.epmet.service.ExternalAppSecretService;
import org.springframework.stereotype.Service;
/**
* 外部应用秘钥列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Service
public class ExternalAppSecretServiceImpl implements ExternalAppSecretService {
}

133
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java

@ -0,0 +1,133 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dao.ExternalAppDao;
import com.epmet.dao.ExternalAppSecretDao;
import com.epmet.dao.ExternalCustomerDao;
import com.epmet.dto.result.ExternalAppResultDTO;
import com.epmet.entity.ExternalAppEntity;
import com.epmet.entity.ExternalAppSecretEntity;
import com.epmet.service.ExternalAppService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
/**
* 外部应用列表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-18
*/
@Service
public class ExternalAppServiceImpl implements ExternalAppService {
@Autowired
private ExternalAppDao externalAppDao;
@Autowired
private ExternalAppSecretDao externalAppSecretDao;
@Autowired
private ExternalCustomerDao externalCustomerDao;
@Transactional
@Override
public ExternalAppResultDTO add(String appName, String customerId) {
Integer count = externalAppDao.countByAppNameAndCustomerId(appName, customerId);
if (count > 0) {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_EXISTS.getCode(),
EpmetErrorCode.OPER_EXTERNAL_APP_EXISTS.getMsg());
}
if (externalCustomerDao.selectById(customerId) == null) {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getCode(),
EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getMsg());
}
// 应用表插入
ExternalAppEntity appEntity = new ExternalAppEntity();
appEntity.setAppName(appName);
appEntity.setCustomerId(customerId);
externalAppDao.insert(appEntity);
// 秘钥表插入
ExternalAppSecretEntity secretEntity = new ExternalAppSecretEntity();
secretEntity.setAppId(appEntity.getId());
secretEntity.setSecret(genSecret());
externalAppSecretDao.insert(secretEntity);
ExternalAppResultDTO dto = new ExternalAppResultDTO();
dto.setAppName(appName);
dto.setCustomerId(customerId);
dto.setAppId(appEntity.getId());
return dto;
}
/**
* 生成秘钥
* @return
*/
private String genSecret() {
String part1 = UUID.randomUUID().toString();
String part2 = UUID.randomUUID().toString();
return part1.concat(part2).replace("-", "");
}
@Override
public ExternalAppResultDTO updateById(String appId, String appName, String customerId) {
ExternalAppEntity exists = externalAppDao.selectById(appId);
if (exists == null) {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getCode(),
EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getMsg());
}
ExternalAppResultDTO byName = externalAppDao.getByNameAndCustomerId(appName, customerId);
if (byName != null && !byName.getAppId().equals(appId)) {
// 说明改了之后的名字跟当前客户内的其他应用重复
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_EXISTS.getCode(), "应用名称重复");
}
exists.setAppName(appName);
exists.setCustomerId(customerId);
externalAppDao.updateById(exists);
ExternalAppResultDTO resultDTO = new ExternalAppResultDTO();
resultDTO.setAppId(appId);
resultDTO.setCustomerId(customerId);
resultDTO.setAppName(appName);
return resultDTO;
}
@Override
public PageData<ExternalAppResultDTO> listPage(Integer pageNo, Integer pageSize, String customerId) {
PageHelper.startPage(pageNo, pageSize);
List<ExternalAppResultDTO> list = externalAppDao.list(customerId);
PageInfo<ExternalAppResultDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());
}
}

64
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalCustomerServiceImpl.java

@ -0,0 +1,64 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dao.ExternalCustomerDao;
import com.epmet.dto.result.ExternalCustomerResultDTO;
import com.epmet.entity.ExternalCustomerEntity;
import com.epmet.service.ExternalCustomerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ExternalCustomerServiceImpl implements ExternalCustomerService {
@Autowired
private ExternalCustomerDao externalCustomerDao;
@Override
public PageData<ExternalCustomerResultDTO> listPage(Integer pageNo, Integer pageSize) {
PageHelper.startPage(pageNo, pageSize);
List<ExternalCustomerResultDTO> customers = externalCustomerDao.listBaseInfo();
long total = new PageInfo<>(customers).getTotal();
PageData<ExternalCustomerResultDTO> pageData = new PageData<>(customers, (int) total);
return pageData;
}
@Override
public ExternalCustomerResultDTO add(String customerName) {
Integer exitsCustomerCount = externalCustomerDao.countByCustomerName(customerName);
if (exitsCustomerCount > 0) {
throw new RenException(EpmetErrorCode.OPER_CUSTOMER_EXISTS.getCode(), "客户已存在");
}
ExternalCustomerEntity entity = new ExternalCustomerEntity();
entity.setCustomerName(customerName);
externalCustomerDao.insert(entity);
ExternalCustomerResultDTO resultDTO = new ExternalCustomerResultDTO();
resultDTO.setCustomerId(entity.getId());
resultDTO.setCustomerName(customerName);
return resultDTO;
}
@Override
public ExternalCustomerResultDTO update(String customerId, String customerName) {
ExternalCustomerEntity existsCustomer = externalCustomerDao.selectById(customerId);
if (existsCustomer == null) {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getCode(),
EpmetErrorCode.OPER_EXTERNAL_CUSTOMER_NOT_EXISTS.getMsg());
}
existsCustomer.setCustomerName(customerName);
externalCustomerDao.updateById(existsCustomer);
ExternalCustomerResultDTO resultDTO = new ExternalCustomerResultDTO();
resultDTO.setCustomerId(customerId);
resultDTO.setCustomerName(customerName);
return resultDTO;
}
}

93
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java

@ -0,0 +1,93 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.epmet.utils.externalapp;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* Jwt工具类
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Component
public class ExtAppJwtTokenUtils {
private static final Logger logger = LoggerFactory.getLogger(ExtAppJwtTokenUtils.class);
public Claims getClaimByToken(String token, String secret) {
return Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
}
public Claims tryGetClaimByToken(String token, String secret) {
try {
return Jwts.parser()
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
} catch (Exception e) {
logger.debug("validate is token error, token = " + token, e);
return null;
}
}
public String createToken(Map<String, Object> map, String secret) {
return Jwts.builder()
.setHeaderParam("typ", "JWT")
.setClaims(map)
.setIssuedAt(new Date())
// .setExpiration(DateTime.now().plusSeconds(jwtProperties.getExpire()).toDate())
.signWith(SignatureAlgorithm.HS512, secret)
.compact();
}
// /**
// * token是否过期
// *
// * @return true:过期
// */
// public boolean isTokenExpired(Date expiration) {
// return expiration.before(new Date());
// }
public static void main(String[] args) {
genToken();
// getClaim();
}
public static void genToken() {
HashMap<String, Object> claim = new HashMap<>();
claim.put("appId", "227fb75ae4baa820755aaf43bf7f0a69");
claim.put("customerId", "c1");
claim.put("ts", System.currentTimeMillis() - 1000 * 60 * 4);
String abc = new ExtAppJwtTokenUtils().createToken(claim, "4a762660254c57996343f8ee42fbc0a6");
System.out.println(abc);
}
public static void getClaim() {
String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhcHBJZCI6IjEiLCJjdXN0b21lcklkIjoiYzEiLCJpYXQiOjE1OTc3NDI2NTB9.09Vop0Nobg3LENAJoAZaCUKtgAjADAK48BS11ky3YdAp6h-cXYtGeqUxbgvE_4F6239rc7UE2fjxtEvMuWEJuA";
Claims claimByToken = new ExtAppJwtTokenUtils().getClaimByToken(token, "4a762660254c57996343f8ee42fbc0a6");
System.out.println(claimByToken);
}
}

64
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ExternalAppDao">
<resultMap type="com.epmet.entity.ExternalAppEntity" id="externalAppMap">
<result property="id" column="ID"/>
<result property="appName" column="APP_NAME"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- appName和客户ID查询-->
<select id="countByAppNameAndCustomerId" resultType="java.lang.Integer">
SELECT
count(0)
FROM
external_app
WHERE
APP_NAME = #{appName}
AND CUSTOMER_ID = #{customerId}
AND DEL_FLAG = 0
</select>
<select id="list" resultType="com.epmet.dto.result.ExternalAppResultDTO">
SELECT
ea.ID appId,
ea.APP_NAME,
ea.CUSTOMER_ID,
ec.CUSTOMER_NAME ,
eas.SECRET
FROM
external_app ea
INNER JOIN external_customer ec ON ( ea.CUSTOMER_ID = ec.ID )
LEFT JOIN external_app_secret eas ON (ea.ID = eas.APP_ID)
<where>
ea.DEL_FLAG = 0
<if test="customerId != null and customerId != ''">
AND ea.CUSTOMER_ID = #{customerId}
</if>
</where>
</select>
<select id="getByNameAndCustomerId" resultType="com.epmet.dto.result.ExternalAppResultDTO">
SELECT
ID AS appId,
APP_NAME ,
CUSTOMER_ID
FROM
external_app
WHERE
APP_NAME = #{appName}
AND
CUSTOMER_ID = #{customerId}
AND DEL_FLAG = 0
</select>
</mapper>

37
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ExternalAppSecretDao">
<resultMap type="com.epmet.entity.ExternalAppSecretEntity" id="externalAppSecretMap">
<result property="id" column="ID"/>
<result property="appId" column="APP_ID"/>
<result property="secret" column="SECRET"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getSecretsByAppId" resultType="com.epmet.entity.ExternalAppSecretEntity">
SELECT
ID,
APP_ID,
SECRET,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
FROM
external_app_secret
WHERE
APP_ID = #{appId}
AND DEL_FLAG = 0
</select>
</mapper>

45
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalCustomerDao.xml

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ExternalCustomerDao">
<resultMap type="com.epmet.entity.ExternalCustomerEntity" id="externalCustomerMap">
<result property="id" column="ID"/>
<result property="customerName" column="CUSTOMER_NAME"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<!-- 列出客户基本信息-->
<select id="listBaseInfo" resultType="com.epmet.dto.result.ExternalCustomerResultDTO">
SELECT
id customerId,
CUSTOMER_NAME
FROM
external_customer
WHERE
DEL_FLAG = 0
</select>
<select id="getByCustomerName" resultType="com.epmet.dto.result.ExternalCustomerResultDTO">
SELECT
ID, CUSTOMER_NAME
from
external_customer
WHERE CUSTOMER_NAME = #{customerName}
</select>
<select id="countByCustomerName" resultType="int">
SELECT
count(1)
from
external_customer
WHERE CUSTOMER_NAME = #{customerName}
</select>
</mapper>

41
epmet-module/epmet-ext/epmet-ext-client/pom.xml

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>epmet-ext</artifactId>
<groupId>com.epmet</groupId>
<version>2.0.0</version>
</parent>
<artifactId>epmet-ext-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>3.6.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>

25
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/StaffSinAgencyFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 9:33 上午
*/
@Data
public class StaffSinAgencyFormDTO implements Serializable {
private static final long serialVersionUID = 1827402498483127629L;
//后端自己看
public interface StaffSinAgency{}
/**
* 机关Id
*/
@NotBlank(message = "机关Id不能为空",groups = {StaffSinAgency.class})
private String agencyId;
}

25
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/StaffSinDeptFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 9:33 上午
*/
@Data
public class StaffSinDeptFormDTO implements Serializable {
private static final long serialVersionUID = 1827404498483127629L;
//后端自己看
public interface StaffSinDept{}
/**
* 部门Id
*/
@NotBlank(message = "部门Id不能为空",groups = {StaffSinDept.class})
private String departmentId;
}

26
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/form/StaffSinGridFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 9:33 上午
*/
@Data
public class StaffSinGridFormDTO implements Serializable {
private static final long serialVersionUID = 1827404498483127629L;
//后端自己看
public interface StaffSinGrid{}
/**
* 网格Id
*/
@NotBlank(message = "网格Id不能为空",groups = {StaffSinGrid.class})
private String gridId;
}

32
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/RoleResultDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 9:30 上午
*/
@Data
public class RoleResultDTO implements Serializable {
private static final long serialVersionUID = -4321366067217459L;
/**
* 角色key
*/
private String roleKey;
/**
* 角色名称
*/
private String roleName;
/**
* 用户id
*/
@JsonIgnore
private String userId;
}

42
epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/StaffSinDeptResultDTO.java

@ -0,0 +1,42 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/8/13 9:25 上午
*/
@Data
public class StaffSinDeptResultDTO implements Serializable {
private static final long serialVersionUID = -3440415466710443002L;
/**
* 工作人员Id
*/
private String staffId;
/**
* 工作人员名称
*/
private String staffName;
/**
* 头像
*/
private String headPhoto;
/**
* 性别1男2女0未知
*/
private Integer gender;
/**
* 角色列表
*/
private List<RoleResultDTO> roleList;
}

11
epmet-module/epmet-ext/epmet-ext-server/Dockerfile

@ -0,0 +1,11 @@
FROM java:8
RUN export LANG="zh_CN.UTF-8"
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' > /etc/timezone
COPY ./target/*.jar ./app.jar
EXPOSE 8113
ENTRYPOINT ["sh", "-c", "$RUN_INSTRUCT"]

17
epmet-module/epmet-ext/epmet-ext-server/deploy/docker-compose-dev.yml

@ -0,0 +1,17 @@
version: "3.7"
services:
epmet-ext-server:
container_name: epmet-ext-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-ext-server:0.0.4
ports:
- "8113:8113"
network_mode: host # 使用现有网络
volumes:
- "/opt/epmet-cloud-logs/dev:/logs"
environment:
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./app.jar"
deploy:
resources:
limits:
cpus: '0.1'
memory: 250M

17
epmet-module/epmet-ext/epmet-ext-server/deploy/docker-compose-prod.yml

@ -0,0 +1,17 @@
version: "3.7"
services:
epmet-ext-server:
container_name: epmet-ext-server-prod
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-ext-server:0.0.1
ports:
- "8113:8113"
network_mode: host # 使用现有网络
volumes:
- "/opt/epmet-cloud-logs/prod:/logs"
environment:
RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./app.jar"
deploy:
resources:
limits:
cpus: '0.1'
memory: 600M

17
epmet-module/epmet-ext/epmet-ext-server/deploy/docker-compose-test.yml

@ -0,0 +1,17 @@
version: "3.7"
services:
epmet-ext-server:
container_name: epmet-ext-server-test
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-ext-server:0.0.1
ports:
- "8113:8113"
network_mode: host # 使用现有网络
volumes:
- "/opt/epmet-cloud-logs/test:/logs"
environment:
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./app.jar"
deploy:
resources:
limits:
cpus: '0.1'
memory: 250M

272
epmet-module/epmet-ext/epmet-ext-server/pom.xml

@ -0,0 +1,272 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.0.4</version>
<parent>
<groupId>com.epmet</groupId>
<artifactId>epmet-ext</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>epmet-ext-server</artifactId>
<packaging>jar</packaging>
<properties>
<aliyun.core.version>3.2.2</aliyun.core.version>
<aliyun.dysmsapi.version>1.1.0</aliyun.dysmsapi.version>
<qcloud.qcloudsms.version>1.0.5</qcloud.qcloudsms.version>
<freemarker.version>2.3.28</freemarker.version>
</properties>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-ext-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-extapp-auth</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-tools</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>gov-org-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-mybatis</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>${aliyun.core.version}</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>${aliyun.dysmsapi.version}</version>
</dependency>
<dependency>
<groupId>com.github.qcloudsms</groupId>
<artifactId>qcloudsms</artifactId>
<version>${qcloud.qcloudsms.version}</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<!-- 替换Feign原生httpclient -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>10.3.0</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<!--<version>5.1.1</version>-->
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-common</artifactId>
<version>3.6.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.1.12.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<server.port>8113</server.port>
<spring.profiles.active>dev</spring.profiles.active>
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_third?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet_third_user</spring.datasource.druid.username>
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.130</spring.redis.host>
<spring.redis.port>6379</spring.redis.port>
<spring.redis.password>123456</spring.redis.password>
<!-- nacos -->
<nacos.register-enabled>true</nacos.register-enabled>
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr>
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace>
<nacos.config.group></nacos.config.group>
<nacos.config-enabled>false</nacos.config-enabled>
<nacos.ip/>
<spring.flyway.enabled>false</spring.flyway.enabled>
</properties>
</profile>
<profile>
<id>test</id>
<!--<activation>
<activeByDefault>true</activeByDefault>
</activation>-->
<properties>
<server.port>8113</server.port>
<spring.profiles.active>test</spring.profiles.active>
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_third?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet</spring.datasource.druid.username>
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host>
<spring.redis.port>6379</spring.redis.port>
<spring.redis.password>EpmEtrEdIs!q@w</spring.redis.password>
<!-- nacos -->
<nacos.register-enabled>true</nacos.register-enabled>
<nacos.server-addr>192.168.10.150:8848</nacos.server-addr>
<nacos.discovery.namespace>67e3c350-533e-4d7c-9f8f-faf1b4aa82ae</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace>
<nacos.config.group></nacos.config.group>
<nacos.config-enabled>false</nacos.config-enabled>
<nacos.ip/>
<spring.flyway.enabled>true</spring.flyway.enabled>
</properties>
</profile>
<profile>
<id>prod</id>
<!--<activation>
<activeByDefault>true</activeByDefault>
</activation>-->
<properties>
<server.port>8113</server.port>
<spring.profiles.active>prod</spring.profiles.active>
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://rm-m5e3vzs2637224wj9.mysql.rds.aliyuncs.com:3306/epmet_third?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>epmet_third_user</spring.datasource.druid.username>
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com</spring.redis.host>
<spring.redis.port>6379</spring.redis.port>
<spring.redis.password>EpmEtclOUdrEdIs!Q2w</spring.redis.password>
<!-- nacos -->
<nacos.register-enabled>true</nacos.register-enabled>
<nacos.server-addr>192.168.11.180:8848</nacos.server-addr>
<nacos.discovery.namespace>bd205d23-e696-47be-b995-916313f86e99</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace>
<nacos.config.group></nacos.config.group>
<nacos.config-enabled>false</nacos.config-enabled>
<nacos.ip/>
<spring.flyway.enabled>true</spring.flyway.enabled>
</properties>
</profile>
</profiles>
</project>

17
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/EpmetExtApplication.java

@ -0,0 +1,17 @@
package com.epmet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class EpmetExtApplication {
public static void main(String[] args) {
SpringApplication.run(EpmetExtApplication.class, args);
}
}

40
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/aspect/RequestLogAspect.java

@ -0,0 +1,40 @@
package com.epmet.aspect;
import com.epmet.commons.tools.aspect.BaseRequestLogAspect;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* 日志/异常处理切面实现调用父类方法完成日志记录和异常处理
*/
@Aspect
@Component
@Order(0)
public class RequestLogAspect extends BaseRequestLogAspect {
@Override
@Around(value = "execution(* com.epmet.controller.*Controller*.*(..)) ")
public Object proceed(ProceedingJoinPoint point) throws Throwable {
return super.proceed(point, getRequest());
}
/**
* 获取Request对象
*
* @return
*/
private HttpServletRequest getRequest() {
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
return sra.getRequest();
}
}

26
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/config/ModuleConfigImpl.java

@ -0,0 +1,26 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* https://www.renren.io
*
* 版权所有侵权必究
*/
package com.epmet.config;
import com.epmet.commons.tools.config.ModuleConfig;
import org.springframework.stereotype.Service;
/**
* 模块配置信息
*
* @author Mark sunlightcs@gmail.com
* @since 1.0.0
*/
@Service
public class ModuleConfigImpl implements ModuleConfig {
@Override
public String getName() {
return "epmetext";
}
}

17
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -0,0 +1,17 @@
package com.epmet.constant;
/**
* @Description
* @author zxc
*/
public interface ModuleConstant {
String ERROR_GOV_ORG_GRID = "调用gov_org服务查询【网格】下的所有工作人员失败";
String ERROR_GOV_ORG_DEPARTMENT = "调用gov_org服务查询【部门】下的所有工作人员失败";
String ERROR_GOV_ORG_AGENCY = "调用gov_org服务查询【机关】下的所有工作人员失败";
String ERROR_EPMET_USER = "调用epmet_user服务查询网格下的所有工作人员失败";
}

105
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java

@ -0,0 +1,105 @@
package com.epmet.controller;
import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.OpenUpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/8/13 9:16 上午
*/
@RestController
@RequestMapping("staff")
public class OpenUpController {
@Autowired
private OpenUpService openUpService;
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
/**
* @Description 网格工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/13 9:42 上午
*/
@ExternalAppRequestAuth
@PostMapping("staffsingrid")
public Result<List<StaffSinGridResultDTO>> staffSinGrid(@RequestBody StaffSinGridFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, StaffSinGridFormDTO.StaffSinGrid.class);
return new Result<List<StaffSinGridResultDTO>>().ok(openUpService.staffSinGrid(formDTO));
}
/**
* @Description 部门工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/13 9:51 上午
*/
@ExternalAppRequestAuth
@PostMapping("staffsindept")
public Result<List<StaffSinDeptResultDTO>> staffSinDept(@RequestBody StaffSinDeptFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, StaffSinDeptFormDTO.StaffSinDept.class);
return new Result<List<StaffSinDeptResultDTO>>().ok(openUpService.staffSinDept(formDTO));
}
/**
* @Description 机关工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/17 9:59 上午
*/
@ExternalAppRequestAuth
@PostMapping("staffsinagency")
public Result<List<StaffSinAgencyResultDTO>> staffSinAgency(@RequestBody StaffSinAgencyFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, StaffSinAgencyFormDTO.StaffSinAgency.class);
return new Result<List<StaffSinAgencyResultDTO>>().ok(openUpService.staffSinAgency(formDTO));
}
/**
* @Description 查找工作人员的信息
* @param
* @return
* @author wangc
* @date 2020.08.17 10:30
**/
@ExternalAppRequestAuth
@PostMapping("staffinfo")
public Result<ExtStaffInfoResultDTO> staffInfo(@LoginUser TokenDto token){
CommonStaffIdFormDTO commonStaffIdFormDTO = new CommonStaffIdFormDTO();
commonStaffIdFormDTO.setStaffId(token.getUserId());
ValidatorUtils.validateEntity(commonStaffIdFormDTO, CommonStaffIdFormDTO.StaffIdGroup.class);
return epmetUserOpenFeignClient.extStaffInfo(commonStaffIdFormDTO);
}
/**
* @Description 根据staffId查询当前这个用户的数据权限
* @param
* @return
* @author wangc
* @date 2020.08.17 17:30
**/
@ExternalAppRequestAuth
@PostMapping("permission")
Result<ExtStaffPermissionResultDTO> staffPermissionExt(@RequestBody CommonStaffIdFormDTO commonStaffIdFormDTO){
ValidatorUtils.validateEntity(commonStaffIdFormDTO, CommonStaffIdFormDTO.StaffIdGroup.class);
return govOrgOpenFeignClient.staffPermissionExt(commonStaffIdFormDTO.getStaffId());
}
}

44
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpUserController.java

@ -0,0 +1,44 @@
package com.epmet.controller;
import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CommonUserIdFormDTO;
import com.epmet.dto.result.ExtUserInfoResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Description
* @ClassName OpenUpUserController
* @Auth wangc
* @Date 2020-08-21 17:56
*/
@RestController
@RequestMapping("user")
public class OpenUpUserController {
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
/**
* @Description 查找当前用户的信息
* @param
* @return
* @author wangc
* @date 2020.08.17 10:30
**/
@ExternalAppRequestAuth
@PostMapping("userinfo")
Result<ExtUserInfoResultDTO> userInfo(@LoginUser TokenDto token){
CommonUserIdFormDTO userParam = new CommonUserIdFormDTO();
userParam.setUserId(token.getUserId());
ValidatorUtils.validateEntity(userParam, CommonUserIdFormDTO.CommonUserIdGroup.class);
return epmetUserOpenFeignClient.extUserInfo(userParam);
}
}

41
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java

@ -0,0 +1,41 @@
package com.epmet.service;
import com.epmet.dto.form.StaffSinAgencyFormDTO;
import com.epmet.dto.form.StaffSinDeptFormDTO;
import com.epmet.dto.form.StaffSinGridFormDTO;
import com.epmet.dto.result.StaffSinAgencyResultDTO;
import com.epmet.dto.result.StaffSinDeptResultDTO;
import com.epmet.dto.result.StaffSinGridResultDTO;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/8/13 9:17 上午
*/
public interface OpenUpService {
/**
* @Description 网格工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/13 9:42 上午
*/
List<StaffSinGridResultDTO> staffSinGrid(StaffSinGridFormDTO formDTO);
/**
* @Description 部门工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/13 9:51 上午
*/
List<StaffSinDeptResultDTO> staffSinDept(StaffSinDeptFormDTO formDTO);
/**
* @Description 机关工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/17 9:59 上午
*/
List<StaffSinAgencyResultDTO> staffSinAgency(StaffSinAgencyFormDTO formDTO);
}

126
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java

@ -0,0 +1,126 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ModuleConstant;
import com.epmet.dto.form.*;
import com.epmet.dto.result.StaffSinAgencyResultDTO;
import com.epmet.dto.result.StaffSinDeptResultDTO;
import com.epmet.dto.result.StaffSinGridResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.OpenUpService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @Author zxc
* @DateTime 2020/8/13 9:18 上午
*/
@Service
public class OpenUpServiceImpl implements OpenUpService {
@Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
/**
* @Description 网格工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/13 9:42 上午
*/
@Override
public List<StaffSinGridResultDTO> staffSinGrid(StaffSinGridFormDTO formDTO) {
CommonGridIdFormDTO commonGridId = new CommonGridIdFormDTO();
commonGridId.setGridId(formDTO.getGridId());
commonGridId.setUserId(UUID.randomUUID().toString().replace(StrConstant.HYPHEN, ""));
Result<List<String>> gridStaffs = govOrgOpenFeignClient.getGridStaffs(commonGridId);
if (!gridStaffs.success()){
throw new RenException(ModuleConstant.ERROR_GOV_ORG_GRID);
}
if (gridStaffs.getData().size() == NumConstant.ZERO){
return new ArrayList<>();
}
return this.getStaffList(gridStaffs.getData());
}
/**
* @Description 部门工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/13 9:51 上午
*/
@Override
public List<StaffSinDeptResultDTO> staffSinDept(StaffSinDeptFormDTO formDTO) {
DepartmentIdFormDTO departmentId = new DepartmentIdFormDTO();
departmentId.setDepartmentId(formDTO.getDepartmentId());
Result<List<String>> departmentStaffs = govOrgOpenFeignClient.getDepartmentStaffs(departmentId);
if (!departmentStaffs.success()){
throw new RenException(ModuleConstant.ERROR_GOV_ORG_DEPARTMENT);
}
if (departmentStaffs.getData().size() == NumConstant.ZERO){
return new ArrayList<>();
}
List<StaffSinGridResultDTO> data = this.getStaffList(departmentStaffs.getData());
List<StaffSinDeptResultDTO> result = new ArrayList<>();
data.forEach(staff -> {
StaffSinDeptResultDTO dept = new StaffSinDeptResultDTO();
BeanUtils.copyProperties(staff,dept);
result.add(dept);
});
return result;
}
/**
* @Description 机关工作人员 被禁用的未激活的不显示
* @param formDTO
* @author zxc
* @date 2020/8/17 9:59 上午
*/
@Override
public List<StaffSinAgencyResultDTO> staffSinAgency(StaffSinAgencyFormDTO formDTO) {
AgencyIdFormDTO agencyId = new AgencyIdFormDTO();
agencyId.setAgencyId(formDTO.getAgencyId());
Result<List<String>> agencyStaffs = govOrgOpenFeignClient.getAgencyStaffs(agencyId);
if (!agencyStaffs.success()){
throw new RenException(ModuleConstant.ERROR_GOV_ORG_AGENCY);
}
if (agencyStaffs.getData().size() == NumConstant.ZERO){
return new ArrayList<>();
}
List<StaffSinGridResultDTO> staffList = this.getStaffList(agencyStaffs.getData());
List<StaffSinAgencyResultDTO> result = new ArrayList<>();
staffList.forEach(staff -> {
StaffSinAgencyResultDTO agency = new StaffSinAgencyResultDTO();
BeanUtils.copyProperties(staff,agency);
result.add(agency);
});
return result;
}
/**
* @Description 获取工作人员信息
* @param userIds
* @author zxc
* @date 2020/8/17 1:30 下午
*/
public List<StaffSinGridResultDTO> getStaffList(List<String> userIds){
UserIdsFormDTO userIdsForm = new UserIdsFormDTO();
userIdsForm.setUserIds(userIds);
Result<List<StaffSinGridResultDTO>> staffInfoList = epmetUserOpenFeignClient.getStaffInfoList(userIdsForm);
if (!staffInfoList.success()){
throw new RenException(ModuleConstant.ERROR_EPMET_USER);
}
return staffInfoList.getData();
}
}

100
epmet-module/epmet-ext/epmet-ext-server/src/main/resources/bootstrap.yml

@ -0,0 +1,100 @@
server:
port: @server.port@
servlet:
context-path: /epmet/ext
spring:
main:
allow-bean-definition-overriding: true
application:
name: epmet-ext-server
# dev|test|prod
profiles:
active: dev
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
redis:
database: @spring.redis.index@
host: @spring.redis.host@
port: @spring.redis.port@
password: @spring.redis.password@
timeout: 30s
datasource:
druid:
#MySQL
driver-class-name: com.mysql.cj.jdbc.Driver
url: @spring.datasource.druid.url@
username: @spring.datasource.druid.username@
password: @spring.datasource.druid.password@
cloud:
nacos:
discovery:
server-addr: @nacos.server-addr@
namespace: @nacos.discovery.namespace@
register-enabled: @nacos.register-enabled@
ip: @nacos.ip@
config:
enabled: @nacos.config-enabled@
server-addr: @nacos.server-addr@
namespace: @nacos.config.namespace@
group: @nacos.config.group@
file-extension: yaml
flyway:
enabled: @spring.flyway.enabled@
locations: classpath:db/migration
url: @spring.datasource.druid.url@
user: @spring.datasource.druid.username@
password: @spring.datasource.druid.password@
baseline-on-migrate: true
baseline-version: 0
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: ALWAYS
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
typeAliasesPackage: com.epmet.entity
global-config:
db-config:
id-type: ID_WORKER
field-strategy: NOT_NULL
column-underline: true
banner: false
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
feign:
hystrix:
enabled: true
client:
config:
default:
loggerLevel: BASIC
httpclient:
enabled: true
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 60000
ribbon:
ReadTimeout: 300000
ConnectTimeout: 300000
pagehelper:
helper-dialect: mysql
reasonable: false

1
epmet-module/epmet-ext/epmet-ext-server/src/main/resources/db/migration/V0.0.1__demo.sql

@ -0,0 +1 @@
select 0;

164
epmet-module/epmet-ext/epmet-ext-server/src/main/resources/logback-spring.xml

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<property name="log.path" value="logs/ext"/>
<springProperty scope="context" name="appname" source="spring.application.name"/>
<!-- 日志上下文名称 -->
<contextName>${appname}</contextName>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--1. 输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--2. 输出到文档-->
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${log.path}/debug.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文档保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文档只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 2.2 level为 INFO 日志,时间滚动输出 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${log.path}/info.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文档保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文档只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 2.3 level为 WARN 日志,时间滚动输出 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${log.path}/warn.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文档保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文档只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 2.4 level为 ERROR 日志,时间滚动输出 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文档的路径及文档名 -->
<file>${log.path}/error.log</file>
<!--日志文档输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文档保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文档只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 开发、测试环境 -->
<springProfile name="dev,test">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/>
<logger name="com.epmet.dao" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="DEBUG_FILE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
</springProfile>
<!-- 生产环境 -->
<springProfile name="prod">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="DEBUG_FILE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
</springProfile>
</configuration>

21
epmet-module/epmet-ext/pom.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>epmet-module</artifactId>
<groupId>com.epmet</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>epmet-ext</artifactId>
<packaging>pom</packaging>
<modules>
<module>epmet-ext-client</module>
<module>epmet-ext-server</module>
</modules>
</project>

29
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerAccessTokenInfoFormDTO.java

@ -0,0 +1,29 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/24 10:03 上午
*/
@Data
public class CustomerAccessTokenInfoFormDTO implements Serializable {
private static final long serialVersionUID = 6514918025012507710L;
public interface CustomerAccessTokenInfo{}
/**
* 客户ID
*/
@NotBlank(message = "客户ID不能为空",groups = {CustomerAccessTokenInfo.class})
private String customerId;
/**
* 客户端类型
*/
private String clientType;
}

4
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ModifyDomainFormDTO.java

@ -22,6 +22,10 @@ public class ModifyDomainFormDTO implements Serializable {
* 客户端类型
*/
private String clientType;
/**
* 操作类型:add 添加,delete 删除,set 覆盖
*/
private String action;
/**
* request 合法域名
*/

4
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/WebviewDomainFormDTO.java

@ -21,6 +21,10 @@ public class WebviewDomainFormDTO implements Serializable {
* 客户端类型
*/
private String clientType;
/**
* 操作类型:add 添加,delete 删除,set 覆盖
*/
private String action;
/**
* 业务域名
*/

56
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerAccessTokenInfoResultDTO.java

@ -0,0 +1,56 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/24 10:08 上午
*/
@Data
public class CustomerAccessTokenInfoResultDTO implements Serializable {
private static final long serialVersionUID = 7008455455787166150L;
/**
* 客户名称
*/
private String customerName;
/**
* 环境类型
*/
private String source;
/**
* 客户ID
*/
private String customerId;
/**
* 授权方AppId
*/
private String authAppId;
/**
* 授权方的 accessToken
*/
private String authorizerAccessToken;
/**
* 授权方的 refreshToken
*/
private String authorizerRefreshToken;
/**
* accessToken过期事件
*/
private String expiresInTime;
/**
* 客户端类型
*/
private String clientType;
}

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

@ -2,7 +2,7 @@ version: "3.7"
services:
epmet-third-server:
container_name: epmet-third-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.132
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-third-server:0.0.134
ports:
- "8110:8110"
network_mode: host # 使用现有网络

2
epmet-module/epmet-third/epmet-third-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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>0.0.132</version>
<version>0.0.134</version>
<parent>
<groupId>com.epmet</groupId>

17
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/AppLetAuthorizationController.java

@ -4,14 +4,18 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.CustomerAccessTokenInfoFormDTO;
import com.epmet.dto.form.GoToAuthFormDTO;
import com.epmet.dto.form.OpenAppIdFormDTO;
import com.epmet.dto.form.RemoveBindFormDTO;
import com.epmet.dto.result.CustomerAccessTokenInfoResultDTO;
import com.epmet.dto.result.GoToAuthResultDTO;
import com.epmet.service.AppLetAuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Author zxc
* @CreateTime 2020/7/10 15:48
@ -31,6 +35,7 @@ public class AppLetAuthorizationController {
@PostMapping("gotoauth")
public Result<GoToAuthResultDTO> goToAuth(@LoginUser TokenDto tokenDto, @RequestBody GoToAuthFormDTO formDTO, @RequestHeader("source")String source){
ValidatorUtils.validateEntity(formDTO);
GoToAuthResultDTO goToAuthResultDTO = appLetAuthorizationService.goToAuth(tokenDto,formDTO,source);
return new Result().ok(goToAuthResultDTO);
}
@ -59,4 +64,16 @@ public class AppLetAuthorizationController {
return new Result<String>().ok(openAppId);
}
/**
* @Description 查询客户下的小程序基本信息
* @param customerAccessTokenInfoFormDTO
* @author zxc
* @date 2020/8/24 10:26 上午
*/
@PostMapping("getcustomeraccesstokeninfo")
public Result<List<CustomerAccessTokenInfoResultDTO>> getCustomerAccessTokenInfo(@RequestBody CustomerAccessTokenInfoFormDTO customerAccessTokenInfoFormDTO){
ValidatorUtils.validateEntity(customerAccessTokenInfoFormDTO, CustomerAccessTokenInfoFormDTO.CustomerAccessTokenInfo.class);
return new Result<List<CustomerAccessTokenInfoResultDTO>>().ok(appLetAuthorizationService.getCustomerAccessTokenInfo(customerAccessTokenInfoFormDTO));
}
}

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java

@ -21,7 +21,9 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.AuthorizationInfoDTO;
import com.epmet.dto.form.AuthorizationInfoFormDTO;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.CustomerAccessTokenInfoFormDTO;
import com.epmet.dto.result.AuthCodeResultDTO;
import com.epmet.dto.result.CustomerAccessTokenInfoResultDTO;
import com.epmet.dto.result.WillOverDueResultDTO;
import com.epmet.entity.AuthorizationInfoEntity;
import org.apache.ibatis.annotations.Mapper;
@ -99,4 +101,12 @@ public interface AuthorizationInfoDao extends BaseDao<AuthorizationInfoEntity> {
*/
List<AuthorizationInfoDTO> getAuthInfoByCustomerId(@Param("customerId") String customerId);
/**
* @Description 查询客户下的小程序基本信息
* @param customerAccessTokenInfoFormDTO
* @author zxc
* @date 2020/8/24 10:26 上午
*/
List<CustomerAccessTokenInfoResultDTO> getCustomerAccessTokenInfo(CustomerAccessTokenInfoFormDTO customerAccessTokenInfoFormDTO);
}

12
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/AppLetAuthorizationService.java

@ -1,11 +1,15 @@
package com.epmet.service;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.form.CustomerAccessTokenInfoFormDTO;
import com.epmet.dto.form.GoToAuthFormDTO;
import com.epmet.dto.form.OpenAppIdFormDTO;
import com.epmet.dto.form.RemoveBindFormDTO;
import com.epmet.dto.result.CustomerAccessTokenInfoResultDTO;
import com.epmet.dto.result.GoToAuthResultDTO;
import java.util.List;
/**
* @Author zxc
* @CreateTime 2020/7/10 15:52
@ -34,4 +38,12 @@ public interface AppLetAuthorizationService {
*/
String getOpenAppId(OpenAppIdFormDTO formDTO);
/**
* @Description 查询客户下的小程序基本信息
* @param customerAccessTokenInfoFormDTO
* @author zxc
* @date 2020/8/24 10:26 上午
*/
List<CustomerAccessTokenInfoResultDTO> getCustomerAccessTokenInfo(CustomerAccessTokenInfoFormDTO customerAccessTokenInfoFormDTO);
}

17
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/AppLetAuthorizationServiceImpl.java

@ -8,13 +8,16 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant;
import com.epmet.dao.AuthorizationInfoDao;
import com.epmet.dao.BindingAccountDao;
import com.epmet.dao.CustomerMpDao;
import com.epmet.dao.OpenPlatformAccountDao;
import com.epmet.dto.form.CustomerAccessTokenInfoFormDTO;
import com.epmet.dto.form.GoToAuthFormDTO;
import com.epmet.dto.form.OpenAppIdFormDTO;
import com.epmet.dto.form.RemoveBindFormDTO;
import com.epmet.dto.result.AuthorizationInfoResultDTO;
import com.epmet.dto.result.CustomerAccessTokenInfoResultDTO;
import com.epmet.dto.result.GoToAuthResultDTO;
import com.epmet.redis.RedisThird;
import com.epmet.service.AppLetAuthorizationService;
@ -25,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
@ -45,6 +49,8 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic
private RedisThird redisThird;
@Autowired
private BindingAccountDao bindingAccountDao;
@Autowired
private AuthorizationInfoDao authorizationInfoDao;
@Value("${third.platform.appId}")
private String componentAppId;
@ -117,4 +123,15 @@ public class AppLetAuthorizationServiceImpl implements AppLetAuthorizationServic
}
return map.get(ModuleConstant.ERR_MSG).toString();
}
/**
* @Description 查询客户下的小程序基本信息
* @param customerAccessTokenInfoFormDTO
* @author zxc
* @date 2020/8/24 10:26 上午
*/
@Override
public List<CustomerAccessTokenInfoResultDTO> getCustomerAccessTokenInfo(CustomerAccessTokenInfoFormDTO customerAccessTokenInfoFormDTO) {
return authorizationInfoDao.getCustomerAccessTokenInfo(customerAccessTokenInfoFormDTO);
}
}

21
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java

@ -408,20 +408,23 @@ public class CodeServiceImpl implements CodeService {
@Override
public List<ReasonResultDTO> reason(CodeCommonFormDTO formDTO) {
List<ReasonResultDTO> resultList = new ArrayList<>();
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
if (StringUtils.isNotBlank(formDTO.getCodeId())) {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
formDTO.setCustomerId(codeCustomerDTO.getCustomerId());
formDTO.setClientType(codeCustomerDTO.getClientType());
}
//是否授权
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) {
throw new RenException("未授权");
}
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType());
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
if (null == authInfo) {
throw new RenException("未授权");
}
//获取审核结果信息
List<CodeAuditResultDTO> codeAuditResultList = codeAuditResultService.getAuditFailedList(codeCustomerDTO.getCustomerId(),
codeCustomerDTO.getClientType());
List<CodeAuditResultDTO> codeAuditResultList = codeAuditResultService.getAuditFailedList(formDTO.getCustomerId(),
formDTO.getClientType());
codeAuditResultList.forEach(dto -> {
ReasonResultDTO result = new ReasonResultDTO();
result.setReason(dto.getReason());
@ -500,9 +503,9 @@ public class CodeServiceImpl implements CodeService {
public PageData history(CodeCommonFormDTO formDTO) {
PageHelper.startPage(formDTO.getPage(), formDTO.getLimit());
//获取上传代码信息
CodeCustomerDTO code = codeCustomerService.get(formDTO.getCodeId());
// CodeCustomerDTO code = codeCustomerService.get(formDTO.getCodeId());
//获取上传代码信息
List<CodeHistoryResultDTO> list = codeOperationHistoryService.getHistoryList(code.getCustomerId(), code.getClientType());
List<CodeHistoryResultDTO> list = codeOperationHistoryService.getHistoryList(formDTO.getCustomerId(), formDTO.getClientType());
PageInfo<CodeHistoryResultDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());
}

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SettingServiceImpl.java

@ -33,6 +33,7 @@ public class SettingServiceImpl implements SettingService {
throw new RenException("未授权");
}
WxMaModifyDomainReq request = new WxMaModifyDomainReq();
request.setAction(formDTO.getAction());
request.setDownloadDomain(formDTO.getDownloadDomain());
request.setRequestDomain(formDTO.getRequestDomain());
request.setWsRequestDomain(formDTO.getWsRequestDomain());
@ -52,7 +53,7 @@ public class SettingServiceImpl implements SettingService {
throw new RenException("未授权");
}
WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq();
request.setAction("set");
request.setAction(formDTO.getAction());
request.setWebViewDomain(formDTO.getWebViewDomain());
//设置业务域名
WxResult setWebviewDomain = wxMaSettingService.setWebviewDomain(authInfo.getAuthorizerAccessToken(), request);

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java

@ -354,6 +354,8 @@ public enum WxMaErrorMsgEnum {
CODE_85062(85062, "手机号黑名单"),
CODE_85015(85015, "该账号不是小程序账号"),
CODE_85016(85016, "域名数量超过限制"),
CODE_85017(85017, "没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加"),

22
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml

@ -99,4 +99,26 @@
AND EXPIRES_IN_TIME > NOW()
</select>
<!-- 查询客户下的小程序基本信息 -->
<select id="getCustomerAccessTokenInfo" resultType="com.epmet.dto.result.CustomerAccessTokenInfoResultDTO">
SELECT
pc.customer_name AS customerName,
pc.source AS source,
ai.customer_id AS customerId,
ai.authorizer_appid AS authAppId,
ai.authorizer_access_token AS authorizerAccessToken,
ai.authorizer_refresh_token AS authorizerRefreshToken,
ai.expires_in_time AS expiresInTime,
ai.client_type AS clientType
FROM authorization_info ai
LEFT JOIN pa_customer pc ON pc.id = ai.customer_id
WHERE
ai.del_flag = 0
AND pc.del_flag = 0
AND ai.customer_id = #{customerId}
<if test="clientType != null and clientType != '' ">
AND ai.client_type = #{clientType}
</if>
</select>
</mapper>

20
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AgencyIdFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/17 10:37 上午
*/
@Data
public class AgencyIdFormDTO implements Serializable {
private static final long serialVersionUID = -1719033407335647411L;
/**
* 部门Id
*/
private String agencyId;
}

21
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/CustomerIdFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 5:56 下午
*/
@Data
public class CustomerIdFormDTO implements Serializable {
private static final long serialVersionUID = 4512080710854617599L;
public interface Customer{}
@NotBlank(message = "customerId不能为空",groups = {Customer.class})
private String customerId;
}

20
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/DepartmentIdFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 10:37 上午
*/
@Data
public class DepartmentIdFormDTO implements Serializable {
private static final long serialVersionUID = -1718433407335647411L;
/**
* 部门Id
*/
private String departmentId;
}

20
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/GridIdFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/13 10:35 上午
*/
@Data
public class GridIdFormDTO implements Serializable {
private static final long serialVersionUID = -1062540828459359881L;
/**
* 网格Id
*/
private String gridId;
}

31
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/UpdateCustomerParameterFormDTO.java

@ -0,0 +1,31 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 修改客户网格数和有效期-接口入参
* @Author sun
*/
@Data
public class UpdateCustomerParameterFormDTO implements Serializable {
private static final long serialVersionUID = 4512080710854617599L;
/**
* 客户Id
*/
@NotBlank(message = "customerId不能为空",groups = {Customer.class})
private String customerId;
/**
* 有效期
*/
private String validityTime;
/**
* 最大允许创建网格数
*/
private Integer gridNumber;
public interface Customer{}
}

20
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridCountResultDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/8/14 9:27 上午
*/
@Data
public class CustomerGridCountResultDTO implements Serializable {
private static final long serialVersionUID = 386294009143897744L;
/**
* 客户下的网格数量
*/
private Integer gridCount;
}

26
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtDeptResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 部门信息
* @ClassName ExtDeptResultDTO
* @Auth wangc
* @Date 2020-08-17 17:16
*/
@Data
public class ExtDeptResultDTO implements Serializable {
private static final long serialVersionUID = 1792371558965832432L;
/**
* 部门Id
* */
private String deptId;
/**
* 部门名称
* */
private String deptName;
}

26
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtGridResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 网格信息
* @ClassName ExtGridResultDTO
* @Auth wangc
* @Date 2020-08-17 15:28
*/
@Data
public class ExtGridResultDTO implements Serializable {
private static final long serialVersionUID = -4531574240525562587L;
/**
* 网格Id
* */
private String gridId;
/**
* 网格名称
* */
private String gridName;
}

26
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtRoleMapResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @ClassName ExtRoleMapResultDTO
* @Auth wangc
* @Date 2020-08-17 09:19
*/
@Data
public class ExtRoleMapResultDTO implements Serializable {
private static final long serialVersionUID = 4988555173286922503L;
/**
* 角色key
* */
private String roleKey;
/**
* 角色名称
* */
private String roleName;
}

86
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtStaffInfoResultDTO.java

@ -0,0 +1,86 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @ClassName ExtStaffInfoResultDTO
* @Auth wangc
* @Date 2020-08-17 09:14
*/
@Data
public class ExtStaffInfoResultDTO implements Serializable {
private static final long serialVersionUID = 3874334777882476292L;
/**
* 当前用户id
* */
private String userId;
/**
* 工作人员昵称
* */
private String nickname;
/**
* 工作人员头像
* */
private String profile;
/**
*
* */
private String realName;
/**
* 客户Id
* */
private String customerId;
/**
* 客户名称
* */
private String customerName;
/**
* 机关Id
* */
private String agencyId;
/**
* 机关名称
* */
private String agencyName;
/**
* 机关路径Id
* */
private String agencyIdPath;
/**
* 机关路径名称
* */
private String agencyNamePath;
/**
* 网格Id
* */
private String gridId;
/**
* 网格名称
* */
private String gridName;
/**
* 是否管理员标识 1是0否
* */
private String adminFlag;
/**
* 用户角色列表
* */
private List<ExtRoleMapResultDTO> roleList;
}

43
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtStaffPermissionResultDTO.java

@ -0,0 +1,43 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Description 工作人员数据权限
* @ClassName ExtStaffPermissionResultDTO
* @Auth wangc
* @Date 2020-08-17 15:24
*/
@Data
public class ExtStaffPermissionResultDTO implements Serializable {
private static final long serialVersionUID = 2513553862809278219L;
/**
* 直属机关Id
* */
private String agencyId;
/**
* 直属机关名称
* */
private String agencyName;
/**
* 直属机关直属网格列表
* */
private List<ExtGridResultDTO> gridList = new ArrayList<>();
/**
* 直属机关直属部门列表
* */
private List<ExtDeptResultDTO> departmentList = new ArrayList<>();
/**
* 子集机关列表
* */
private List<ExtStaffPermissionResultDTO> subAgencyList = new ArrayList<>();
}

82
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtUserInfoResultDTO.java

@ -0,0 +1,82 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Description
* @ClassName ExtUserInfoResultDTO
* @Auth wangc
* @Date 2020-08-21 17:09
*/
@Data
public class ExtUserInfoResultDTO implements Serializable {
private static final long serialVersionUID = 5888986115026957874L;
/**
* 当前用户id
* */
private String userId = "";
/**
* 工作人员昵称
* */
private String nickname = "";
/**
* 工作人员头像
* */
private String profile = "";
/**
*
* */
private String realName = "";
/**
* 客户Id
* */
private String customerId = "";
/**
* 客户名称
* */
private String customerName = "";
/**
* 机关Id
* */
private String agencyId = "";
/**
* 机关名称
* */
private String agencyName = "";
/**
* 机关路径Id
* */
private String agencyIdPath = "";
/**
* 机关路径名称
* */
private String agencyNamePath = "";
/**
* 网格Id
* */
private String gridId = "";
/**
* 网格名称
* */
private String gridName = "";
/**
* 用户角色列表
* */
private List<ExtRoleMapResultDTO> roleList = new ArrayList<>();
}

73
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java

@ -4,10 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerPartyBranchDTO;
import com.epmet.dto.form.AddAgencyAndStaffFormDTO;
import com.epmet.dto.form.BelongGridNameFormDTO;
import com.epmet.dto.form.ListPartyBranchFormDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.fallback.GovOrgOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
@ -22,7 +19,7 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/6/4 13:37
*/
// @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class, url = "localhost:8092")
//@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class, url = "localhost:8092")
@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgOpenFeignClientFallback.class)
public interface GovOrgOpenFeignClient {
@ -187,4 +184,70 @@ public interface GovOrgOpenFeignClient {
**/
@PostMapping(value = "/gov/org/customeragency/getStaffOrgList",consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO);
/**
* @Description 查询一个网格下的所有工作人员
* @param gridIdFormDTO
* @author zxc
* @date 2020/8/13 10:46 上午
*/
@PostMapping(value = "/gov/org/customerstaffgrid/getgridstaffs")
Result<List<String>> getGridStaffs(@RequestBody CommonGridIdFormDTO gridIdFormDTO);
/**
* @Description 查询部门下工作人员
* @param formDTO
* @author zxc
* @date 2020/8/13 2:46 下午
*/
@PostMapping(value = "/gov/org/customerstaffdepartment/getdepartmentstaffs")
Result<List<String>> getDepartmentStaffs(@RequestBody DepartmentIdFormDTO formDTO);
/**
* @Description 查询客户下的网格数量
* @param customerIdFormDTO
* @author zxc
* @date 2020/8/14 9:31 上午
*/
@PostMapping(value = "/gov/org/customergrid/gridcount")
Result<CustomerGridCountResultDTO> selectGridCount(@RequestBody CustomerIdFormDTO customerIdFormDTO);
/**
* @Description 查询机关下工作人员
* @param formDTO
* @author zxc
* @date 2020/8/17
*/
@PostMapping(value = "/gov/org/customerstaffagency/getagencystaffs")
Result<List<String>> getAgencyStaffs(@RequestBody AgencyIdFormDTO formDTO);
/**
* @Description User模块调用gov-org查询工作人员所在机关的信息以及客户信息
* @param result
* @return
* @author wangc
* @date 2020.08.17 14:11
**/
@PostMapping("/gov/org/customeragency/staffinfoext")
Result<ExtStaffInfoResultDTO> staffInfoExt(@RequestBody ExtStaffInfoResultDTO result);
/**
* @Description 根据staffId查询当前这个用户的数据权限对外接口
* @param staffId
* @return
* @author wangc
* @date 2020.08.17 17:30
**/
@PostMapping("/gov/org/customeragency/permissionext/{staffId}")
Result<ExtStaffPermissionResultDTO> staffPermissionExt(@PathVariable(value = "staffId") String staffId);
/**
* @Description User模块调用gov-org查询用户所在机关的信息以及客户信息
* @param result ExtStaffInfoResultDTO.class
* @return Result<ExtStaffInfoResultDTO>
* @author wangc
* @date 2020.08.17 13:52
**/
@PostMapping("/gov/org/customeragency/userinfoext")
Result<ExtUserInfoResultDTO> userInfoExt(@RequestBody ExtUserInfoResultDTO result);
}

40
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java

@ -5,10 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.CustomerPartyBranchDTO;
import com.epmet.dto.form.AddAgencyAndStaffFormDTO;
import com.epmet.dto.form.BelongGridNameFormDTO;
import com.epmet.dto.form.ListPartyBranchFormDTO;
import com.epmet.dto.form.StaffOrgFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.feign.GovOrgOpenFeignClient;
import org.springframework.stereotype.Component;
@ -114,4 +111,39 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient {
public Result<List<StaffOrgsResultDTO>> getStaffOrgList(StaffOrgFormDTO staffOrgFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getStaffOrgList", staffOrgFormDTO);
}
@Override
public Result<List<String>> getGridStaffs(CommonGridIdFormDTO gridIdFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridStaffs", gridIdFormDTO);
}
@Override
public Result<List<String>> getDepartmentStaffs(DepartmentIdFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getDepartmentStaffs", formDTO);
}
@Override
public Result<CustomerGridCountResultDTO> selectGridCount(CustomerIdFormDTO customerIdFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectGridCount", customerIdFormDTO);
}
@Override
public Result<List<String>> getAgencyStaffs(AgencyIdFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyStaffs", formDTO);
}
@Override
public Result<ExtStaffInfoResultDTO> staffInfoExt(ExtStaffInfoResultDTO result) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "staffInfoExt", result);
}
@Override
public Result<ExtStaffPermissionResultDTO> staffPermissionExt(String staffId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "staffPermissionExt", staffId);
}
@Override
public Result<ExtUserInfoResultDTO> userInfoExt(ExtUserInfoResultDTO result) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "userInfoExt", result);
}
}

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

@ -2,7 +2,7 @@ version: "3.7"
services:
gov-org-server:
container_name: gov-org-server-dev
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.83
image: 192.168.1.130:10080/epmet-cloud-dev/gov-org-server:0.3.86
ports:
- "8092:8092"
network_mode: host # 使用现有网络

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save