Commit 8510edc7 authored by zhangc's avatar zhangc

commit api网关代码

parent 1ea71617
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<?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.jz.dm</groupId>
<artifactId>jz-dm-parent</artifactId>
<groupId>com.jz.dm</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jz-dm-apigateway</artifactId>
<name>jz-dm-apigateway</name>
<description>jz-dm-apigateway</description>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.3.0.RELEASE</version>
<scope>compile</scope>
</dependency>
<!-- spring-boot 相关依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!--Redis集中存储Session-->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- spring boot 和mybatis -->
<!--<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>-->
<!-- mybatis plus -->
<!--mybatis-plus自动的维护了mybatis以及mybatis-spring的依赖,
在springboot中这三者不能同时的出现,避免版本的冲突,表示:跳进过这个坑-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.1</version>
</dependency>
<!--mybatis分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
</dependency>
<!-- druid数据库连接池 -->
<!-- 引入Druid依赖,阿里巴巴所提供的数据源 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.29</version>
</dependency>
<!-- mysql连接 -->
<!-- 提供mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<!-- swagger2接口文档 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
</dependency>
<!--工具类-->
<!--lang3工具类-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!--fastJson包-->
<dependency>
<groupId>com.jz.common</groupId>
<artifactId>jz-dm-common</artifactId>
<version>1.0.0-SNAPSHOT</version>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.jz.dm;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm
* @PROJECT_NAME: jz-dm-parent
* @NAME: ApiGatewayApplication
* @USER: key
* @DATE: 2020-12-2/16:03
* @DAY_NAME_SHORT: 周三
* @Description:
**/
@SpringBootApplication
//@ComponentScan(basePackages = {"com.jz"})
@MapperScan("com.jz.dm.mapper")
public class ApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
}
package com.jz.dm.gateway.common.exception;
package com.jz.dm.common.exception;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
/**
* 网关异常
......
package com.jz.dm.gateway.common.exception;
package com.jz.dm.common.exception;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
/**
* 信息摘要异常
......
package com.jz.dm.gateway.common.exception;
package com.jz.dm.common.exception;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
/**
* 通知异常
......
package com.jz.dm.gateway.common.exception;
package com.jz.dm.common.exception;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
/**
* openapi异常
......
package com.jz.dm.gateway.common.exception;
package com.jz.dm.common.exception;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
/**
* 加密异常
......
package com.jz.dm.gateway.common.exception;
package com.jz.dm.common.exception;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
/**
* 签名异常
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import org.apache.commons.codec.BinaryDecoder;
import org.apache.commons.codec.BinaryEncoder;
......
/**
* Copyright (c) 2011-2014 All Rights Reserved.
*/
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
/**
* @author Admin
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import java.util.HashMap;
import java.util.Map;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jz.dm.gateway.common.exception.OpenApiException;
import com.jz.dm.common.exception.OpenApiException;
import java.math.BigDecimal;
import java.math.BigInteger;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import java.util.HashMap;
import java.util.Map;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.apache.commons.codec.binary.Base64;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.security.*;
......@@ -12,6 +13,7 @@ import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
public class RSAUtils {
public static final String CHARSET = "UTF-8";
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.jz.dm.gateway.common.exception.SignatureException;
import com.jz.dm.gateway.model.signtype.Md5;
import com.jz.dm.common.exception.SignatureException;
import com.jz.dm.model.signtype.Md5;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import org.apache.commons.lang3.StringUtils;
......
package com.jz.dm.gateway.common.util;
package com.jz.dm.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.*;
......
package com.jz.dm.gateway.config;
package com.jz.dm.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
......@@ -15,20 +15,20 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*/
@EnableTransactionManagement
@Configuration
@MapperScan("com.jz.dm.gateway.mapper")
@MapperScan("com.jz.dm.mapper")
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// paginationInterceptor.setOverflow(false);
// 设置最大单页限制数量,默认 500 条,-1 不受限制
paginationInterceptor.setLimit(500);
// 开启 count 的 join 优化,只针对部分 left join
paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
return paginationInterceptor;
}
//@Bean
//public PaginationInterceptor paginationInterceptor() {
// PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
// // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
// // paginationInterceptor.setOverflow(false);
// // 设置最大单页限制数量,默认 500 条,-1 不受限制
// paginationInterceptor.setLimit(500);
// // 开启 count 的 join 优化,只针对部分 left join
// paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
// return paginationInterceptor;
//}
}
package com.jz.dm.gateway.constant;
package com.jz.dm.constant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
package com.jz.dm.gateway.controller;
package com.jz.dm.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.jz.dm.gateway.common.util.JsonUtil;
import com.jz.dm.gateway.gateway.GatewayService;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.RequestContext;
import com.jz.dm.common.util.JsonUtil;
import com.jz.dm.gateway.GatewayService;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.RequestContext;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.RequestContext;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.RequestContext;
import org.springframework.core.Ordered;
/**
* 抽象过滤器
* @author key
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.jz.dm.gateway.common.exception.GatewayException;
import com.jz.dm.gateway.common.util.SignType;
import com.jz.dm.gateway.common.util.StringUtil;
import com.jz.dm.gateway.constant.Constants;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.enums.Format;
import com.jz.dm.gateway.model.enums.GatewayResultCode;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.common.util.SignType;
import com.jz.dm.common.util.StringUtil;
import com.jz.dm.constant.Constants;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.enums.Format;
import com.jz.dm.model.enums.GatewayResultCode;
import org.springframework.stereotype.Component;
import java.nio.charset.Charset;
......
package com.jz.dm.gateway.filter;
import com.jz.dm.gateway.common.exception.GatewayException;
import com.jz.dm.gateway.constant.Constants;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.RequestContext;
import com.jz.dm.gateway.model.enums.GatewayResultCode;
package com.jz.dm.filter;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.constant.Constants;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.RequestContext;
import com.jz.dm.model.enums.GatewayResultCode;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
......
package com.jz.dm.gateway.filter;
import com.jz.dm.gateway.common.exception.GatewayException;
import com.jz.dm.gateway.constant.Constants;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.enums.GatewayResultCode;
import org.springframework.beans.factory.annotation.Value;
package com.jz.dm.filter;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.constant.Constants;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.enums.GatewayResultCode;
import org.springframework.stereotype.Component;
/**
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
/**
* 过滤器
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
/**
* 请求过滤链
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.jz.dm.gateway.common.exception.OpenApiException;
import com.jz.dm.gateway.common.util.LogUtil;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.enums.GatewayResultCode;
import com.jz.dm.common.exception.OpenApiException;
import com.jz.dm.common.util.LogUtil;
import com.jz.dm.common.util.ResultCode;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.enums.GatewayResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jz.dm.gateway.common.exception.GatewayException;
import com.jz.dm.gateway.common.util.LogUtil;
import com.jz.dm.gateway.constant.Constants;
import com.jz.dm.gateway.constant.LoggingConstants;
import com.jz.dm.gateway.gateway.DefaultOpenApiDispatcher;
import com.jz.dm.gateway.model.*;
import com.jz.dm.gateway.model.enums.GatewayResultCode;
import com.jz.dm.gateway.model.enums.RouteType;
import com.jz.dm.common.exception.GatewayException;
import com.jz.dm.common.util.LogUtil;
import com.jz.dm.constant.Constants;
import com.jz.dm.constant.LoggingConstants;
import com.jz.dm.gateway.DefaultOpenApiDispatcher;
import com.jz.dm.model.enums.GatewayResultCode;
import com.jz.dm.model.enums.RouteType;
import com.jz.dm.model.*;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......
package com.jz.dm.gateway.filter;
package com.jz.dm.filter;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.jz.dm.gateway.common.util.StringUtil;
import com.jz.dm.gateway.common.exception.SignatureException;
import com.jz.dm.gateway.common.util.*;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.gateway.model.enums.GatewayResultCode;
import com.jz.dm.common.util.*;
import com.jz.dm.common.exception.SignatureException;
import com.jz.dm.common.util.StringUtil;
import com.jz.dm.constant.Constants;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.enums.GatewayResultCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jz.dm.gateway.constant.Constants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
......
package com.jz.dm.gateway.filter;
import com.jz.dm.gateway.common.util.HddHashMap;
import com.jz.dm.gateway.common.util.RSAUtils;
import com.jz.dm.gateway.constant.Constants;
import com.jz.dm.gateway.model.*;
import com.jz.dm.gateway.model.enums.RouteType;
package com.jz.dm.filter;
import com.jz.dm.common.util.HddHashMap;
import com.jz.dm.common.util.RSAUtils;
import com.jz.dm.constant.Constants;
import com.jz.dm.model.enums.RouteType;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import com.jz.dm.model.OpenApi;
import com.jz.dm.model.RequestContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.security.interfaces.RSAPublicKey;
......
package com.jz.dm.gateway;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
/**
* @author key
*/
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@ComponentScan(basePackages = {"com.jz.dm"})
@MapperScan("com.jz.dm.gateway.mapper")
public class ApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
}
package com.jz.dm.gateway.gateway;
package com.jz.dm.gateway;
import com.alibaba.fastjson.JSON;
import com.jz.dm.gateway.common.util.StringUtil;
import com.jz.dm.gateway.common.exception.OpenApiException;
import com.jz.dm.gateway.common.util.OpenApiRequest;
import com.jz.dm.gateway.common.util.OpenApiResponse;
import com.jz.dm.gateway.common.util.OpenApiResultCode;
import com.jz.dm.gateway.model.DispatchContext;
import com.jz.dm.common.exception.OpenApiException;
import com.jz.dm.common.util.OpenApiRequest;
import com.jz.dm.common.util.OpenApiResponse;
import com.jz.dm.common.util.OpenApiResultCode;
import com.jz.dm.common.util.StringUtil;
import com.jz.dm.model.DispatchContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
......@@ -19,8 +19,9 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* 默认openapi分发器
*
* @author key
*/
@Component
@Component("defaultOpenApiDispatcher")
public class DefaultOpenApiDispatcher implements OpenApiDispatcher {
private static final Logger LOGGER = LoggerFactory
......
package com.jz.dm.gateway.gateway;
package com.jz.dm.gateway;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
/**
* GatewayService
* @author key
*/
public interface GatewayService {
......
package com.jz.dm.gateway.gateway;
package com.jz.dm.gateway;
import com.jz.dm.gateway.model.DispatchContext;
import com.jz.dm.model.DispatchContext;
/**
* openapi分发器
......
package com.jz.dm.gateway.gateway;
package com.jz.dm.gateway;
import com.jz.dm.gateway.common.util.OpenApiRequest;
import com.jz.dm.gateway.common.util.OpenApiResponse;
import com.jz.dm.common.util.OpenApiRequest;
import com.jz.dm.common.util.OpenApiResponse;
/**
* openapi服务
......
package com.jz.dm.gateway.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* @ProjectName zhaxinle
* @Author: zeroJun
* @Date: 2018/8/16 16:49
* @Description: 主数据源配置类
*/
@Configuration
// 前缀为primary.datasource.druid的配置信息
@ConfigurationProperties(prefix = "spring.datasource")
@MapperScan(basePackages = DatabaseConfig.PACKAGE, sqlSessionFactoryRef = "sqlSessionFactory")
public class DatabaseConfig {
/**
* dao层的包路径
*/
static final String PACKAGE = "com.jz.dm.gateway.mapper";
/**
* mapper文件的相对路径
*/
private static final String MAPPER_LOCATION = "classpath:/mapper/*.xml";
private String filters;
private String url;
private String username;
private String password;
private String driverClassName;
private int initialSize;
private int minIdle;
private int maxActive;
private long maxWait;
private long timeBetweenEvictionRunsMillis;
private long minEvictableIdleTimeMillis;
private String validationQuery;
private boolean testWhileIdle;
private boolean testOnBorrow;
private boolean testOnReturn;
private boolean poolPreparedStatements;
private int maxPoolPreparedStatementPerConnectionSize;
// 主数据源使用@Primary注解进行标识
//@Primary
@Bean(name = "dataSource")
public DataSource dataSource() throws SQLException {
DruidDataSource druid = new DruidDataSource();
// 监控统计拦截的filters
druid.setFilters(filters);
// 配置基本属性
druid.setDriverClassName(driverClassName);
druid.setUsername(username);
druid.setPassword(password);
druid.setUrl(url);
//初始化时建立物理连接的个数
druid.setInitialSize(initialSize);
//最大连接池数量
druid.setMaxActive(maxActive);
//最小连接池数量
druid.setMinIdle(minIdle);
//获取连接时最大等待时间,单位毫秒。
druid.setMaxWait(maxWait);
//间隔多久进行一次检测,检测需要关闭的空闲连接
druid.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
//一个连接在池中最小生存的时间
druid.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
//用来检测连接是否有效的sql
druid.setValidationQuery(validationQuery);
//建议配置为true,不影响性能,并且保证安全性。
druid.setTestWhileIdle(testWhileIdle);
//申请连接时执行validationQuery检测连接是否有效
druid.setTestOnBorrow(testOnBorrow);
druid.setTestOnReturn(testOnReturn);
//是否缓存preparedStatement,也就是PSCache,oracle设为true,mysql设为false。分库分表较多推荐设置为false
druid.setPoolPreparedStatements(poolPreparedStatements);
// 打开PSCache时,指定每个连接上PSCache的大小
druid.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
return druid;
}
// 创建该数据源的事务管理
@Primary
@Bean(name = "transactionManager")
public DataSourceTransactionManager transactionManager() throws SQLException {
return new DataSourceTransactionManager(dataSource());
}
// 创建Mybatis的连接会话工厂实例
@Primary
@Bean(name = "sqlSessionFactory")
public SqlSessionFactory sqlSessionFactory(@Qualifier("dataSource") DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource); // 设置数据源bean
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(DatabaseConfig.MAPPER_LOCATION)); // 设置mapper文件路径
return sessionFactory.getObject();
}
public String getFilters() {
return filters;
}
public void setFilters(String filters) {
this.filters = filters;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
public int getInitialSize() {
return initialSize;
}
public void setInitialSize(int initialSize) {
this.initialSize = initialSize;
}
public int getMinIdle() {
return minIdle;
}
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
public int getMaxActive() {
return maxActive;
}
public void setMaxActive(int maxActive) {
this.maxActive = maxActive;
}
public long getMaxWait() {
return maxWait;
}
public void setMaxWait(long maxWait) {
this.maxWait = maxWait;
}
public long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
}
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}
public long getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
}
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
public boolean isTestWhileIdle() {
return testWhileIdle;
}
public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
}
public boolean isTestOnBorrow() {
return testOnBorrow;
}
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public boolean isTestOnReturn() {
return testOnReturn;
}
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
public boolean isPoolPreparedStatements() {
return poolPreparedStatements;
}
public void setPoolPreparedStatements(boolean poolPreparedStatements) {
this.poolPreparedStatements = poolPreparedStatements;
}
public int getMaxPoolPreparedStatementPerConnectionSize() {
return maxPoolPreparedStatementPerConnectionSize;
}
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
}
}
\ No newline at end of file
/**
* Copyright (c) 2011-2019 All Rights Reserved.
*/
package com.jz.dm.gateway.gateway.impl;
package com.jz.dm.gateway.impl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* API白名单表 服务实现类
*
......
package com.jz.dm.gateway.gateway.impl;
package com.jz.dm.gateway.impl;
import com.jz.dm.gateway.filter.FilterChain;
import com.jz.dm.gateway.filter.FilterChainFactory;
import com.jz.dm.gateway.gateway.GatewayService;
import com.jz.dm.gateway.model.GatewayRequest;
import com.jz.dm.gateway.model.GatewayResponse;
import com.jz.dm.filter.FilterChain;
import com.jz.dm.filter.FilterChainFactory;
import com.jz.dm.gateway.GatewayService;
import com.jz.dm.model.GatewayRequest;
import com.jz.dm.model.GatewayResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 网关服务
*
* @author key
*/
@Service
@Service("gatewayService")
public class GatewayServiceImpl implements GatewayService {
@Autowired
......
package com.jz.dm.gateway.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.common.entity.DataGoodsApi;
import java.util.List;
/**
* api商品(TDataGoodsApi)表数据库访问层
*
* @author Bellamy
* @since 2020-12-01 10:41:31
*/
public interface DataGoodsApiDao extends BaseMapper<DataGoodsApi> {
List<DataGoodsApi> findAll();
}
\ No newline at end of file
package com.jz.dm.gateway.mapper;
import com.jz.common.base.BaseMapper;
import com.jz.common.entity.DataGoodsApiParams;
/**
* api商品参数配置(TDataGoodsApiParams)表数据库访问层
*
* @author Bellamy
* @since 2020-12-01 10:41:31
*/
public interface DataGoodsApiParamsDao extends BaseMapper<DataGoodsApiParams> {
}
\ No newline at end of file
package com.jz.dm.gateway.service;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.gateway.service
* @PROJECT_NAME: jz-dm-parent
* @NAME: Test
* @USER: key
* @DATE: 2020-11-24/16:21
* @DAY_NAME_SHORT: 周二
* @Description:
**/
public class Test {
}
package com.jz.dm.gateway.model;
package com.jz.dm.model;
import java.io.Serializable;
import java.util.HashMap;
......
package com.jz.dm.gateway.model;
package com.jz.dm.model;
import com.jz.dm.gateway.web.annotation.ParamName;
import com.jz.dm.web.annotation.ParamName;
import java.io.Serializable;
import java.util.HashMap;
......
package com.jz.dm.gateway.model;
package com.jz.dm.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
......
package com.jz.dm.gateway.model;
package com.jz.dm.model;
import com.alibaba.fastjson.JSON;
import com.jz.dm.gateway.model.enums.RouteType;
import com.jz.dm.model.enums.RouteType;
import java.util.Date;
import java.util.HashMap;
......
package com.jz.dm.gateway.model;
package com.jz.dm.model;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......
package com.jz.dm.gateway.model.enums;
package com.jz.dm.model.enums;
import com.jz.dm.gateway.common.util.ResultCode;
import com.jz.dm.common.util.ResultCode;
import java.util.HashMap;
import java.util.Map;
......
package com.jz.dm.gateway.model.signtype;
package com.jz.dm.model.signtype;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......
package com.jz.dm.gateway.model.signtype;
package com.jz.dm.model.signtype;
import com.jz.dm.gateway.constant.Constants;
import com.jz.dm.constant.Constants;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import javax.crypto.Cipher;
......
package com.jz.dm.gateway.model.signtype;
package com.jz.dm.model.signtype;
import com.jz.dm.gateway.common.util.Base64;
import com.jz.dm.gateway.common.util.StreamUtil;
import com.jz.dm.common.util.Base64;
import com.jz.dm.common.util.StreamUtil;
import org.apache.commons.lang3.StringUtils;
import java.io.*;
......
package com.jz.dm.gateway.service.trade;
package com.jz.dm.service;
import com.jz.dm.gateway.common.util.OpenApiRequest;
import com.jz.dm.gateway.common.util.OpenApiResponse;
import com.jz.dm.gateway.gateway.OpenApiService;
import lombok.extern.slf4j.Slf4j;
import com.jz.dm.common.util.OpenApiRequest;
import com.jz.dm.common.util.OpenApiResponse;
import com.jz.dm.gateway.OpenApiService;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class TradeAddService implements OpenApiService {
public class AccountAddService implements OpenApiService {
@Override
public String getOpenApiMethod() {
return "bal.query";
return "account.add";
}
@Override
......@@ -24,6 +19,6 @@ public class TradeAddService implements OpenApiService {
@Override
public void doService(OpenApiRequest request, OpenApiResponse response) {
System.out.println("~~~~~~~~~~~~请求到接口~~~~~~~~~~~~");
System.out.println("请求过来了。。。。。");
}
}
package com.jz.dm.gateway.web.binder;
package com.jz.dm.web.binder;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequestDataBinder;
......
package com.jz.dm.gateway.web.binder;
package com.jz.dm.web.binder;
import com.jz.dm.gateway.web.annotation.ParamName;
import com.jz.dm.web.annotation.ParamName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.context.request.NativeWebRequest;
......
#开发环境配置
spring:
#缓存会话
redis:
#database: 0
#host: 119.23.13.83
#port: 8007
#timeout: 5000
cluster:
nodes:
- 192.168.31.167:6379
- 192.168.31.167:6380
- 192.168.31.167:6381
- 192.168.31.167:6382
- 192.168.31.167:6383
- 192.168.31.167:6384
session:
store-type: none
#数据库
datasource:
url: jdbc:mysql://rm-wz9n399q2avsy3k6m4o.mysql.rds.aliyuncs.com:3306/wj-mkt-project?characterEncoding=utf8&useSSL=false
driverClassName: com.mysql.jdbc.Driver
username: root
password: I%ou$buy!ok
type: com.alibaba.druid.pool.DruidDataSource
#监控统计拦截的filters
filters: stat
#配置初始化大小/最小/最大
initialSize: 1
minIdle: 1
maxActive: 20
#获取连接等待超时时间
maxWait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
timeBetweenEvictionRunsMillis: 60000
#一个连接在池中最小生存的时间
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
#打开PSCache,并指定每个连接上PSCache的大小。
#oracle设为true,mysql设为false。分库分表较多推荐设置为false
poolPreparedStatements: false
maxPoolPreparedStatementPerConnectionSize: 20
# 跳过签名
api:
skipFilter: false
skipIpLimit: true
maxPostSize: 1048576
supplierId: 200314008093
# 代发三要素校验定时任务
validCron: 0/1 * * * * *
##测试环境配置
#spring:
#
# #缓存会话
# redis:
# host: r-wz9cnvxpbfm2ir35dh.redis.rds.aliyuncs.com
# password: hdd2020@888
# port: 6379
# timeout: 10000
# lettuce:
# pool:
# max-active: 100 #连接池最大连接数(使用负值表示没有限制)
# max-idle: 100 #连接池中的最大空闲连接
# min-idle: 50 #连接池中的最小空闲连接
# max-wait: 6000 #连接池最大阻塞等待时间(使用负值表示没有限制)
#
# #数据库
# datasource:
# url: jdbc:mysql://172.18.126.216:3306/btcpaydb?serverTimezone=GMT%2B8&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false
# username: root
# password: hdd2020@888
# type: com.zaxxer.hikari.HikariDataSource
# driver-class-name: com.mysql.cj.jdbc.Driver
# hikari:
# minimum-idle: 20
# maximum-pool-size: 100
# auto-commit: true
# idle-timeout: 30000
# pool-name: MyHikariCP
# max-lifetime: 1800000
# connection-timeout: 30000
# connection-test-query: SELECT 1
#数据源
spring:
security:
basic:
enabled: false
datasource:
url: jdbc:mysql://rm-wz9n399q2avsy3k6m4o.mysql.rds.aliyuncs.com:3306/wj-mkt-project?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false
username: root
password: I%ou$buy!ok
driver-class-name: com.mysql.jdbc.Driver
druid:
# 初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时
initialSize: 1
# 最小连接池数量
minIdle: 1
# 最大连接池数量
maxActive: 10
# 配置获取连接等待超时的时间
maxWait: 10000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 验证连接有效与否的SQL,不同的数据配置不同
validationQuery: select 1
# 建议配置为true,不影响性能,并且保证安全性。
# 申请连接的时候检测,如果空闲时间大于
# timeBetweenEvictionRunsMillis,
# 执行validationQuery检测连接是否有效。
testWhileIdle: true
# 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
# 这里建议配置为TRUE,防止取到的连接不可用
testOnBorrow: true
# 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能
testOnReturn: false
# 是否缓存preparedStatement,也就是PSCache。
# PSCache对支持游标的数据库性能提升巨大,比如说oracle。
# 在mysql5.5以下的版本中没有PSCache功能,建议关闭掉。
# 作者在5.5版本中使用PSCache,通过监控界面发现PSCache有缓存命中率记录,
# 该应该是支持PSCache。
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 属性类型是字符串,通过别名的方式配置扩展插件,
# 常用的插件有:
# 监控统计用的filter:stat
# 日志用的filter:log4j
# 防御sql注入的filter:wall
filters: stat
# ====================MybatisPlus====================
mybatis-plus:
# 如果是放在src/main/java目录下 classpath:/com/yourpackage/*/mapper/*Mapper.xml
# 如果是放在resource目录 classpath:/mapper/*Mapper.xml
mapper-locations: classpath*:com/frame/**/**.xml,classpath*:mapping/**/**.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.frame.**.entity,com.frame.**.dto
global-config:
#刷新mapper 调试神器
db-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: UUID
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
column-underline: false
#数据库大写下划线转换
# capital-mode: true
#逻辑删除配置
logic-delete-value: 1
logic-not-delete-value: 0
refresh: true
configuration:
#配置返回数据库(column下划线命名&&返回java实体是驼峰命名),自动匹配无需as(没开启这个,SQL需要写as: select user_id as userId)
map-underscore-to-camel-case: true
cache-enabled: false
#配置JdbcTypeForNull, oracle数据库必须配置
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
database-id: mysql
\ No newline at end of file
......@@ -3,12 +3,6 @@ server:
port: 8088
servlet:
context-path: /
#Djasypt.encryptor.password
jasypt:
encryptor:
password: btcpay.com
#日志打印
logging:
level:
......@@ -22,29 +16,22 @@ spring:
aop:
proxy-target-class: true
profiles:
active: dev #默认使用的配置文件
active: test #默认使用的配置文件
http:
encoding:
charset: UTF-8
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
default-property-inclusion: NON_NULL
#MyBatis
mybatis-plus:
mapper-locations: classpath:/mapper/**/*.xml
typeAliasesPackage: com.jz.common.entity
#type-handlers-package: com.btcpay.commons.typehandler
global-config:
id-type: 1
field-strategy: 2
db-column-underline: true
refresh-mapper: true
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#mybatis-plus:
# mapper-locations: classpath:/mapper/**/*.xml
# typeAliasesPackage: com.jz.common.entity
# #type-handlers-package: com.btcpay.commons.typehandler
# global-config:
# id-type: 1
# field-strategy: 2
# db-column-underline: true
# refresh-mapper: true
# configuration:
# map-underscore-to-camel-case: true
# cache-enabled: false
# #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<substitutionProperty name="log.proj" value="gateway" />
<!-- 服务器 -->
<substitutionProperty name="log.base" value="/logs/${log.proj}" />
<!-- 本地 -->
<!-- <substitutionProperty name="log.base" value="/Users/luoyichang/Desktop/hdd/logs/${log.proj}" />-->
<substitutionProperty name="max.size" value="100MB" />
<jmxConfigurator />
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [${log.proj}:%thread] %-5level %logger{80} - %msg%n
</pattern>
</layout>
</appender>
<appender name="file.debug" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- All Log Info -->
<File>${log.base}/${log.proj}.log</File>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.base}/${log.proj}_%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>${max.size}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
</layout>
</appender>
<appender name="file.info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <File>${log.base}/${log.proj}_info.log</File> -->
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.base}/${log.proj}_info_%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>${max.size}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
</layout>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file.error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.base}/${log.proj}_error_%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>${max.size}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
</layout>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file.warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.base}/${log.proj}_warn_%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>${max.size}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
</layout>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"><!-- 临界值过滤器,过滤掉低于指定临界值的日志 -->
<level>WARN</level>
</filter>
</appender>
<!--异步输出 -->
<appender name="async.file.info" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>256</queueSize>
<appender-ref ref="file.info" />
</appender>
<appender name="async.file.debug" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>256</queueSize>
<appender-ref ref="file.debug" />
</appender>
<appender name="async.file.warn" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>256</queueSize>
<appender-ref ref="file.warn" />
</appender>
<appender name="async.file.error" class="ch.qos.logback.classic.AsyncAppender">
<discardingThreshold>0</discardingThreshold>
<queueSize>256</queueSize>
<appender-ref ref="file.error" />
</appender>
<root level="info" additivity="false">
<appender-ref ref="stdout" />
<!-- <appender-ref ref="async.file.debug" /> -->
<appender-ref ref="async.file.info" />
<appender-ref ref="async.file.error" />
<!-- <appender-ref ref="async.file.warn" /> -->
</root>
<logger name="io.lettuce.core.protocol.ConnectionWatchdog" additivity="false">
<appender-ref ref="stdout" />
<level value="ERROR" />
</logger>
<logger name="io.lettuce.core.protocol.ReconnectionHandler" additivity="false">
<appender-ref ref="stdout" />
<level value="ERROR" />
</logger>
</configuration>
\ No newline at end of file
<?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.jz.dm.gateway.mapper.DataGoodsApiDao">
<resultMap type="com.jz.common.entity.DataGoodsApi" id="TDataGoodsApiMap">
<result property="goodsApi" column="goods_api" jdbcType="INTEGER"/>
<result property="dataGoodsId" column="data_goods_id" jdbcType="INTEGER"/>
<result property="apiName" column="api_name" jdbcType="VARCHAR"/>
<result property="requestType" column="request_type" jdbcType="VARCHAR"/>
<result property="apiUrl" column="api_url" jdbcType="VARCHAR"/>
<result property="apiMethod" column="api_method" jdbcType="VARCHAR"/>
<result property="apiProtocl" column="api_protocl" jdbcType="VARCHAR"/>
<result property="returnDataExample" column="return_data_example" jdbcType="VARCHAR"/>
<result property="requestExample" column="request_example" jdbcType="VARCHAR"/>
<result property="returnType" column="return_type" jdbcType="VARCHAR"/>
<result property="apiKey" column="api_key" jdbcType="VARCHAR"/>
<result property="creTime" column="cre_time" jdbcType="TIMESTAMP"/>
<result property="crePerson" column="cre_person" jdbcType="VARCHAR"/>
<result property="uptPerson" column="upt_person" jdbcType="VARCHAR"/>
<result property="uptTime" column="upt_time" jdbcType="TIMESTAMP"/>
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
</resultMap>
<select id="findAll" resultType="com.jz.common.entity.DataGoodsApi">
select * from t_data_goods_api
</select>
</mapper>
\ No newline at end of file
<?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.jz.dm.gateway.mapper.DataGoodsApiParamsDao">
<resultMap type="com.jz.common.entity.DataGoodsApiParams" id="TDataGoodsApiParamsMap">
<result property="apiParamsId" column="api_params_id" jdbcType="INTEGER"/>
<result property="goodsApi" column="goods_api" jdbcType="INTEGER"/>
<result property="paramsDiff" column="params_diff" jdbcType="VARCHAR"/>
<result property="paramsName" column="params_name" jdbcType="VARCHAR"/>
<result property="paramsType" column="params_type" jdbcType="VARCHAR"/>
<result property="paramsDesc" column="params_desc" jdbcType="VARCHAR"/>
<result property="defaultValue" column="default_value" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="ifRequird" column="if_requird" jdbcType="VARCHAR"/>
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
<result property="creTime" column="cre_time" jdbcType="TIMESTAMP"/>
<result property="uptTime" column="upt_time" jdbcType="TIMESTAMP"/>
</resultMap>
</mapper>
\ No newline at end of file
/**
* Copyright (c) 2011-2014 All Rights Reserved.
*/
package domian;
package com.jz.dm.gateway;
/**
*
......
package domian;
package com.jz.dm.gateway;
......@@ -24,7 +24,7 @@ public class TestApplicationContextInitializer implements ApplicationContextInit
private Properties props = null;
/**
* @see org.springframework.context.ApplicationContextInitializer#initialize(org.springframework.context.ConfigurableApplicationContext)
* @see ApplicationContextInitializer#initialize(org.springframework.context.ConfigurableApplicationContext)
*/
@Override
public void initialize(GenericApplicationContext context) {
......
package domian; /**
* Copyright (c) 2011-2018 All Rights Reserved.
*/
import com.alibaba.fastjson.JSON;
import com.jz.dm.gateway.common.util.TtpayUtils;
import com.jz.dm.gateway.common.util.WebUtils;
import com.jz.dm.gateway.model.signtype.Md5;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author Admin
* @version $Id: PushSdkTest.java 2018年4月12日 下午4:31:31 $
*/
public class PushSdkLocalhostTest1 {
private static String uri = "http://localhost:8088/gateway";
public static void main(String[] args) throws Exception {
// 余额查询接口
balQuery();
//委托订单查询
//orderQuery();
//取消订单
//cancelOrder();
//账户信息查询
//accQuery();
//代发订单详情
//orderDetail();
}
protected static void balQuery() {
try {
Map<String, String> data = new HashMap<>();
data.put("appId", "200316008117");
data.put("method", "bal.query");
data.put("charset", "UTF-8");
data.put("signType", "MD5");
data.put("timestamp", String.valueOf(System.currentTimeMillis()));
data.put("version", "1.0.0");
Map<String, String> params = new HashMap<>();
params.put("account_no", "5845342722900679704");
params.put("account_type", "WBANK");
data.put("params", JSON.toJSONString(params));
String dataStr = TtpayUtils.createLinkString(TtpayUtils.filter(data));
String sign = Md5.encrypt(dataStr, "fP6R7cSvQj8JwThFvP1RrOomkHXydHx3", "UTF-8");
data.put("sign", sign);
System.out.println(data);
String rsp = WebUtils.post(uri, data);
System.out.println(rsp);
} catch (Exception e) {
e.printStackTrace();
}
}
//protected static void orderQuery() {
// try {
// Map<String, String> data = new HashMap<>();
// data.put("app_id", "200314008093");
// data.put("method", "trade.query");
// data.put("charset", "UTF-8");
// data.put("sign_type", "MD5");
//
// data.put("timestamp", String.valueOf(System.currentTimeMillis()));
// data.put("version", "1.0.0");
//
// Map<String, String> params = new HashMap<>();
// //商户订单号
// params.put("out_trade_no", "YW202003040013");
// //银行卡号(非必填)
// //params.put("card_no", "6214806601002512988");
// data.put("params", JSON.toJSONString(params));
// String dataStr = TtpayUtils.createLinkString(TtpayUtils.filter(data));
// String sign = Md5.encrypt(dataStr, "fP6R7cSvQj8JwThFvP1RrOomkHXydHx3", "UTF-8");
// data.put("sign", sign);
//
// String rsp = WebUtils.post(uri, data);
// System.out.println(rsp);
// } catch (Exception e) {
// e.printStackTrace();
// }
//}
//
//protected static void cancelOrder() {
// try {
// Map<String, String> data = new HashMap<>();
// data.put("app_id", "200314008092");
// data.put("method", "trade.cancel");
// data.put("charset", "UTF-8");
// data.put("sign_type", "MD5");
//
// data.put("timestamp", String.valueOf(System.currentTimeMillis()));
// data.put("version", "1.0.0");
//
// Map<String, String> params = new HashMap<>();
// params.put("remark", "订单取消");
// //商户订单号
// params.put("out_trade_no", "2020031410810730003");
// data.put("params", JSON.toJSONString(params));
//
// String dataStr = TtpayUtils.createLinkString(TtpayUtils.filter(data));
// String sign = Md5.encrypt(dataStr, "fP6R7cSvQj8JwThFvP1RrOomkHXydHx3", "UTF-8");
// data.put("sign", sign);
//
// String rsp = WebUtils.post(uri, data);
// System.out.println(rsp);
// } catch (Exception e) {
// e.printStackTrace();
// }
//}
//protected static void accQuery() {
// try {
// Map<String, String> data = new HashMap<>();
// data.put("app_id", "200314008092");
// data.put("method", "acc.query");
// data.put("charset", "UTF-8");
// data.put("sign_type", "MD5");
//
// data.put("timestamp", String.valueOf(System.currentTimeMillis()));
// data.put("version", "1.0.0");
//
// Map<String, String> params = new HashMap<>();
// //params.put("remark", "订单取消");
// //商户订单号
// //params.put("out_trade_no", "2020031410810730003");
// data.put("params", JSON.toJSONString(params));
//
// String dataStr = TtpayUtils.createLinkString(TtpayUtils.filter(data));
// String sign = Md5.encrypt(dataStr, "fP6R7cSvQj8JwThFvP1RrOomkHXydHx3", "UTF-8");
// data.put("sign", sign);
//
// String rsp = WebUtils.post(uri, data);
// System.out.println(rsp);
// } catch (Exception e) {
// e.printStackTrace();
// }
//}
//protected static void orderDetail() {
// try {
// Map<String, String> data = new HashMap<>();
// data.put("app_id", "200314008093");
// data.put("method", "trade.detail");
// data.put("charset", "UTF-8");
// data.put("sign_type", "MD5");
//
// data.put("timestamp", String.valueOf(System.currentTimeMillis()));
// data.put("version", "1.0.0");
//
// Map<String, String> params = new HashMap<>();
// //商户订单号
// params.put("out_trade_no", "YW202003040012");
// data.put("params", JSON.toJSONString(params));
//
// String dataStr = TtpayUtils.createLinkString(TtpayUtils.filter(data));
// String sign = Md5.encrypt(dataStr, "fP6R7cSvQj8JwThFvP1RrOomkHXydHx3", "UTF-8");
// data.put("sign", sign);
//
// String rsp = WebUtils.post(uri, data);
// System.out.println(rsp);
// } catch (Exception e) {
// e.printStackTrace();
// }
//}
}
package domian.TestApi;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jz.common.entity.DataGoodsApi;
import com.jz.dm.gateway.mapper.DataGoodsApiDao;
import domian.SpringTestCase;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collections;
import java.util.List;
/**
* @author ZC
* @PACKAGE_NAME: domian.TestApi
* @PROJECT_NAME: jz-dm-parent
* @NAME: GatewayTest
* @USER: key
* @DATE: 2020-12-2/11:53
* @DAY_NAME_SHORT: 周三
* @Description:
**/
public class GatewayTest extends SpringTestCase {
@Autowired
private DataGoodsApiDao dataGoodsApiDao;
@Test
public void Test(){
//List<DataGoodsApi> list= dataGoodsApiDao.findAll();
// System.out.println(list);
QueryWrapper<DataGoodsApi> wrapper = new QueryWrapper<>();
wrapper.eq("goods_api",1);
DataGoodsApi dataGoodsApi = dataGoodsApiDao.selectOne(wrapper);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment