新增订单推送

dev-discount
袁野 3 years ago
parent c8f129252c
commit 3791f2279a
  1. 128
      hai-msg/src/main/java/com/msg/config/AuthConfig.java
  2. 24
      hai-msg/src/main/java/com/msg/config/ConfigListener.java
  3. 49
      hai-msg/src/main/java/com/msg/config/CorsConfig.java
  4. 26
      hai-msg/src/main/java/com/msg/config/MultipartConfig.java
  5. 109
      hai-msg/src/main/java/com/msg/config/RedisConfig.java
  6. 47
      hai-msg/src/main/java/com/msg/config/SwaggerConfig.java
  7. 51
      hai-msg/src/main/java/com/msg/config/SysConfig.java
  8. 19
      hai-msg/src/main/java/com/msg/config/SysConst.java
  9. 56
      hai-msg/target/classes/application.yml
  10. BIN
      hai-msg/target/classes/com/MsgApplication.class
  11. BIN
      hai-msg/target/classes/com/msg/config/AuthConfig$1.class
  12. BIN
      hai-msg/target/classes/com/msg/config/AuthConfig.class
  13. BIN
      hai-msg/target/classes/com/msg/config/ConfigListener.class
  14. BIN
      hai-msg/target/classes/com/msg/config/CorsConfig.class
  15. BIN
      hai-msg/target/classes/com/msg/config/MultipartConfig.class
  16. BIN
      hai-msg/target/classes/com/msg/config/RedisConfig.class
  17. BIN
      hai-msg/target/classes/com/msg/config/SwaggerConfig.class
  18. BIN
      hai-msg/target/classes/com/msg/config/SysConfig.class
  19. BIN
      hai-msg/target/classes/com/msg/config/SysConst.class
  20. BIN
      hai-msg/target/classes/com/msg/controller/HighMegController.class
  21. 4
      hai-msg/target/classes/config.properties
  22. 72
      hai-msg/target/classes/logback.xml
  23. BIN
      hai-msg/target/hai-msg-1.0-SNAPSHOT.jar
  24. BIN
      hai-msg/target/hai-msg-1.0-SNAPSHOT.jar.original
  25. 4
      hai-msg/target/maven-archiver/pom.properties
  26. 11
      hai-msg/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  27. 10
      hai-msg/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  28. 0
      hai-msg/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst

@ -0,0 +1,128 @@
package com.msg.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.hai.common.security.UserCenter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@Configuration
public class AuthConfig implements WebMvcConfigurer {
private static Logger log = LoggerFactory.getLogger(AuthConfig.class);
@Autowired
private UserCenter userCenter;
/**
* 获取配置文件debug变量
*/
@Value("${debug}")
private boolean debug = false;
/**
* 解决18位long类型数据转json失去精度问题
* @param converters
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters){
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = jsonConverter.getObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
objectMapper.registerModule(simpleModule);
converters.add(jsonConverter);
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getParameter("Authorization");
if (StringUtils.isBlank(token)) {
token = request.getHeader("Authorization");
}
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
userCenter.refreshCookie(request, response);
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/test/*")
;
}
public String getIpAddress(HttpServletRequest request) {
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
}

@ -0,0 +1,24 @@
package com.msg.config;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
@WebListener
public class ConfigListener implements ServletContextListener {
@Autowired
private SysConfig sysConfig;
@Override
public void contextInitialized(ServletContextEvent sce) {
SysConst.setSysConfig(sysConfig);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}

@ -0,0 +1,49 @@
package com.msg.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName CorsConfig
* @Description: TODO ()
* @Author 胡锐
* @Date 2020/12/16
**/
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "DELETE", "PUT")
.maxAge(3600);
}
private CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
List<String> list = new ArrayList<>();
list.add("*");
corsConfiguration.setAllowedOrigins(list);
/*
// 请求常用的三种配置,*代表允许所有,当时你也可以自定义属性(比如header只能带什么,只能是post方式等等)
*/
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
return corsConfiguration;
}
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig());
return new CorsFilter(source);
}
}

