parent
							
								
									340598ee66
								
							
						
					
					
						commit
						42c4e4784b
					
				| @ -0,0 +1,188 @@ | ||||
| <?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> | ||||
| 	<groupId>com.gitee.sop</groupId> | ||||
| 	<artifactId>sop-common</artifactId> | ||||
| 	<version>1.0.0-SNAPSHOT</version> | ||||
| 	<packaging>pom</packaging> | ||||
| 
 | ||||
| 	<properties> | ||||
| 		<java.version>1.8</java.version> | ||||
| 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||
| 		<maven.compiler.source>1.8</maven.compiler.source> | ||||
| 		<maven.compiler.target>1.8</maven.compiler.target> | ||||
| 		<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version> | ||||
| 		<spring-boot.version>2.1.2.RELEASE</spring-boot.version> | ||||
| 		<!-- Logging --> | ||||
| 		<logback.version>1.0.13</logback.version> | ||||
| 		<slf4j.version>1.7.5</slf4j.version> | ||||
| 
 | ||||
| 		<!-- Test --> | ||||
| 		<junit.version>4.11</junit.version> | ||||
| 
 | ||||
| 		<fastjson.version>1.2.15</fastjson.version> | ||||
| 		<commons-io.version>2.5</commons-io.version> | ||||
| 		<commons-fileupload.version>1.3.3</commons-fileupload.version> | ||||
| 		<commons-collection.version>3.2.2</commons-collection.version> | ||||
| 		<commons-lang3.version>3.8.1</commons-lang3.version> | ||||
| 		<commons-codec.version>1.11</commons-codec.version> | ||||
| 		<zookeeper.version>3.4.12</zookeeper.version> | ||||
| 	</properties> | ||||
| 
 | ||||
| 	<modules> | ||||
| 		<module>sop-gateway-common</module> | ||||
| 		<module>sop-service-common</module> | ||||
| 	</modules> | ||||
| 
 | ||||
| 	<dependencyManagement> | ||||
| 		<dependencies> | ||||
| 			<!-- 加了这个就不需要加版本号了 --> | ||||
| 			<dependency> | ||||
| 				<groupId>org.springframework.boot</groupId> | ||||
| 				<artifactId>spring-boot-dependencies</artifactId> | ||||
| 				<version>${spring-boot.version}</version> | ||||
| 				<type>pom</type> | ||||
| 				<scope>import</scope> | ||||
| 			</dependency> | ||||
| 			<dependency> | ||||
| 				<groupId>org.springframework.cloud</groupId> | ||||
| 				<artifactId>spring-cloud-dependencies</artifactId> | ||||
| 				<version>${spring-cloud.version}</version> | ||||
| 				<type>pom</type> | ||||
| 				<scope>import</scope> | ||||
| 			</dependency> | ||||
| 		</dependencies> | ||||
| 	</dependencyManagement> | ||||
| 
 | ||||
