提交 57e039e9 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 e498cc74
<?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"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" 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="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
差异被折叠。
<?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.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<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>
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
eclipse.preferences.version=1
line.separator=\r\n
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target\\generated-sources\\annotations
org.eclipse.jdt.apt.genTestSrcDir=target\\generated-test-sources\\test-annotations
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
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.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<root>
<facet id="me.spring">
<node name="libprov">
<attribute name="provider-id" value="spring-no-op-library-provider"/>
</node>
</facet>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
<installed facet="me.spring" version="4.1"/>
</faceted-project>
boot.validation.initialized=true
eclipse.preferences.version=1
<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.0</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>com.zrqx.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>
</project>
\ No newline at end of file
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.openfeign.EnableFeignClients;
@EnableFeignClients
@EnableEurekaClient
@EnableHystrix
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
// 系统会去入口类的同级包以及下级包中去扫描实体类,因此我们建议入口类的位置在groupId+arctifactID组合的包名下。
public class ThirdStart {
private final static Logger logger = LoggerFactory.getLogger(ThirdStart.class);
public static void main(String[] args) {
SpringApplication.run(ThirdStart.class, args);
logger.info("thrid服务已启动.....");
}
}
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.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
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();
}
};
}
/*@SuppressWarnings("rawtypes")
@Bean
public CacheManager cacheManager(RedisTemplate redisTemplate) {
RedisCacheManager rcm = new RedisCacheManager(redisTemplate);
// 设置缓存过期时间
// rcm.setDefaultExpiration(60);//秒
return rcm;
}*/
@Bean
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig()
//.entryTtl(Duration.ofHours(1)) // 设置缓存有效期一小时
;
return RedisCacheManager
.builder(RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory))
.cacheDefaults(redisCacheConfiguration).build();
}
@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
package com.zrqx.third.commons.config;
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 {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包路径
.apis(RequestHandlerSelectors.basePackage("com.zrqx"))
.paths(PathSelectors.any())
.build();
}
//构建 api文档的详细信息函数
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
//页面标题
.title("sysUser 测试使用 Swagger2 构建RESTful API")
//描述
.description("sysUser服务 API 描述")
//创建人
.contact(new Contact("陈新昌", "www.baidu.com", "cxinchang@126.com"))
//版本号
.version("3.0")
.build();
}
}
\ No newline at end of file
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);
}
// @Bean
// public Decoder feignDecoder() {
// HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(customObjectMapper());
// ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
// return new ResponseEntityDecoder(new SpringDecoder(objectFactory));
// }
// @Bean
// public Encoder feignEncoder(){
// HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(customObjectMapper());
// ObjectFactory<HttpMessageConverters> objectFactory = () -> new HttpMessageConverters(jacksonConverter);
// return new SpringEncoder(objectFactory);
// }
//
// public ObjectMapper customObjectMapper(){
// ObjectMapper objectMapper = new ObjectMapper();
// //Customize as much as you want
// objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
// return objectMapper;
// }
}
\ No newline at end of file
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 {
private static 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.fail(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.fail(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
package com.zrqx.third.commons.interceptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import feign.RequestInterceptor;
import feign.RequestTemplate;
@Component
public class CustomRequestInterceptor implements RequestInterceptor {
@Autowired
private ObjectMapper objectMapper;
@Override
public void apply(RequestTemplate template) {
// feign 不支持 GET 方法传 POJO, json body转query
if (template.method().equals("GET") && template.body() != null) {
try {
JsonNode jsonNode = objectMapper.readTree(template.body());
template.body(null);
Map<String, Collection<String>> queries = new HashMap<>();
buildQuery(jsonNode, "", queries);
template.queries(queries);
} catch (IOException e) {
e.printStackTrace();
}
}
}
private void buildQuery(JsonNode jsonNode, String path, Map<String, Collection<String>> queries) {
if (!jsonNode.isContainerNode()) { // 叶子节点
if (jsonNode.isNull()) {
return;
}
Collection<String> values = queries.get(path);
if (null == values) {
values = new ArrayList<>();
queries.put(path, values);
}
values.add(jsonNode.asText());
return;
}
if (jsonNode.isArray()) { // 数组节点
Iterator<JsonNode> it = jsonNode.elements();
while (it.hasNext()) {
buildQuery(it.next(), path, queries);
}
} else {
Iterator<Map.Entry<String, JsonNode>> it = jsonNode.fields();
while (it.hasNext()) {
Map.Entry<String, JsonNode> entry = it.next();
if (StringUtils.hasText(path)) {
buildQuery(entry.getValue(), path + "." + entry.getKey(), queries);
} else { // 根节点
buildQuery(entry.getValue(), entry.getKey(), queries);
}
}
}
}
}
package com.zrqx.third.commons.interceptor;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* Feign配置
* 使用FeignClient进行服务间调用,传递headers信息
* @author lw
* @date 2018年10月17日下午2:48:44
*/
@Component
@Configuration
public class FeignHeaderInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
if (attributes != null) {
HttpServletRequest request = attributes.getRequest();
// 前台token
if(request.getHeader("Y-Token") != null){
requestTemplate.header("Y-Token", request.getHeader("Y-Token"));
}
// 后台token
if(request.getHeader("X-Token") != null){
requestTemplate.header("X-Token", request.getHeader("X-Token"));
}
}
}
}
package com.zrqx.third.commons.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
public class InterceptorConfig implements HandlerInterceptor{
private static final Logger log = LoggerFactory.getLogger(InterceptorConfig.class);
/**
* 进入controller层之前拦截请求
* @param httpServletRequest
* @param httpServletResponse
* @param o
* @return
* @throws Exception
*/
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
HttpSession session = httpServletRequest.getSession();
if(session.getAttribute("user") != null){
return true;
}
else{
return true;
}
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
log.info("--------------处理请求完成后视图渲染之前的处理操作---------------");
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
log.info("---------------视图渲染之后的操作--------------------------");
}
}
\ No newline at end of file
package com.zrqx.third.constant;
import com.zrqx.core.constant.third.ThirdRequestPath;
/**
* @Description: 管理项目下的 URI信息
* @author lpf
* @date 2018年5月21日下午1:51:21
*/
public class RequestPath extends ThirdRequestPath{
}
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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.form.third.email.EmailForm;
import com.zrqx.third.constant.RequestPath;
import com.zrqx.third.email.config.EmailConfig;
@RestController
@RequestMapping(RequestPath.EMAIL)
@Api(description = "邮件")
public class EmailController {
@Autowired
StringRedisTemplate stringRedisTemplate;
@ApiOperation(value = "邮件验证", notes = "邮件验证")
@PostMapping(value = RequestPath.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 = RequestPath.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";
}
}
/**
* @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;
}
}
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="";
}
package com.zrqx.third.sdksms;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.exception.BaseException;
import com.zrqx.core.form.third.sdksms.SdkSmsForm;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.util.encry.MD5Util;
import com.zrqx.third.constant.RequestPath;
import com.zrqx.third.sdksms.config.SdkSmsConfig;
@RestController
@RequestMapping(RequestPath.SDKSMS)
@Api(description = "sdk发送短信")
public class SdkSmsController {
@ApiOperation(value = "sdk发送短信", notes = "sdk发送短信")
@PostMapping(RequestPath.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 url = SdkSmsConfig.url + "sn=" + SdkSmsConfig.sn + "&pwd=" + pwd + "&mobile=" + ssf.getMobile() + "&content="
+ ssf.getContent()+"【中国市场出版社】";
// 创建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) {
throw new BaseException("发送失败");
}
return CallBack.success(result);
}
}
\ No newline at end of file
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=
}
package com.zrqx.third.sms;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import org.springframework.web.bind.annotation.GetMapping;
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.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.zrqx.core.form.third.sms.SmsForm;
import com.zrqx.core.form.third.sms.SmsQueryForm;
import com.zrqx.third.constant.RequestPath;
import com.zrqx.third.sms.config.SmsConfig;
import com.zrqx.third.sms.config.SmsEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping(RequestPath.SMS)
@Api(description = "短信接口")
public class SmsController {
@ApiOperation(value = "发送短信", notes = "发送短信")
@PostMapping(RequestPath.SEND)
public SendSmsResponse sendSms(@RequestBody SmsForm smsForm) throws ClientException {
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", SmsConfig.accessKeyId, SmsConfig.accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", SmsConfig.product, SmsConfig.domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
//必填:待发送手机号
request.setPhoneNumbers(smsForm.getPhone());
//必填:短信签名-可在短信控制台中找到
request.setSignName(SmsConfig.signName);
//必填:短信模板-可在短信控制台中找到
request.setTemplateCode(SmsEnum.getName(smsForm.getType()));
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.setTemplateParam("{'name':'"+smsForm.getName()+"', 'code':'"+smsForm.getCode()+"'}");
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
request.setOutId(smsForm.getOutId());
//hint 此处可能会抛出异常,注意catch
SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
return sendSmsResponse;
}
@ApiOperation(value = "查询短信", notes = "查询短信")
@GetMapping(RequestPath.QUERY)
public QuerySendDetailsResponse querySendDetails(SmsQueryForm sqf) throws ClientException {
//可自助调整超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
//初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", SmsConfig.accessKeyId, SmsConfig.accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", SmsConfig.product, SmsConfig.domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
//组装请求对象
QuerySendDetailsRequest request = new QuerySendDetailsRequest();
//必填-号码
request.setPhoneNumber(sqf.getPhone());
//可选-流水号
request.setBizId(sqf.getBizId());
//必填-发送日期 支持30天内记录查询,格式yyyyMMdd
SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
if(sqf.getDate()==null||"".equals(sqf.getDate())){
request.setSendDate(ft.format(new Date()));
}else{
request.setSendDate(sqf.getDate());
}
//必填-页大小
request.setPageSize(10L);
//必填-当前页码从1开始计数
request.setCurrentPage(1L);
//hint 此处可能会抛出异常,注意catch
QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
return querySendDetailsResponse;
}
/**
* 生成6位随机数
* @param num
* @return
* @author lz
* @date: 2018年8月6日 下午3:00:07
*/
private static String random(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;
}
}
package com.zrqx.third.sms.config;
public class SmsConfig {
// 产品名称:云通信短信API产品,开发者无需替换
public static String product = "Dysmsapi";
// 产品域名,开发者无需替换
public static String domain = "dysmsapi.aliyuncs.com";
// TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
public static String accessKeyId = "LTAIEvKzhAFYvN8T";
public static String accessKeySecret = "lE7dkXvPEBDMyoar2uX2zrzOD6QUuR";
//必填:短信签名-可在短信控制台中找到
public static String signName="中软启信";
}
package com.zrqx.third.sms.config;
public enum SmsEnum {
//用户注册code
REGIST(0,"SMS_76606370"),
//修改密码code
PASSWORD(1,"SMS_76606369");
private final Integer code;
private final String name;
private SmsEnum(Integer code,String name){
this.code=code;
this.name=name;
}
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
/**
* 通过ID获取名称
* @param code
* @return
*/
public static String getName(Integer code) {
if (code == null) {
throw new IllegalArgumentException("SmsEnum Status " + code
+ " is blank");
}
for (SmsEnum mt : values()) {
if (mt.getCode().equals(code)) {
return mt.getName();
}
}
throw new IllegalArgumentException("SmsEnum Status " + code
+ " is not exist");
}
}
/**
* @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&param2=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();
}
}
}
}
/**
* @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;
}
}
package com.zrqx.third.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.zrqx.core.util.spring.BaseSpringContextUtils;
@Component
public class SpringContextUtils extends BaseSpringContextUtils {
private static final Logger logger = LoggerFactory.getLogger(SpringContextUtils.class);
// @Value("${test-environment}")
// private Boolean testEnvironment;
/**
* 初始化操作
* @author lpf
* @date: 2019年1月3日 上午9:17:01
*/
public void init(){
}
@Override
public Logger getLog() {
return SpringContextUtils.logger;
}
}
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;
}
}
feign:
hystrix:
enabled: true
ribbon:
ConnectTimeout: 60000
ReadTimeout: 60000
hystrix:
command:
default:
execution:
isolation:
strategy: SEMAPHORE
thread:
timeoutInMilliseconds: 120000
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:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
http:
multipart:
maxFileSize: 20Mb
maxRequestSize: 20Mb
thymeleaf:
prefix: classpath:/templates/
pay:
alipay:
# 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号
# app_id: 2016091800539106 #沙箱账号
app_id: 2018032302431822
# 商户私钥,您的PKCS8格式RSA2私钥
# merchant_private_key: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQChjWjM50LiQ9QyN0Nn/4SSpvdNEFecG99DFbh/BvvgxTP7iDE4VqHVrLn78Svn3TEvEOWZjB+TsNJ/8YSb3uUte4o2+3RfAKk8sHwBqxk70EjQ6ekxIaB6NozKB91xD35by+YvwG9u5+VR6LRJQUz72fdCKiq0y2NZ4QIbzscCsYTp9Xnh3QNWqimWACJr+oSs4cbLbExM4SYFrbEpkOLOqxNR1ywHnQlnuSWyYlSbv+642QVLlDhj/zBb+fMJkA0djtd4gXykYOK/o9y5fDT0drCisKO8t2qld75kKcIr0+n0kERKfMU8dSmY0UkUxKQOPQMfo+cslMZdQQyEqaqFAgMBAAECggEAcPnaK0kizebPUxqwid730DLxSLRAAEzBkkFzV2oD5QkjtChm+1YiMLJtEdJzeN+HkLmJRxrlzjveyViV+wciT+9QFek9VV65+1YUMnp72AdtlKOvzwsMFctmI7biVjmWjQ2HeSdjBjUnemN5CK2g75NbRasFWI/Pd8BR4C53n9pyYz3TSdJsM9rpHGtauio6O4LtfcWOyLpJh7tH77lpJkG41qB8unc50bdw+8kwjMdRY964on+WqARq9+oq6ii29glYGfQVy74g/BNukKgXlzvdRqqfjwF9TKCmfbbOiOyw1IK6MZVEnjPKVgZ0e0XlbYxjapanOc/9o4YmzjsxQQKBgQDxAoY4NdMIqKVN0Xk1tWuvijm+9NJ1ttRZ5Zwf6x7htM7TOHVVGz8JSUWtBfgaeMdEXKoAbz6hM6LHPeXkPO5DiuksnidOqiLeOr2q4y7Brhm62LH9ORTjcKYVx3oW0o99QJ+UtPxhgVrgLrMX9L3jQRg1VszY7GJsCIsgNNMdVQKBgQCrmbl/zHAY+ap/h04ELnYvoaLV+032yrqLwU6/86w1WhSPR9ew6aFkDFLp7b08IYI1L98StN1AJJjU5ebdUxrp2T/J0CKJLrLHIuUkFxIzc0xAFP1KtvNnAP6pivdx1uUWrm9jiyjkuD7/s1exuiKCpXa1LfJ3Rt1nBNGo99LYcQKBgQCBdw6swVUk8Jsj62PGUzeOq50LlC4+J8F4rRwqFT6Ylm0ID+sPlbxN+7tfD7bQWZMJiRGVfCzToY5Oo1SMP6LqS4OogSiyXDiw0jMyyilCx4hw05kBYxlyd//v8SEHg4KrEPzogDSXGEq95Lg2JTWgD0a22HLgEFNqn0hFO7swpQKBgGm8OR7UG6ZoAHTALIRLFKvYzvtG9A1DcZq3rAx+2ves38pBnFf4PWfmaBiYUugARbj8HFnsdAAYDMvyNUTe9lBteu6hfwZEbghiKgsI5EArpSo/RKuK+4PWixRw+nN81IAbT6tojfQQy1DHcxuh863IwtJ001hHpBjcUUvqGFMhAoGAO9vuhT3lh3WhllUzS6fqDZbjmm0iozYfolt0IZuuLVP7rf22m4E+PR1OPmBdsBztLDTMFVTGLTybBlV3oV3d83qzVu/i3nRCRn4kFYxbGNyLQoFPodlxP1mZOkhIzsyf6iYHyrV/fVZPDRL6ms0Mn5ukuulUSNWrXhRAugK/Vfo=
merchant_private_key: MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCrnXI8IDoltKJUnARYg41h2XSQF1eTJ3XQUMko5FCFl9tivkpf9ZCln/y3Xs52e+n2XkYIIPUGgtQe0kgUdJVFffFhhFELJ3T+pD2pcXpl0jgegWRYVNI4vIb8k4T/Pn0X4HHGKGWuv+nIhGJFfgu5BYLAvS3HU9wbdGfRomb8i09mOmGe/EADzqDPZ6afleQTVDAo0PPA2Z9PIL7pSfBm83ZR+K+3NnZcDe5usFXSqSC7QW3ntzzQcWW6Wic4ALHFAiFGEwJKHodudtL+Zbo+CdIkXkDrvF62TrBcj7/r4nvpNsCpuj85RYupKb8+NA/zpWcgCGRu+19UNNjmfK/zAgMBAAECggEAfIcD9HMiHmgjfqezU5MpzT3gogn+Bw6UI7PrM9vwPfBCRjV0fIsRCc28sEaAJGOoEpi30oAvrCjUyQSnPwiVpFZOCAfeUuyvrXL6N3DbcvUGucQET0BFRtwuSyq0UA5E8UVw6Ww41IP3nQPK10guM3S3OypLBJ9qURW3m9tvRYKUYQxpLLzexsnriux3gU/wDAkQC1q9I6vfIHxCk1pbrbWbxBeBtdSSisI16IIXoSTz6T78ekIkIVI3Db/BKnaFO0NtAj52Way2+28OX31wezrh3ePKb6Mcsv8/z9i2OC3EbY3vbi59JvrxovkynrPrhCQ15pMQvCaZPKitGms1cQKBgQDc1+qc9JS7mB75RxMn8PccZ3ZSSxQ9mysWp8FuDdH+edC0La/mMBqWCx+3yPpwrcZwMiRsPdoeaKQfpgzFYygC8BkdEiC5g5tmeaDFeLwiWgRxKdqwTPgnz34DnKHApSHAH4myX7iCRY0cQElB1KTglyy5EsnM4wTx0yJzNDmnmwKBgQDG71A2vbgcxKgW1PXfDzhYgfD/jsACP3OHeRMKVsRB9saOmq0syZtGJMtvI/rVBn/WO72US9pWw/jKM0tsURqj2d1ZduaPz9tv8EE6kk8H/jrkoeAVvXKu+AUvF/bhEPPsxgeTOOIVNS4daaBGgPqYertpCi0dxtOYmdy2IzjaiQKBgQDBszf6lqNlrtVr+yUYIUf8x9qF74g/SLwQUO9dog2P0DR39KKVmZeYBwW44zSWZDTq72/26IFJrqpVgAUvk/riKMk+MEo3rPE+fmu/CFirIJ1IzFcdz0TRVjLG5DkTiUMDCiZyJ3bj/DD6mIAol2ROAQqfAZWyeWQ63t8WgLYZBQKBgQC5Xo4UNDy3MdifTdm9/GS4tHxo5g+tCIsSlZNUcv11qgnjH+Z2cXYqqmaWLaSxk9jTO9+vq+7MIthVMe76A6kbPQuxLcYyA7GqYOmnNmZGQHOIT/6Kw3l16M6Lz3zQxAdHfk/Ys4yXznImHiKnD9By/QpdGopn0Lmi3Nx5K+DyYQKBgQCRUcaLJAKEqSkmzVUTEzUYsgUOVeEGNz2wI3dRJ2gMwz9RCPYIDJWblcP5dZOiDS7CAITTUS+hGKqHb1PqVNvHJTazOquL0gwl99nK0zqhG7ZCwPjNzwt5osYtWbUl/foNhGKDUCCMbsf46ORSdQWwkMTwQrvOR4pbP7jViCu7bg==
# 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
# alipay_public_key: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhX8wJNSoM9YuPSPHmlzXNrEz8N+cHCSJUuk5n2IWNjz6kv/TlKn5D+nu21FDQdX8L0Arplq8M/ne1tuGDiwZo27A3OuOn8JLoKtBe+7C3IasqkezhxyRDuEYg8nRfirMS7HIzCc3P4HAqecp0N/DNEemLxodKdsvBbYHh+7zsRCm553CK01aIp3pfPj7bdtH3L4L192/MH66PpUvNszCt4Uk75qBKH1/xK07YeJ/nFBheaNlPrip3IhXkCHvM7ByT2sY9oLnu5XyZplm30vG8YpZoE0+yWm58qBAWTyacJvxXe9Gbn6qia0BU38FodF0IYSbTikQ/jdA/+6pYYmZawIDAQAB
alipay_public_key: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhX8wJNSoM9YuPSPHmlzXNrEz8N+cHCSJUuk5n2IWNjz6kv/TlKn5D+nu21FDQdX8L0Arplq8M/ne1tuGDiwZo27A3OuOn8JLoKtBe+7C3IasqkezhxyRDuEYg8nRfirMS7HIzCc3P4HAqecp0N/DNEemLxodKdsvBbYHh+7zsRCm553CK01aIp3pfPj7bdtH3L4L192/MH66PpUvNszCt4Uk75qBKH1/xK07YeJ/nFBheaNlPrip3IhXkCHvM7ByT2sY9oLnu5XyZplm30vG8YpZoE0+yWm58qBAWTyacJvxXe9Gbn6qia0BU38FodF0IYSbTikQ/jdA/+6pYYmZawIDAQAB
# 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
# notify_url: http://122.14.50.6:8096/third/pay_receive/notify_ali
# notify_url: http://a23u767737.zicp.vip/pay_receive/notify_ali # 花生壳本机测试
notify_url: http://zgsccbs.com/third1/pay_receive/notify_ali
#notify_url: localhost:8611/pay_receive/returnUrl
# 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问
return_url: http://zgsccbs.com/third1/pay_receive/returnUrl
#return_url: localhost:8611/pay_receive/returnUrl
# 签名方式
sign_type: RSA2
# 字符编码格式
charset: utf-8
# 支付宝网关
gatewayUrl: https://openapi.alipay.com/gateway.do # 真实
# gatewayUrl: https://openapi.alipay.com/gateway.do # 沙箱
wechatpay:
# 公众账号ID
appID: wxa036be65443d937f
# APP的appid
app_appID: wx08952708744cff59
# 商户号
mchID: 1397269802
# API 密钥
key: zhongguoshichangchubanshe2019064
# 设备号,pc端填写WEB
device_info: WEB
# 终端IP,公司ip为122.14.50.6
spbill_create_ip: 39.107.230.131
# 扫码回调地址
#notify_url: http://122.14.50.6:8096/third/pay_receive/notify_wechat
notify_url: http://zgsccbs.com/third1/pay_receive/notify_wechat
#notify_url: localhost:8611/pay_receive/notify_wechat
yeepay:
# 商户编号
p1_MerId: 10012438171 # 生产
# p1_MerId:10012442782 # 测试
p4_Cur: CNY
# 回调地址
p8_Url: http://122.14.50.6:8096/third/pay_receive/notify_yee #测试
# p8_Url: http://rsks.class.com.cn/third/yeepay/notify #生产
pr_NeedResponse: 1
# 商户密钥
keyValue: 6J0a5CM554V5227c088IAFq8V69Nrcg6b640236Sy63hlD82D56y08n3P9kd #生产
# keyValue: mP42238826nuW64r7yh26DGK34o2L2m81L25RG32lD7Lo1058A7iJ28at6QS #测试
# 下单请求地址
requestURL: https://www.yeepay.com/app-merchant-proxy/node
# 订单查询请求地址
queryURL: https://cha.yeepay.com/app-merchant-proxy/command
# 退款请求地址
refundURL: https://cha.yeepay.com/app-merchant-proxy/command
# 退款查询请求地址
refundQueryURL: https://www.yeepay.com/app-merchant-proxy/node
# 订单取消请求地址
cancelOrderURL: https://cha.yeepay.com/app-merchant-proxy/command
forUrl: http://rsks.class.com.cn/
<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
server:
port: 8611
spring:
cloud:
config:
uri: http://localhost:8388 #配置中心地址
name: third1
profile: prod
label: master
\ No newline at end of file
<?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/sc/third/" />
<property name="FILESIZE" value="10MB" />
<property name="MAXHISTORY" value="60" />
<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 根目录 -->
<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
<script>
window.location.href="http://zgsccbs.com/center/index.html/#/userCenterTemp";
</script>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论