@ -0,0 +1,26 @@
package com.msg.config;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement;
@Configuration
public class MultipartConfig {
/**
* 文件上传配置
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//文件最大
factory.setMaxFileSize("300MB"); //KB,MB
//设置总上传数据总大小
factory.setMaxRequestSize("350MB");
return factory.createMultipartConfig();
}
}

@ -0,0 +1,109 @@
package com.msg.config;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@EnableCaching //开启注解
public class RedisConfig extends CachingConfigurerSupport {
/**
* retemplate相关配置
* @param factory
* @return
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
/**
* 对hash类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
/**
* 对redis字符串类型数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForValue();
}
/**
* 对链表类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
/**
* 对无序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
/**
* 对有序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}

@ -0,0 +1,47 @@
package com.msg.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
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;
/**
* SwaggerConfig.java
* 项目名称:
* :
* 类名称: SwaggerConfig.java
* 类描述: 构建restful api接口文档
* 创建人:
* 创建时间: 2017 下午4:23:45
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
/**
* 描述api的基本信息
* 基本信息会展现在文档页面中
* @return [api的基本信息]
*/
ApiInfo apiInfo()
{
return new ApiInfoBuilder().title("hgj-BWeb").description("提供给管理平台的接口").termsOfServiceUrl("").version("1.0.0")
.contact(new Contact("", "", "")).build();
}
@Bean
public Docket customImplementation()
{
return new Docket(DocumentationType.SWAGGER_2).select()
.apis(RequestHandlerSelectors.basePackage("com"))
.build().directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class).apiInfo(apiInfo());
}
}

@ -0,0 +1,51 @@
package com.msg.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Component("sysConfig")
@ConfigurationProperties
@PropertySource("classpath:/config.properties")
public class SysConfig {
private String fileUrl;
private String cmsPath;
private String agentQrCode;
private String agentQrCodeWxUrl;
public String getAgentQrCodeWxUrl() {
return agentQrCodeWxUrl;
}
public void setAgentQrCodeWxUrl(String agentQrCodeWxUrl) {
this.agentQrCodeWxUrl = agentQrCodeWxUrl;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getCmsPath() {
return cmsPath;
}
public void setCmsPath(String cmsPath) {
this.cmsPath = cmsPath;
}
public String getAgentQrCode() {
return agentQrCode;
}
public void setAgentQrCode(String agentQrCode) {
this.agentQrCode = agentQrCode;
}
}

@ -0,0 +1,19 @@
package com.msg.config;
public class SysConst {
private static SysConfig sysConfig;
public static void setSysConfig(SysConfig arg){
sysConfig = arg;
}
public static SysConfig getSysConfig(){
if (null == sysConfig) {
//防止空指针异常
sysConfig = new SysConfig();
return sysConfig;
}
return sysConfig;
}
}

@ -0,0 +1,56 @@
server:
port: 9901
servlet:
context-path: /msg
#配置是否为debug模式,debug模式下,不开启权限校验
debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
filters: stat
maxActive: 10
initialSize: 5
maxWait: 60000
minIdle: 5
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20
redis:
database: 0
host: 139.159.177.244
port: 36379
password: HF123456.Redis
timeout: 36000000
jedis:
pool:
max-active: 20
max-wait: -1
max-idle: 10
min-idle: 0
#配置日期返回至前台为时间戳
jackson:
serialization:
write-dates-as-timestamps: true
mybatis:
mapperLocations:
- classpath*:sqlmap*/*.xml
type-aliases-package:
org.springboot.sample.entity
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql

@ -0,0 +1,4 @@
fileUrl=/home/project/hsg/filesystem
cmsPath=/home/project/hsg/filesystem/cmsPath
agentQrCode=/home/project/hsg/filesystem/agentQrCode
agentQrCodeWxUrl=https://hsgcs.dctpay.com/wx/?action=ic&id=

@ -0,0 +1,72 @@
<configuration>
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="baselog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/base.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/base.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="daolog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/dao.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/dao.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="errorlog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/error.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/error.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="com.hai" level="DEBUG">
<appender-ref ref="baselog" />
</logger>
<logger name="com.hai.dao" level="DEBUG">
<appender-ref ref="daolog" />
</logger>
<logger name="com.hai" level="ERROR">
<appender-ref ref="errorlog" />
</logger>
</configuration>

@ -0,0 +1,4 @@
#Created by Apache Maven 3.8.2
version=1.0-SNAPSHOT
groupId=com.hgj
artifactId=hai-msg

@ -0,0 +1,11 @@
com/msg/config/RedisConfig.class
com/msg/config/MultipartConfig.class
com/msg/config/AuthConfig.class
com/msg/config/SysConst.class
com/MsgApplication.class
com/msg/config/SysConfig.class
com/msg/controller/HighMegController.class
com/msg/config/SwaggerConfig.class
com/msg/config/AuthConfig$1.class
com/msg/config/ConfigListener.class
com/msg/config/CorsConfig.class

@ -0,0 +1,10 @@
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/controller/HighMegController.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/SysConst.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/CorsConfig.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/RedisConfig.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/SwaggerConfig.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/ConfigListener.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/SysConfig.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/MultipartConfig.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/msg/config/AuthConfig.java
/Volumes/work/code/high-work/high-service/hai-msg/src/main/java/com/MsgApplication.java
Loading…
Cancel
Save