| 	<dependencies> | ||||
| 		<!-- zookeeper --> | ||||
| 		<dependency> | ||||
| 			<groupId>org.springframework.cloud</groupId> | ||||
| 			<artifactId>spring-cloud-starter-zookeeper-all</artifactId> | ||||
| 			<exclusions> | ||||
| 				<!-- 不使用服务发现 --> | ||||
| 				<exclusion> | ||||
| 					<groupId>org.springframework.cloud</groupId> | ||||
| 					<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId> | ||||
| 				</exclusion> | ||||
| 				<!-- 这里为什么要排除,详见:http://curator.apache.org/zk-compatibility.html --> | ||||
| 				<exclusion> | ||||
| 					<groupId>org.apache.zookeeper</groupId> | ||||
| 					<artifactId>zookeeper</artifactId> | ||||
| 				</exclusion> | ||||
| 			</exclusions> | ||||
| 		</dependency> | ||||
| 		<dependency> | ||||
| 			<groupId>org.apache.zookeeper</groupId> | ||||
| 			<artifactId>zookeeper</artifactId> | ||||
| 			<version>${zookeeper.version}</version> | ||||
| 			<exclusions> | ||||
| 				<exclusion> | ||||
| 					<groupId>org.slf4j</groupId> | ||||
| 					<artifactId>slf4j-log4j12</artifactId> | ||||
| 				</exclusion> | ||||
| 			</exclusions> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<dependency> | ||||
| 			<groupId>com.alibaba</groupId> | ||||
| 			<artifactId>fastjson</artifactId> | ||||
| 			<version>${fastjson.version}</version> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<!-- commons --> | ||||
| 		<dependency> | ||||
| 			<groupId>org.apache.commons</groupId> | ||||
| 			<artifactId>commons-lang3</artifactId> | ||||
| 			<version>${commons-lang3.version}</version> | ||||
| 		</dependency> | ||||
| 		<dependency> | ||||
| 			<groupId>commons-collections</groupId> | ||||
| 			<artifactId>commons-collections</artifactId> | ||||
| 			<version>${commons-collection.version}</version> | ||||
| 		</dependency> | ||||
| 		<dependency> | ||||
| 			<groupId>commons-io</groupId> | ||||
| 			<artifactId>commons-io</artifactId> | ||||
| 			<version>${commons-io.version}</version> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<!-- optional --> | ||||
| 		<dependency> | ||||
| 			<groupId>org.springframework.data</groupId> | ||||
| 			<artifactId>spring-data-redis</artifactId> | ||||
| 			<version>2.1.4.RELEASE</version> | ||||
| 			<optional>true</optional> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<!-- provided --> | ||||
| 		<dependency> | ||||
| 			<groupId>org.projectlombok</groupId> | ||||
| 			<artifactId>lombok</artifactId> | ||||
| 			<version>1.18.4</version> | ||||
| 			<scope>provided</scope> | ||||
| 		</dependency> | ||||
| 		<dependency> | ||||
| 			<groupId>javax.servlet</groupId> | ||||
| 			<artifactId>javax.servlet-api</artifactId> | ||||
| 			<version>3.1.0</version> | ||||
| 			<scope>provided</scope> | ||||
| 		</dependency> | ||||
| 	</dependencies> | ||||
| 
 | ||||
| 	<build> | ||||
| 		<plugins> | ||||
| 			<!-- 打包时跳过测试 --> | ||||
| 			<plugin> | ||||
| 				<groupId>org.apache.maven.plugins</groupId> | ||||
| 				<artifactId>maven-surefire-plugin</artifactId> | ||||
| 				<configuration> | ||||
| 					<skipTests>true</skipTests> | ||||
| 				</configuration> | ||||
| 			</plugin> | ||||
| 			<plugin> | ||||
| 				<groupId>org.apache.maven.plugins</groupId> | ||||
| 				<artifactId>maven-compiler-plugin</artifactId> | ||||
| 				<configuration> | ||||
| 					<source>${java.version}</source> | ||||
| 					<target>${java.version}</target> | ||||
| 					<encoding>UTF-8</encoding> | ||||
| 				</configuration> | ||||
| 			</plugin> | ||||
| 			<plugin> | ||||
| 				<groupId>org.apache.maven.plugins</groupId> | ||||
| 				<artifactId>maven-source-plugin</artifactId> | ||||
| 				<version>2.2.1</version> | ||||
| 				<executions> | ||||
| 					<execution> | ||||
| 						<id>attach-sources</id> | ||||
| 						<goals> | ||||
| 							<goal>jar-no-fork</goal> | ||||
| 						</goals> | ||||
| 					</execution> | ||||
| 				</executions> | ||||
| 			</plugin> | ||||
| 
 | ||||
| 			<plugin> | ||||
| 				<groupId>org.apache.maven.plugins</groupId> | ||||
| 				<artifactId>maven-javadoc-plugin</artifactId> | ||||
| 				<version>2.9</version> | ||||
| 				<executions> | ||||
| 					<execution> | ||||
| 						<id>attach-javadocs</id> | ||||
| 						<goals> | ||||
| 							<goal>jar</goal> | ||||
| 						</goals> | ||||
| 						<!-- JDK8必须使用下面的配置 --> | ||||
| 						<configuration> | ||||
| 							<additionalparam>-Xdoclint:none</additionalparam> | ||||
| 						</configuration> | ||||
| 					</execution> | ||||
| 				</executions> | ||||
| 			</plugin> | ||||
| 		</plugins> | ||||
| 	</build> | ||||
| 
 | ||||
| </project> | ||||
| @ -0,0 +1,5 @@ | ||||
| # sop-common | ||||
| 
 | ||||
