Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jgjy
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
jgjy
Commits
90aafd25
提交
90aafd25
authored
4月 25, 2019
作者:
lvwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
0e8fb22d
隐藏空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
1330 行增加
和
0 行删除
+1330
-0
.classpath
com.zrqx.third/.classpath
+36
-0
.project
com.zrqx.third/.project
+41
-0
org.eclipse.core.resources.prefs
com.zrqx.third/.settings/org.eclipse.core.resources.prefs
+6
-0
org.eclipse.core.runtime.prefs
com.zrqx.third/.settings/org.eclipse.core.runtime.prefs
+2
-0
org.eclipse.jdt.core.prefs
com.zrqx.third/.settings/org.eclipse.jdt.core.prefs
+8
-0
org.eclipse.m2e.core.prefs
com.zrqx.third/.settings/org.eclipse.m2e.core.prefs
+4
-0
org.eclipse.wst.common.project.facet.core.prefs.xml
...tings/org.eclipse.wst.common.project.facet.core.prefs.xml
+7
-0
org.eclipse.wst.common.project.facet.core.xml
...d/.settings/org.eclipse.wst.common.project.facet.core.xml
+5
-0
pom.xml
com.zrqx.third/pom.xml
+180
-0
Application.java
com.zrqx.third/src/main/java/com/zrqx/third/Application.java
+31
-0
RedisConfig.java
.../main/java/com/zrqx/third/commons/config/RedisConfig.java
+71
-0
Swagger2Config.java
...in/java/com/zrqx/third/commons/config/Swagger2Config.java
+77
-0
WebAppConfig.java
...main/java/com/zrqx/third/commons/config/WebAppConfig.java
+17
-0
CustomExceptionHandler.java
...rqx/third/commons/interceptor/CustomExceptionHandler.java
+88
-0
EmailController.java
...d/src/main/java/com/zrqx/third/email/EmailController.java
+98
-0
RandomUtil.java
....third/src/main/java/com/zrqx/third/email/RandomUtil.java
+47
-0
EmailConfig.java
...rc/main/java/com/zrqx/third/email/config/EmailConfig.java
+12
-0
SdkSmsController.java
...src/main/java/com/zrqx/third/sdksms/SdkSmsController.java
+78
-0
SdkSmsConfig.java
.../main/java/com/zrqx/third/sdksms/config/SdkSmsConfig.java
+12
-0
HttpsUtils.java
...x.third/src/main/java/com/zrqx/third/util/HttpsUtils.java
+205
-0
SplitUtil.java
...qx.third/src/main/java/com/zrqx/third/util/SplitUtil.java
+37
-0
ThirdUtil.java
...qx.third/src/main/java/com/zrqx/third/util/ThirdUtil.java
+32
-0
application.yml
com.zrqx.third/src/main/resources/application.yml
+46
-0
assembly.xml
com.zrqx.third/src/main/resources/assembly.xml
+45
-0
bootstrap.yml
com.zrqx.third/src/main/resources/bootstrap.yml
+10
-0
logback.xml
com.zrqx.third/src/main/resources/logback.xml
+135
-0
没有找到文件。
com.zrqx.third/.classpath
0 → 100644
浏览文件 @
90aafd25
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"src"
output=
"target/classes"
path=
"src/main/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/classes"
path=
"src/main/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"src/test/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/test-classes"
path=
"src/test/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
com.zrqx.third/.project
0 → 100644
浏览文件 @
90aafd25
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>
com.zrqx.third
</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.wst.common.project.facet.core.builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.genuitec.eclipse.springframework.springbuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.springframework.ide.eclipse.core.springbuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
org.springframework.ide.eclipse.core.springnature
</nature>
<nature>
com.genuitec.eclipse.springframework.springnature
</nature>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.m2e.core.maven2Nature
</nature>
<nature>
org.eclipse.wst.common.project.facet.core.nature
</nature>
</natures>
</projectDescription>
com.zrqx.third/.settings/org.eclipse.core.resources.prefs
0 → 100644
浏览文件 @
90aafd25
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
com.zrqx.third/.settings/org.eclipse.core.runtime.prefs
0 → 100644
浏览文件 @
90aafd25
eclipse.preferences.version=1
line.separator=\r\n
com.zrqx.third/.settings/org.eclipse.jdt.core.prefs
0 → 100644
浏览文件 @
90aafd25
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
com.zrqx.third/.settings/org.eclipse.m2e.core.prefs
0 → 100644
浏览文件 @
90aafd25
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
com.zrqx.third/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
0 → 100644
浏览文件 @
90aafd25
<root>
<facet
id=
"me.spring"
>
<node
name=
"libprov"
>
<attribute
name=
"provider-id"
value=
"spring-no-op-library-provider"
/>
</node>
</facet>
</root>
com.zrqx.third/.settings/org.eclipse.wst.common.project.facet.core.xml
0 → 100644
浏览文件 @
90aafd25
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed
facet=
"java"
version=
"1.8"
/>
<installed
facet=
"me.spring"
version=
"4.1"
/>
</faceted-project>
com.zrqx.third/pom.xml
0 → 100644
浏览文件 @
90aafd25
<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.zrqx
</groupId>
<artifactId>
com.zrqx.pom
</artifactId>
<version>
4.0.1
</version>
<relativePath>
../com.zrqx.pom
</relativePath>
</parent>
<artifactId>
com.zrqx.third
</artifactId>
<dependencies>
<!-- 跨服务调用 -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
<dependency>
<groupId>
com.zrqx
</groupId>
<artifactId>
core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-zipkin
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<!--表示为web工程 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<!-- 用于健康监控 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<!--熔断器 -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-hystrix
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-hystrix-dashboard
</artifactId>
</dependency>
<!--swagger2 -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
</dependency>
<!-- Springsecurity给服务端提供安全访问 -->
<!--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
-->
<!--用于测试的 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<!--支付宝支付 -->
<dependency>
<groupId>
com.alipay.sdk
</groupId>
<artifactId>
alipay-sdk-java
</artifactId>
<version>
3.1.0
</version>
</dependency>
<!--阿里短信接口 -->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
3.2.3
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dysmsapi
</artifactId>
<version>
1.1.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
<dependency>
<groupId>
baiwang
</groupId>
<artifactId>
baiwang
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dm
</artifactId>
<version>
3.1.0
</version>
</dependency>
<!-- 热部署工具 -->
<!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
</dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>
true
</addClasspath>
<classpathPrefix>
../lib/
</classpathPrefix>
<mainClass>
com.zrqx.server.ServerStart
</mainClass>
</manifest>
</archive>
<outputDirectory>
${project.build.directory}/${project.artifactId}
</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<executions>
<execution>
<id>
copy-lib
</id>
<phase>
prepare-package
</phase>
<goals>
<goal>
copy-dependencies
</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
<overWriteReleases>
false
</overWriteReleases>
<overWriteSnapshots>
false
</overWriteSnapshots>
<overWriteIfNewer>
true
</overWriteIfNewer>
<includeScope>
compile
</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>
maven-assembly-plugin
</artifactId>
<configuration>
<appendAssemblyId>
false
</appendAssemblyId>
<descriptors>
<descriptor>
src/main/resources/assembly.xml
</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>
make-assembly
</id>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- spring boot打包 <plugin> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <configuration> <finalName>${project.artifactId}</finalName>
</configuration> </plugin> -->
</plugins>
</build>
</project>
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/third/Application.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.hystrix.EnableHystrix
;
import
org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
tk.mybatis.spring.annotation.MapperScan
;
@EnableFeignClients
@EnableEurekaClient
@EnableHystrix
@EnableHystrixDashboard
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
DataSourceTransactionManagerAutoConfiguration
.
class
})
// 系统会去入口类的同级包以及下级包中去扫描实体类,因此我们建议入口类的位置在groupId+arctifactID组合的包名下。
public
class
Application
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
Application
.
class
);
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Application
.
class
,
args
);
logger
.
info
(
"thrid服务已启动....."
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/commons/config/RedisConfig.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
commons
.
config
;
import
java.lang.reflect.Method
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.annotation.CachingConfigurerSupport
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
/**
* redis 配置类
* @author pc
*
*/
@Configuration
@EnableCaching
public
class
RedisConfig
extends
CachingConfigurerSupport
{
@Bean
public
KeyGenerator
keyGenerator
()
{
return
new
KeyGenerator
()
{
@Override
public
Object
generate
(
Object
target
,
Method
method
,
Object
...
params
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
target
.
getClass
().
getName
());
sb
.
append
(
method
.
getName
());
for
(
Object
obj
:
params
)
{
sb
.
append
(
obj
.
toString
());
}
return
sb
.
toString
();
}
};
}
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
factory
)
{
RedisTemplate
<
String
,
Object
>
redisTemplate
=
new
RedisTemplate
<>();
redisTemplate
.
setConnectionFactory
(
factory
);
// key序列化方式,但是如果方法上有Long等非String类型的话,会报类型转换错误
// 所以在没有自己定义key生成策略的时候,以下这个代码建议不要这么写,可以不配置或者自己实现ObjectRedisSerializer
RedisSerializer
<
String
>
redisSerializer
=
new
StringRedisSerializer
();
// Long类型不可以会出现异常信息;
redisTemplate
.
setKeySerializer
(
redisSerializer
);
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
om
);
redisTemplate
.
setValueSerializer
(
jackson2JsonRedisSerializer
);
redisTemplate
.
setHashValueSerializer
(
jackson2JsonRedisSerializer
);
redisTemplate
.
afterPropertiesSet
();
return
redisTemplate
;
}
}
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/third/commons/config/Swagger2Config.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
commons
.
config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* 访问地址
* http://ip:port/swagger-ui.html
最常用的5个注解
@Api:修饰整个类,描述Controller的作用
@ApiOperation:描述一个类的一个方法,或者说一个接口
@ApiParam:单个参数描述
@ApiModel:用对象来接收参数
@ApiModelProperty:用对象接收参数时,描述对象的一个字段
其它若干
@ApiResponse:HTTP响应其中1个描述
@ApiResponses:HTTP响应整体描述
@ApiIgnore:使用该注解忽略这个API
@ApiClass
@ApiError
@ApiErrors
@ApiParamImplicit
@ApiParamsImplicit
*/
@EnableSwagger2
@Configuration
public
class
Swagger2Config
{
/** 服务环境 {@link EnvironmentEnum} 0 测试|其他正式 */
@Value
(
"${server.environment}"
)
private
String
env
;
@Bean
public
Docket
createRestApi
()
{
if
(
"0"
.
equals
(
env
))
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
//为当前包路径
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.zrqx"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
return
null
;
}
//构建 api文档的详细信息函数
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
//页面标题
.
title
(
"third 测试使用 Swagger2 构建RESTful API"
)
//描述
.
description
(
"third服务 API 描述"
)
//创建人
.
contact
(
new
Contact
(
"陈新昌"
,
"www.baidu.com"
,
"cxinchang@126.com"
))
//版本号
.
version
(
"4.0"
)
.
build
();
}
}
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/third/commons/config/WebAppConfig.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
commons
.
config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Configuration
public
class
WebAppConfig
extends
WebMvcConfigurerAdapter
{
/**
* 跨域支持
*/
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
).
allowedOrigins
(
"*"
).
allowedMethods
(
"*"
).
allowCredentials
(
false
).
maxAge
(
3600
);
}
}
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/third/commons/interceptor/CustomExceptionHandler.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
commons
.
interceptor
;
import
java.util.Date
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.ObjectError
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.response.CallBack
;
/**
*controller 异常处理
* @ClassName: CustomExceptionHandler
* @Description: TODO(这里用一句话描述这个类的作用)
* @author 杨振广
* @date 2016-7-14 上午9:45:40
*
*/
@ControllerAdvice
public
class
CustomExceptionHandler
{
Logger
logger
=
LoggerFactory
.
getLogger
(
CustomExceptionHandler
.
class
);
@ExceptionHandler
(
Exception
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseBody
public
Object
handlerException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Exception
e
){
e
.
printStackTrace
();
StackTraceElement
[]
s
=
e
.
getStackTrace
();
StringBuffer
stes
=
new
StringBuffer
(
s
.
length
*
2
);
for
(
StackTraceElement
stackTraceElement
:
s
)
{
stes
.
append
(
stackTraceElement
.
toString
());
stes
.
append
(
"\n"
);
}
String
info
=
"异常时间:"
+
new
Date
().
toLocaleString
()+
"\n请求地址:"
+
request
.
getRequestURI
()+
"\n参数:"
+
request
.
getQueryString
()+
"\n"
+
e
.
getMessage
();
logger
.
error
(
info
+
"\n"
+
stes
.
toString
());
request
.
setAttribute
(
"error"
,
info
);
request
.
setAttribute
(
"errorInfo"
,
e
.
getStackTrace
());
return
CallBack
.
exception
(
e
.
getMessage
());
}
/**
* 参数验证异常处理
* @Title: handlerException
* @Description:
* @param request
* @param response
* @param e BindException
* @return
* @author lpf
* @date: 2018年5月9日 下午5:01:58
*/
@ExceptionHandler
(
BindException
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseBody
public
Object
handlerException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
BindException
e
)
{
List
<
ObjectError
>
errors
=
e
.
getAllErrors
();
StringBuffer
msg
=
new
StringBuffer
();
for
(
ObjectError
objectError
:
errors
)
{
msg
.
append
(
objectError
.
getDefaultMessage
());
msg
.
append
(
","
);
}
msg
.
deleteCharAt
(
msg
.
length
()-
1
);
return
CallBack
.
validate
(
msg
.
toString
());
}
/**
* 执行异常处理
* @Description:
* @param e BaseException
* @return
* @date: 2018年5月9日 下午5:01:58
*
*/
@ExceptionHandler
(
BaseException
.
class
)
@ResponseStatus
(
HttpStatus
.
OK
)
@ResponseBody
public
Object
myException
(
BaseException
e
)
{
return
CallBack
.
fail
(
e
.
getMessage
());
}
}
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/third/email/EmailController.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
email
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
java.util.concurrent.TimeUnit
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.dm.model.v20151123.SingleSendMailRequest
;
import
com.aliyuncs.dm.model.v20151123.SingleSendMailResponse
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.zrqx.core.constant.third.ThirdRequestPath
;
import
com.zrqx.core.form.third.email.EmailForm
;
import
com.zrqx.third.email.config.EmailConfig
;
@RestController
@RequestMapping
(
ThirdRequestPath
.
EMAIL
)
@Api
(
description
=
"邮件"
)
public
class
EmailController
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@ApiOperation
(
value
=
"邮件验证"
,
notes
=
"邮件验证"
)
@PostMapping
(
value
=
ThirdRequestPath
.
VERIFICATION
)
public
String
sample
(
@ApiParam
(
value
=
"邮箱号"
)
String
email
)
{
// 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要将下面的"cn-hangzhou"替换为"ap-southeast-1"、或"ap-southeast-2"。
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
EmailConfig
.
accessKey
,
EmailConfig
.
accessSecret
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
SingleSendMailRequest
request
=
new
SingleSendMailRequest
();
try
{
// request.setVersion("2017-06-22");//
// 如果是除杭州region外的其它region(如新加坡region),必须指定为2017-06-22
request
.
setAccountName
(
EmailConfig
.
AccountName
);
request
.
setFromAlias
(
"小红"
+
"<"
+
email
+
">"
);
request
.
setAddressType
(
1
);
request
.
setTagName
(
EmailConfig
.
TagName
);
request
.
setReplyToAddress
(
true
);
request
.
setToAddress
(
email
);
request
.
setSubject
(
"邮件验证"
);
// 生成验证码
String
code
=
RandomUtil
.
suijishu
(
5
);
// 将验证码保存到session中
stringRedisTemplate
.
opsForValue
().
set
(
code
,
"100"
,
60
*
10
,
TimeUnit
.
SECONDS
);
request
.
setHtmlBody
(
"您收到这封邮件,是由于新用户注册或用户修改E-mail使用了这个邮箱地址。如果您没有访问过我们的平台或没有进行上述操作,请忽略这封邮件。您不需要退订或进行其他操作。<br/>"
+
"您的验证码为<br/>"
+
code
+
"<br/>"
);
SingleSendMailResponse
httpResponse
=
client
.
getAcsResponse
(
request
);
}
catch
(
ServerException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
return
"1"
;
}
@ApiOperation
(
value
=
"邮件(自己发验证码)"
,
notes
=
"邮件(自己发验证码)"
)
@PostMapping
(
value
=
ThirdRequestPath
.
SEND
)
public
String
sendEmail
(
EmailForm
emailForm
)
{
// 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要将下面的"cn-hangzhou"替换为"ap-southeast-1"、或"ap-southeast-2"。
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
EmailConfig
.
accessKey
,
EmailConfig
.
accessSecret
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
SingleSendMailRequest
request
=
new
SingleSendMailRequest
();
try
{
// request.setVersion("2017-06-22");//
// 如果是除杭州region外的其它region(如新加坡region),必须指定为2017-06-22
request
.
setAccountName
(
EmailConfig
.
AccountName
);
request
.
setFromAlias
(
"小红"
+
"<"
+
emailForm
.
getEmail
()
+
">"
);
request
.
setAddressType
(
1
);
request
.
setTagName
(
EmailConfig
.
TagName
);
request
.
setReplyToAddress
(
true
);
request
.
setToAddress
(
emailForm
.
getEmail
());
request
.
setSubject
(
"邮件验证"
);
request
.
setHtmlBody
(
"您收到这封邮件,是由于新用户注册或用户修改E-mail使用了这个邮箱地址。如果您没有访问过我们的平台或没有进行上述操作,请忽略这封邮件。您不需要退订或进行其他操作。<br/>"
+
"您的验证码为<br/>"
+
emailForm
.
getCode
()
+
"<br/>"
);
SingleSendMailResponse
httpResponse
=
client
.
getAcsResponse
(
request
);
}
catch
(
ServerException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
return
"1"
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/email/RandomUtil.java
0 → 100644
浏览文件 @
90aafd25
/**
* @Title: SessionTools.java
* @Package com.book.util
* @Description: TODO(用一句话描述该文件做什么)
* @author 段思铭
* @date 2015-6-17 上午11:09:22
* @version V5.0
*/
package
com
.
zrqx
.
third
.
email
;
import
java.util.Random
;
import
java.util.concurrent.ThreadLocalRandom
;
import
java.util.concurrent.ThreadLocalRandom
;
/**
*
* @ClassName: RandomUtil
* @Description: TODO(这里用一句话描述这个类的作用)
* @author 段思铭
* @date 2015-6-17 下午1:55:14
*
*/
public
class
RandomUtil
{
/**
*
* @Title: suijima
* @Description: TODO(生成数字随机数)
* @param num
* @return
* @return String 返回类型
* @author 段思铭
* @date 2014-9-18 下午3:30:06
*/
public
static
String
suijishu
(
int
num
)
{
char
[]
str
=
"0123456789"
.
toCharArray
();
Random
rd
=
new
Random
();
String
suiji
=
""
;
int
temp
=
0
;
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
temp
=
rd
.
nextInt
(
10
);
suiji
+=
str
[
temp
];
}
return
suiji
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/email/config/EmailConfig.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
email
.
config
;
public
class
EmailConfig
{
public
static
String
accessKey
=
""
;
public
static
String
accessSecret
=
""
;
//管理控制台中配置的发信地址
public
static
String
AccountName
=
""
;
//控制台创建的标签
public
static
String
TagName
=
""
;
}
com.zrqx.third/src/main/java/com/zrqx/third/sdksms/SdkSmsController.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
sdksms
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
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
;
import
com.zrqx.core.constant.third.ThirdRequestPath
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.form.third.sdksms.SdkSmsForm
;
import
com.zrqx.core.util.encry.MD5Util
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.sdksms.config.SdkSmsConfig
;
@RestController
@RequestMapping
(
ThirdRequestPath
.
SDKSMS
)
@Api
(
description
=
"sdk发送短信"
)
public
class
SdkSmsController
{
@ApiOperation
(
value
=
"sdk发送短信"
,
notes
=
"sdk发送短信"
)
@PostMapping
(
ThirdRequestPath
.
SEND
)
public
CallBack
<
String
>
send
(
@RequestBody
SdkSmsForm
ssf
)
{
//http://sdk.entinfo.cn:8061/mdsmssend.ashx?sn=SDK-XAR-010-00044&pwd=D86555F4EA11EFFA57E8F7DF7AAFFD3F&mobile=13716135661&content=测试【签名】&ext=&stime=&rrid=&msgfmt=
// 创建httpclient对象
String
result
=
""
;
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
String
pwd
=
""
;
try
{
pwd
=
MD5Util
.
getEncoderByMd5
(
SdkSmsConfig
.
sn
+
SdkSmsConfig
.
pwd
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
throw
new
BaseException
(
"加密异常"
);
}
String
content
=
ssf
.
getContent
();
try
{
content
=
URLEncoder
.
encode
(
content
,
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e1
)
{
e1
.
printStackTrace
();
throw
new
BaseException
(
"短信发送内容转码失败"
);
}
String
url
=
SdkSmsConfig
.
url
+
"sn="
+
SdkSmsConfig
.
sn
+
"&pwd="
+
pwd
+
"&mobile="
+
ssf
.
getMobile
()
+
"&content="
+
content
+
"【中国人事考试图书网】"
;
// 创建get方式请求对象
HttpGet
httpGet
=
new
HttpGet
(
url
);
httpGet
.
addHeader
(
"Content-type"
,
"application/json"
);
// 通过请求对象获取响应对象
CloseableHttpResponse
response
;
try
{
response
=
httpClient
.
execute
(
httpGet
);
// 获取结果实体
// 判断网络连接状态码是否正常(0--200都数正常)
if
(
response
.
getStatusLine
().
getStatusCode
()
==
HttpStatus
.
SC_OK
)
{
result
=
EntityUtils
.
toString
(
response
.
getEntity
(),
"utf-8"
);
}
// 释放链接
response
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
BaseException
(
"发送失败"
);
}
return
CallBack
.
success
(
result
);
}
}
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/third/sdksms/config/SdkSmsConfig.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
sdksms
.
config
;
public
class
SdkSmsConfig
{
//请求地址
public
static
String
url
=
"http://sdk.entinfo.cn:8061/mdsmssend.ashx?"
;
//序列号
public
static
String
sn
=
"SDK-XAR-010-00044"
;
//密码
public
static
String
pwd
=
"649623"
;
//sn=SN&pwd=MD5(sn+password)&mobile=mobile&content=content&ext=&stime=&rrid=&msgfmt=
}
com.zrqx.third/src/main/java/com/zrqx/third/util/HttpsUtils.java
0 → 100644
浏览文件 @
90aafd25
/**
* @author ray
* @date 2018年8月24日 下午3:22:57
*/
package
com
.
zrqx
.
third
.
util
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.ParseException
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
/** java模拟 post get请求发送
* @author ray
* @date 2018年8月24日下午3:22:57
*/
public
class
HttpsUtils
{
/**
* java模拟get请求
* @param out_trade_no
* @return
* @throws Exception
* @author ray
* @date: 2018年8月24日 下午3:25:34
*/
public
static
String
sendGet
(
String
url
,
String
param
)
{
String
result
=
""
;
BufferedReader
in
=
null
;
try
{
String
urlNameString
=
url
+
"?"
+
param
;
URL
realUrl
=
new
URL
(
urlNameString
);
// 打开和URL之间的连接
URLConnection
connection
=
realUrl
.
openConnection
();
// 设置通用的请求属性
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
//设置连接主机超时
connection
.
setConnectTimeout
(
30000
);
// 建立实际的连接
connection
.
connect
();
// 获取所有响应头字段
Map
<
String
,
List
<
String
>>
map
=
connection
.
getHeaderFields
();
// 遍历所有的响应头字段
for
(
String
key
:
map
.
keySet
())
{
System
.
out
.
println
(
key
+
"--->"
+
map
.
get
(
key
));
}
// 定义 BufferedReader输入流来读取URL的响应
in
=
new
BufferedReader
(
new
InputStreamReader
(
connection
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
;
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"发送GET请求出现异常!"
+
e
);
e
.
printStackTrace
();
}
// 使用finally块来关闭输入流
finally
{
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
Exception
e2
)
{
e2
.
printStackTrace
();
}
}
return
result
;
}
/**
* java模拟post请求
* @param out_trade_no
* @return
* @throws Exception
* @author ray
* @date: 2018年8月24日 下午3:25:34
*/
public
static
String
sendPost
(
String
url
,
String
param
)
{
PrintWriter
out
=
null
;
BufferedReader
in
=
null
;
String
result
=
""
;
try
{
URL
realUrl
=
new
URL
(
url
);
// 打开和URL之间的连接
URLConnection
conn
=
realUrl
.
openConnection
();
// 设置通用的请求属性
conn
.
setRequestProperty
(
"accept"
,
"*/*"
);
conn
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
conn
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
// 发送POST请求必须设置如下两行
conn
.
setDoOutput
(
true
);
conn
.
setDoInput
(
true
);
// 获取URLConnection对象对应的输出流
out
=
new
PrintWriter
(
conn
.
getOutputStream
());
// 发送请求参数
out
.
print
(
param
);
// flush输出流的缓冲
out
.
flush
();
// 定义BufferedReader输入流来读取URL的响应
in
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
()));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
+=
line
;
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"发送 POST 请求出现异常!"
+
e
);
e
.
printStackTrace
();
}
//使用finally块来关闭输出流、输入流
finally
{
try
{
if
(
out
!=
null
){
out
.
close
();
}
if
(
in
!=
null
){
in
.
close
();
}
}
catch
(
IOException
ex
){
ex
.
printStackTrace
();
}
}
return
result
;
}
public
static
String
sendPost
(
String
url
,
Map
<
String
,?
extends
Object
>
paramsMap
)
{
CloseableHttpClient
closeableHttpClient
=
HttpClients
.
createDefault
();
//配置连接超时时间
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
.
setConnectTimeout
(
5000
)
.
setConnectionRequestTimeout
(
5000
)
.
setSocketTimeout
(
5000
)
.
setRedirectsEnabled
(
true
)
.
build
();
HttpPost
httpPost
=
new
HttpPost
(
url
);
//设置超时时间
httpPost
.
setConfig
(
requestConfig
);
//装配post请求参数
List
<
NameValuePair
>
list
=
new
ArrayList
<
NameValuePair
>();
for
(
String
key
:
paramsMap
.
keySet
())
{
list
.
add
(
new
BasicNameValuePair
(
key
,
String
.
valueOf
(
paramsMap
.
get
(
key
))));
}
try
{
//将参数进行编码为合适的格式,如将键值对编码为param1=value1¶m2=value2
UrlEncodedFormEntity
urlEncodedFormEntity
=
new
UrlEncodedFormEntity
(
list
,
"utf-8"
);
httpPost
.
setEntity
(
urlEncodedFormEntity
);
//执行 post请求
CloseableHttpResponse
closeableHttpResponse
=
closeableHttpClient
.
execute
(
httpPost
);
String
strRequest
=
""
;
if
(
null
!=
closeableHttpResponse
&&
!
""
.
equals
(
closeableHttpResponse
))
{
System
.
out
.
println
(
closeableHttpResponse
.
getStatusLine
().
getStatusCode
());
if
(
closeableHttpResponse
.
getStatusLine
().
getStatusCode
()
==
HttpStatus
.
SC_OK
)
{
HttpEntity
httpEntity
=
closeableHttpResponse
.
getEntity
();
strRequest
=
EntityUtils
.
toString
(
httpEntity
,
"utf-8"
);
}
else
{
strRequest
=
"Error Response"
+
closeableHttpResponse
.
getStatusLine
().
getStatusCode
();
}
}
return
strRequest
;
}
catch
(
ClientProtocolException
e
)
{
e
.
printStackTrace
();
return
"协议异常"
;
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
return
"解析异常"
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
"传输异常"
;
}
finally
{
try
{
if
(
closeableHttpClient
!=
null
)
{
closeableHttpClient
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
com.zrqx.third/src/main/java/com/zrqx/third/util/SplitUtil.java
0 → 100644
浏览文件 @
90aafd25
/**
* @author ray
* @date 2018年9月14日 下午12:05:52
*/
package
com
.
zrqx
.
third
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
/**
* @author ray
* @date 2018年9月14日下午12:05:52
*/
public
class
SplitUtil
{
/**
* 截取qq返回的信息
* @param body
* @return
* @author ray
* @date: 2018年9月14日 下午12:41:23
*/
public
static
Map
<
String
,
String
>
splitBody
(
String
body
){
Map
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
if
(
StringUtils
.
isNotBlank
(
body
)){
//将 access_token=986A0E8DE045BFD2B94689F6D7F3CFCD&expires_in=7776000&refresh_token=E476F1B911CE70E1F0C1A9B84EE181A7形式参数分割成数组
String
[]
arr
=
body
.
split
(
"&"
);
//将=左边作为key,=右边作为value
for
(
String
str:
arr
){
String
[]
arr1
=
str
.
split
(
"="
);
map
.
put
(
arr1
[
0
],
arr1
[
1
]);
}
}
return
map
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/util/ThirdUtil.java
0 → 100644
浏览文件 @
90aafd25
package
com
.
zrqx
.
third
.
util
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
public
class
ThirdUtil
{
public
static
String
doGetWithParam
(
String
url
,
String
getOut_trade_no
,
String
type
)
throws
Exception
{
// 创建一个httpclient对象
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
// 创建一个uri对象
URIBuilder
uriBuilder
=
new
URIBuilder
(
url
);
uriBuilder
.
addParameter
(
"getOut_trade_no"
,
getOut_trade_no
);
uriBuilder
.
addParameter
(
"type"
,
type
);
HttpGet
get
=
new
HttpGet
(
uriBuilder
.
build
());
// 执行请求
CloseableHttpResponse
response
=
httpClient
.
execute
(
get
);
// 取响应的结果
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
System
.
out
.
println
(
statusCode
);
HttpEntity
entity
=
response
.
getEntity
();
String
string
=
EntityUtils
.
toString
(
entity
,
"utf-8"
);
// 关闭httpclient
response
.
close
();
httpClient
.
close
();
return
string
;
}
}
com.zrqx.third/src/main/resources/application.yml
0 → 100644
浏览文件 @
90aafd25
logging
:
level
:
com.zrqx.bg.resource
:
DEBUG
feign
:
hystrix
:
enabled
:
true
ribbon
:
ConnectTimeout
:
360000
ReadTimeout
:
360000
hystrix
:
command
:
default
:
execution
:
isolation
:
strategy
:
SEMAPHORE
thread
:
timeoutInMilliseconds
:
1440000
semaphore
:
maxConcurrentRequests
:
200
mybatis
:
type-aliases-package
:
com.zrqx.core.model
mapper
:
mappers
:
-
com.zrqx.core.mapper.BaseMapper
not-empty
:
false
i-d-e-n-t-i-t-y
:
MYSQL
style
:
normal
b-e-f-o-r-e
:
true
pagehelper
:
helperDialect
:
mysql
reasonable
:
true
supportMethodsArguments
:
true
params
:
count=countSql
spring
:
main
:
allow-bean-definition-overriding
:
true
#2.1.0 多个接口上的@FeignClient(“相同服务名”)会报错 ,允许覆盖
jackson
:
date-format
:
yyyy-MM-dd HH:mm:ss
time-zone
:
GMT+8
http
:
multipart
:
maxFileSize
:
20Mb
maxRequestSize
:
20Mb
thymeleaf
:
prefix
:
classpath:/templates/
\ No newline at end of file
com.zrqx.third/src/main/resources/assembly.xml
0 → 100644
浏览文件 @
90aafd25
<assembly
xmlns=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"
>
<id>
package
</id>
<formats>
<format>
zip
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>
${basedir}/src/main/resources
</directory>
<includes>
<include>
*.yml
</include>
<include>
*.xml
</include>
<include>
static/**
</include>
<include>
templates/**
</include>
<include>
*.properties
</include>
<include>
*.txt
</include>
</includes>
<filtered>
true
</filtered>
<outputDirectory>
${file.separator}${project.artifactId}
</outputDirectory>
</fileSet>
<fileSet>
<directory>
src/main/resources/runScript
</directory>
<outputDirectory>
${file.separator}bin
</outputDirectory>
</fileSet>
<fileSet>
<directory>
${project.build.directory}/lib
</directory>
<outputDirectory>
${file.separator}${project.artifactId}/lib
</outputDirectory>
<includes>
<include>
*.jar
</include>
</includes>
</fileSet>
<fileSet>
<directory>
${project.build.directory}/
</directory>
<outputDirectory>
${file.separator}${project.artifactId}
</outputDirectory>
<includes>
<include>
*.jar
</include>
</includes>
</fileSet>
</fileSets>
</assembly>
\ No newline at end of file
com.zrqx.third/src/main/resources/bootstrap.yml
0 → 100644
浏览文件 @
90aafd25
server
:
port
:
8299
spring
:
cloud
:
config
:
uri
:
http://localhost:8288
#配置中心地址
name
:
third
profile
:
prod
label
:
master
\ No newline at end of file
com.zrqx.third/src/main/resources/logback.xml
0 → 100644
浏览文件 @
90aafd25
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://www.padual.com/java/logback.xsd"
debug=
"false"
scan=
"true"
scanPeriod=
"30 second"
>
<!--读取配置中心的属性-->
<springProperty
scope=
"context"
name=
"name"
source=
"spring.application.name"
/>
<property
name=
"ROOT"
value=
"/opt/logs/master/third/"
/>
<property
name=
"FILESIZE"
value=
"50MB"
/>
<property
name=
"MAXHISTORY"
value=
"100"
/>
<property
name=
"DATETIME"
value=
"yyyy-MM-dd HH:mm:ss"
/>
<!-- 控制台打印 -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
</appender>
<!-- ERROR 输入到文件,按日期和文件大小 -->
<appender
name=
"ERROR"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
ERROR
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/error.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- WARN 输入到文件,按日期和文件大小 -->
<appender
name=
"WARN"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
WARN
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/warn.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- INFO 输入到文件,按日期和文件大小 -->
<appender
name=
"INFO"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
INFO
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/info.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- DEBUG 输入到文件,按日期和文件大小 -->
<appender
name=
"DEBUG"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
DEBUG
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/debug.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- TRACE 输入到文件,按日期和文件大小 -->
<appender
name=
"TRACE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<encoder
charset=
"utf-8"
>
<pattern>
[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
</pattern>
</encoder>
<filter
class=
"ch.qos.logback.classic.filter.LevelFilter"
>
<level>
TRACE
</level>
<onMatch>
ACCEPT
</onMatch>
<onMismatch>
DENY
</onMismatch>
</filter>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<fileNamePattern>
${ROOT}%d/trace.%i.log
</fileNamePattern>
<maxHistory>
${MAXHISTORY}
</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<maxFileSize>
${FILESIZE}
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- SQL相关日志输出-->
<logger
name=
"org.mybatis.spring"
level=
"DEBUG"
additivity=
"true"
/>
<logger
name=
"com.zrqx.third"
level=
"DEBUG"
additivity=
"true"
/>
<!-- Logger 根目录 -->
<root
level=
"INFO"
>
<appender-ref
ref=
"STDOUT"
/>
<appender-ref
ref=
"DEBUG"
/>
<appender-ref
ref=
"ERROR"
/>
<appender-ref
ref=
"WARN"
/>
<appender-ref
ref=
"INFO"
/>
<appender-ref
ref=
"TRACE"
/>
</root>
</configuration>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论