| - 打包成jar:`mvn clean package` | ||||
| - 上传到本机仓库:`mvn clean install` | ||||
| - 上传到maven私服:`mvn clean deploy` | ||||
| @ -0,0 +1,62 @@ | ||||
| <?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.gitee.sop</groupId> | ||||
|         <artifactId>sop-common</artifactId> | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|         <relativePath>../pom.xml</relativePath> | ||||
|     </parent> | ||||
|     <groupId>com.gitee.sop</groupId> | ||||
|     <artifactId>sop-gateway-common</artifactId> | ||||
|     <version>${parent.version}</version> | ||||
|     <packaging>jar</packaging> | ||||
| 
 | ||||
|     <name>sop-gateway-common</name> | ||||
|     <description>sop-gateway-common</description> | ||||
| 
 | ||||
|     <properties> | ||||
|         <java.version>1.8</java.version> | ||||
|     </properties> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>commons-fileupload</groupId> | ||||
|             <artifactId>commons-fileupload</artifactId> | ||||
|             <version>${commons-fileupload.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>commons-codec</groupId> | ||||
|             <artifactId>commons-codec</artifactId> | ||||
|             <version>${commons-codec.version}</version> | ||||
|         </dependency> | ||||
| 
 | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.cloud</groupId> | ||||
|             <artifactId>spring-cloud-netflix-ribbon</artifactId> | ||||
|             <scope>compile</scope> | ||||
|         </dependency> | ||||
| 
 | ||||
|         <!-- optional --> | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.cloud</groupId> | ||||
|             <artifactId>spring-cloud-starter-netflix-zuul</artifactId> | ||||
|             <optional>true</optional> | ||||
|         </dependency> | ||||
| 
 | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.cloud</groupId> | ||||
|             <artifactId>spring-cloud-starter-gateway</artifactId> | ||||
|             <optional>true</optional> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.boot</groupId> | ||||
|             <artifactId>spring-boot-starter-webflux</artifactId> | ||||
|             <optional>true</optional> | ||||
|         </dependency> | ||||
| 
 | ||||
|     </dependencies> | ||||
| 
 | ||||
| 
 | ||||
| </project> | ||||
| @ -0,0 +1,118 @@ | ||||
| package com.gitee.sop.gatewaycommon.message; | ||||
| 
 | ||||
| /** | ||||
|  * 网关错误定义 | ||||
|  * @author tanghc | ||||
|  */ | ||||
| public enum ErrorEnum { | ||||
|     /** 成功 */ | ||||
|     SUCCESS(Codes.CODE_SUCCESS, ""), | ||||
| 
 | ||||
|     /** 服务暂不可用 */ | ||||
|     ISP_UNKNOW_ERROR(Codes.CODE_UNKNOW, "isp.unknow-error"), | ||||
|     /**  */ | ||||
|     AOP_UNKNOW_ERROR(Codes.CODE_UNKNOW, "aop.unknow-error"), | ||||
| 
 | ||||
|     /** 无效的访问令牌 */ | ||||
|     AOP_INVALID_AUTH_TOKEN(Codes.CODE_AUTH, "aop.invalid-auth-token"), | ||||
|     /** 访问令牌已过期 */ | ||||
|     AOP_AUTH_TOKEN_TIME_OUT(Codes.CODE_AUTH, "aop.auth-token-time-out"), | ||||
|     /** 无效的应用授权令牌 */ | ||||
|     AOP_INVALID_APP_AUTH_TOKEN(Codes.CODE_AUTH, "aop.invalid-app-auth-token"), | ||||
|     /** 商户未授权当前接口 */ | ||||
|     AOP_INVALID_APP_AUTH_TOKEN_NO_API(Codes.CODE_AUTH, "aop.invalid-app-auth-token-no-api"), | ||||
|     /** 应用授权令牌已过期 */ | ||||
|     AOP_APP_AUTH_TOKEN_TIME_OUT(Codes.CODE_AUTH, "aop.app-auth-token-time-out"), | ||||
|     /** 商户未签约任何产品 */ | ||||
|     AOP_NO_PRODUCT_REG_BY_PARTNER(Codes.CODE_AUTH, "aop.no-product-reg-by-partner"), | ||||
| 
 | ||||
|     /** 缺少方法名参数 */ | ||||
|     ISV_MISSING_METHOD(Codes.CODE_MISSING, "isv.missing-method"), | ||||
|     /** 缺少签名参数 */ | ||||
|     ISV_MISSING_SIGNATURE(Codes.CODE_MISSING, "isv.missing-signature"), | ||||
|     /** 缺少签名类型参数 */ | ||||
|     ISV_MISSING_SIGNATURE_TYPE(Codes.CODE_MISSING, "isv.missing-signature-type"), | ||||
|     /** 缺少签名配置 */ | ||||
|     ISV_MISSING_SIGNATURE_KEY(Codes.CODE_MISSING, "isv.missing-signature-key"), | ||||
|     /** 缺少appId参数 */ | ||||
|     ISV_MISSING_APP_ID(Codes.CODE_MISSING, "isv.missing-app-id"), | ||||
|     /** 缺少时间戳参数 */ | ||||
|     ISV_MISSING_TIMESTAMP(Codes.CODE_MISSING, "isv.missing-timestamp"), | ||||
|     /** 缺少版本参数 */ | ||||
|     ISV_MISSING_VERSION(Codes.CODE_MISSING, "isv.missing-version"), | ||||
|     /** 解密出错, 未指定加密算法 */ | ||||
|     ISV_DECRYPTION_ERROR_MISSING_ENCRYPT_TYPE(Codes.CODE_MISSING, "isv.decryption-error-missing-encrypt-type"), | ||||
| 
 | ||||
|     /** 参数无效 */ | ||||
|     ISV_INVALID_PARAMETER(Codes.CODE_INVALID, "isv.invalid-parameter"), | ||||
|     /** 文件上传失败 */ | ||||
|     ISV_UPLOAD_FAIL(Codes.CODE_INVALID, "isv.upload-fail"), | ||||
|     /** 文件扩展名无效 */ | ||||
|     ISV_INVALID_FILE_EXTENSION(Codes.CODE_INVALID, "isv.invalid-file-extension"), | ||||
|     /** 文件大小无效 */ | ||||
|     ISV_INVALID_FILE_SIZE(Codes.CODE_INVALID, "isv.invalid-file-size"), | ||||
|     /** 不存在的方法名 */ | ||||
|     ISV_INVALID_METHOD(Codes.CODE_INVALID, "isv.invalid-method"), | ||||
|     /** 无效的数据格式 */ | ||||
|     ISV_INVALID_FORMAT(Codes.CODE_INVALID, "isv.invalid-format"), | ||||
|     /** 无效的签名类型 */ | ||||
|     ISV_INVALID_SIGNATURE_TYPE(Codes.CODE_INVALID, "isv.invalid-signature-type"), | ||||
|     /** 无效签名 */ | ||||
|     ISV_INVALID_SIGNATURE(Codes.CODE_INVALID, "isv.invalid-signature"), | ||||
|     /** 无效的加密类型 */ | ||||
|     ISV_INVALID_ENCRYPT_TYPE(Codes.CODE_INVALID, "isv.invalid-encrypt-type"), | ||||
|     /** 解密异常 */ | ||||
|     ISV_INVALID_ENCRYPT(Codes.CODE_INVALID, "isv.invalid-encrypt"), | ||||
|     /** 无效的appId参数 */ | ||||
|     ISV_INVALID_APP_ID(Codes.CODE_INVALID, "isv.invalid-app-id"), | ||||
|     /** 非法的时间戳参数 */ | ||||
|     ISV_INVALID_TIMESTAMP(Codes.CODE_INVALID, "isv.invalid-timestamp"), | ||||
|     /** 字符集错误 */ | ||||
|     ISV_INVALID_CHARSET(Codes.CODE_INVALID, "isv.invalid-charset"), | ||||
|     /** 摘要错误 */ | ||||
|     ISV_INVALID_DIGEST(Codes.CODE_INVALID, "isv.invalid-digest"), | ||||
|     /** 解密出错,不支持的加密算法 */ | ||||
|     ISV_DECRYPTION_ERROR_NOT_VALID_ENCRYPT_TYPE(Codes.CODE_INVALID, "isv.decryption-error-not-valid-encrypt-type"), | ||||
|     /** 解密出错, 未配置加密密钥或加密密钥格式错误 */ | ||||
|     ISV_DECRYPTION_ERROR_NOT_VALID_ENCRYPT_KEY(Codes.CODE_INVALID, "isv.decryption-error-not-valid-encrypt-key"), | ||||
|     /** 解密出错,未知异常 */ | ||||
|     ISV_DECRYPTION_ERROR_UNKNOWN(Codes.CODE_INVALID, "isv.decryption-error-unknown"), | ||||
|     /** 验签出错, 未配置对应签名算法的公钥或者证书 */ | ||||
|     ISV_MISSING_SIGNATURE_CONFIG(Codes.CODE_INVALID, "isv.missing-signature-config"), | ||||
|     /** 本接口不支持第三方代理调用 */ | ||||
|     ISV_NOT_SUPPORT_APP_AUTH(Codes.CODE_INVALID, "isv.not-support-app-auth"), | ||||
|     /** 可疑的攻击请求 */ | ||||
|     ISV_SUSPECTED_ATTACK(Codes.CODE_INVALID, "isv.suspected-attack"), | ||||
|     /** 无效的content-type */ | ||||
|     ISV_INVALID_CONTENT_TYPE(Codes.CODE_INVALID, "isv.invalid-content-type"), | ||||
| 
 | ||||
|     /** 业务处理失败 */ | ||||
|     BIZ_ERROR(Codes.CODE_BIZ, ""), | ||||
| 
 | ||||
|     /** 请检查配置的账户是否有当前接口权限 */ | ||||
|     ISV_INSUFFICIENT_ISV_PERMISSIONS(Codes.CODE_ISV_PERM, "isv.insufficient-isv-permissions"), | ||||
|     /** 代理的商户没有当前接口权限 */ | ||||
|     ISV_INSUFFICIENT_USER_PERMISSIONS(Codes.CODE_ISV_PERM, "isv.insufficient-user-permissions"), | ||||
| 
 | ||||
|     ; | ||||
|     private ErrorMeta errorMeta; | ||||
| 
 | ||||
|     ErrorEnum(String code, String subCode) { | ||||
|         this.errorMeta = new ErrorMeta("open.error_", code, subCode); | ||||
|     } | ||||
| 
 | ||||
|     public ErrorMeta getErrorMeta() { | ||||
|         return errorMeta; | ||||
|     } | ||||
| 
 | ||||
|     private static class Codes { | ||||
|         public static final String CODE_SUCCESS = "10000"; | ||||
|         public static final String CODE_AUTH = "20001"; | ||||
|         public static final String CODE_MISSING = "40001"; | ||||
|         public static final String CODE_INVALID = "40002"; | ||||
|         public static final String CODE_BIZ = "40004"; | ||||
|         public static final String CODE_ISV_PERM = "40006"; | ||||
|         public static final String CODE_UNKNOW = "20000"; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -1,10 +1,8 @@ | ||||
| package com.gitee.sop.gatewaycommon.message; | ||||
| 
 | ||||
| import com.gitee.sop.gatewaycommon.bean.ApiContext; | ||||
| import com.gitee.sop.gatewaycommon.exception.ApiException; | ||||
| import com.netflix.zuul.context.RequestContext; | ||||
| import lombok.Getter; | ||||
| import sun.plugin.cache.CacheUpdateHelper; | ||||
| 
 | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import java.util.Locale; | ||||
| @ -1,7 +1,5 @@ | ||||
| package com.gitee.sop.gatewaycommon.result; | ||||
| 
 | ||||
| import com.gitee.sop.gatewaycommon.gateway.result.GatewayResult; | ||||
| 
 | ||||
| /** | ||||
|  * 对返回结果进行处理 | ||||
|  * 成功示例 | ||||
| @ -1,12 +1,9 @@ | ||||
| package com.gitee.sop.gatewaycommon.validate.alipay; | ||||
| 
 | ||||
| import com.gitee.sop.gatewaycommon.bean.ApiContext; | ||||
| import com.gitee.sop.gatewaycommon.message.ErrorEnum; | ||||
| import com.gitee.sop.gatewaycommon.param.ApiParam; | ||||
| import com.gitee.sop.gatewaycommon.validate.Signer; | ||||
| 
 | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| 
 | ||||
| /** | ||||
|  * 支付宝签名验证实现。 | ||||
|  * | ||||
Some files were not shown because too many files have changed in this diff Show More
					Loading…
					
					
				
		Reference in new issue