合并代码

dev-discount
袁野 3 years ago
parent 9b8f834d54
commit 2ed7494790
  1. 6
      hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java
  2. 10
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  3. 7
      hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java
  4. 3
      hai-service/src/main/java/com/hai/service/OutRechargePriceService.java
  5. 18
      hai-service/src/main/java/com/hai/service/impl/BsConfigServiceImpl.java
  6. 46
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  7. 4
      hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java
  8. 1
      pom.xml
  9. 45
      v1/pom.xml
  10. 28
      v1/src/main/java/com/V1Application.java
  11. 128
      v1/src/main/java/com/v1/config/AuthConfig.java
  12. 24
      v1/src/main/java/com/v1/config/ConfigListener.java
  13. 49
      v1/src/main/java/com/v1/config/CorsConfig.java
  14. 26
      v1/src/main/java/com/v1/config/MultipartConfig.java
  15. 109
      v1/src/main/java/com/v1/config/RedisConfig.java
  16. 4
      v1/src/main/java/com/v1/config/SignatureConfig.java
  17. 47
      v1/src/main/java/com/v1/config/SwaggerConfig.java
  18. 13
      v1/src/main/java/com/v1/config/SysConfig.java
  19. 19
      v1/src/main/java/com/v1/config/SysConst.java
  20. 56
      v1/src/main/resources/dev/application.yml
  21. 0
      v1/src/main/resources/dev/config.properties
  22. 72
      v1/src/main/resources/dev/logback.xml
  23. 56
      v1/src/main/resources/pre/application.yml
  24. 0
      v1/src/main/resources/pre/config.properties
  25. 72
      v1/src/main/resources/pre/logback.xml
  26. 74
      v1/src/main/resources/prod/application.yml
  27. 0
      v1/src/main/resources/prod/config.properties
  28. 72
      v1/src/main/resources/prod/logback.xml

@ -188,7 +188,7 @@ public class OutRechargePriceController {
object.put("integralDiscount" , new BigDecimal(0)); object.put("integralDiscount" , new BigDecimal(0));
} }
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(object.getLong("id")); OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(object.getLong("id") , null);
if (outRechargePrice == null) { if (outRechargePrice == null) {
log.error("OutRechargePriceController -> updatePrice() error!"); log.error("OutRechargePriceController -> updatePrice() error!");
@ -225,7 +225,7 @@ public class OutRechargePriceController {
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { public ResponseData findById(@RequestParam(value = "id", required = true) Long id) {
try { try {
OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id); OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id , null);
return ResponseMsgUtil.success(outRechargePriceModel); return ResponseMsgUtil.success(outRechargePriceModel);
} catch (Exception e) { } catch (Exception e) {
@ -258,7 +258,7 @@ public class OutRechargePriceController {
SessionObject sessionObject = userCenter.getSessionObject(request); SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id")); OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id") , null);
if (object.getInteger("status") == 1 && outRechargePrice.getRechargePlatform().contains("-2-") && outRechargePrice.getGoodsId() == null) { if (object.getInteger("status") == 1 && outRechargePrice.getRechargePlatform().contains("-2-") && outRechargePrice.getGoodsId() == null) {
log.error("OutRechargePriceController -> editPriceStatus() error!"); log.error("OutRechargePriceController -> editPriceStatus() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅平台需要输入商品编码!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅平台需要输入商品编码!");

@ -48,9 +48,6 @@ public class OutRechargeOrderController {
@Resource @Resource
private SecConfigService secConfigService; private SecConfigService secConfigService;
@Resource
private HighUserCardService highUserCardService;
@Resource @Resource
private HighUserPayPasswordService highUserPayPasswordService; private HighUserPayPasswordService highUserPayPasswordService;
@ -91,7 +88,7 @@ public class OutRechargeOrderController {
String rechargeContent = object.getString("rechargeContent"); String rechargeContent = object.getString("rechargeContent");
// 查询产品详情 // 查询产品详情
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId); OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId , null);
Map<String, Object> listMap = new HashMap<>(); Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", "3"); listMap.put("productType", "3");
@ -174,6 +171,11 @@ public class OutRechargeOrderController {
if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) { if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) {
// 判断用户积分是否够
if (object.getLong("integralNum") > userInfoModel.getHighUser().getGold()) {
log.error("HighOrderController --> addOrder() error!", "积分大于用户积分额度");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "用户积分" + userInfoModel.getHighUser().getGold());
}
// 积分抵扣金额 // 积分抵扣金额
BigDecimal integralDeductionPrice = BigDecimal.valueOf(object.getLong("integralNum") / 100); BigDecimal integralDeductionPrice = BigDecimal.valueOf(object.getLong("integralNum") / 100);

@ -88,10 +88,13 @@ public class OutRechargePriceController {
@RequestMapping(value = "/findById", method = RequestMethod.GET) @RequestMapping(value = "/findById", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据id查询详情") @ApiOperation(value = "根据id查询详情")
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { public ResponseData findById(
@RequestParam(value = "id", required = true) Long id ,
@RequestParam(value = "platformId", required = true) Integer platformId
) {
try { try {
OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id); OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id , platformId);
return ResponseMsgUtil.success(outRechargePriceModel); return ResponseMsgUtil.success(outRechargePriceModel);
} catch (Exception e) { } catch (Exception e) {

@ -3,6 +3,7 @@ package com.hai.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.entity.OutRechargePrice; import com.hai.entity.OutRechargePrice;
import com.hai.model.OutRechargePriceModel; import com.hai.model.OutRechargePriceModel;
import io.swagger.models.auth.In;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -34,7 +35,7 @@ public interface OutRechargePriceService {
* @Param [id] * @Param [id]
* @return com.hai.entity.OutRechargePrice * @return com.hai.entity.OutRechargePrice
**/ **/
OutRechargePriceModel findById(Long id); OutRechargePriceModel findById(Long id , Integer platformId);
/** /**
* @Author Sum1Dream * @Author Sum1Dream

@ -78,7 +78,7 @@ public class BsConfigServiceImpl implements BsConfigService {
public String getProductPayTypeByMap(Map<String, Object> map) { public String getProductPayTypeByMap(Map<String, Object> map) {
BsProductPayTypeExample example = new BsProductPayTypeExample(); BsProductPayTypeExample example = new BsProductPayTypeExample();
BsProductPayTypeExample.Criteria criteria = example.createCriteria(); BsProductPayTypeExample.Criteria criteria = example.createCriteria();
Integer platformId = MapUtils.getInteger(map , "platformId");
if (MapUtils.getInteger(map , "productType") != null) { if (MapUtils.getInteger(map , "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType")); criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType"));
} }
@ -92,10 +92,26 @@ public class BsConfigServiceImpl implements BsConfigService {
StringBuilder stringName = new StringBuilder(); StringBuilder stringName = new StringBuilder();
StringBuilder string = new StringBuilder(); StringBuilder string = new StringBuilder();
// 1:支付宝 2:微信 3:汇联通工会卡 4:银联 5:银联分期
for (BsProductPayType productPayType : list) { for (BsProductPayType productPayType : list) {
if (platformId != null) {
if (platformId == 1 || platformId == 2) {
if (productPayType.getPayTypeId() == 2 || productPayType.getPayTypeId() == 3) {
stringName.append(productPayType.getPayTypeName()).append(",");
string.append(productPayType.getPayTypeId()).append(",");
}
} else if (platformId == 3) {
if (productPayType.getPayTypeId() == 4 || productPayType.getPayTypeId() == 5) {
stringName.append(productPayType.getPayTypeName()).append(","); stringName.append(productPayType.getPayTypeName()).append(",");
string.append(productPayType.getPayTypeId()).append(","); string.append(productPayType.getPayTypeId()).append(",");
} }
}
} else {
stringName.append(productPayType.getPayTypeName()).append(",");
string.append(productPayType.getPayTypeId()).append(",");
}
}
if (MapUtils.getInteger(map , "returnType") == 1) { if (MapUtils.getInteger(map , "returnType") == 1) {
return string.toString(); return string.toString();

@ -178,25 +178,31 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRES_NEW)
public void cancelOrder(Long orderId) { public void cancelOrder(Long orderId) {
OutRechargeOrder order = findByOrderId(orderId); OutRechargeOrder order = findByOrderId(orderId);
// if (order != null && order.getStatus() == 1) { if (order != null && order.getPayStatus() == 101) {
// order.setStatus(4); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
// order.setCancelTime(new Date()); order.setPayStatus(104);
// order.setCancelTime(new Date());
// if (order.getMemDiscountId() != null) {
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); if (order.getMemDiscountId() != null) {
// if (rel != null) { HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 if (rel != null) {
// rel.setUseTime(null); rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
// highDiscountUserRelService.updateDiscountUserRel(rel); rel.setUseTime(null);
// highDiscountUserRelService.updateDiscountUserRel(rel);
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
// code.setStatus(2); HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
// highDiscountAgentCodeService.updateCode(code); code.setStatus(2);
// } highDiscountAgentCodeService.updateCode(code);
// } }
// }
// updateOrder(order);
// } if (order.getIntegralNum() != null) {
// 积分返回
highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId());
}
updateOrder(order);
}
} }
@ -512,7 +518,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品 // 查询充值产品
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId()); OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId() , null);
// 查询充值子订单 // 查询充值子订单
Map<String, Object> childOrderMap = new HashMap<>(); Map<String, Object> childOrderMap = new HashMap<>();

@ -71,7 +71,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
@Override @Override
public OutRechargePriceModel findById(Long id) { public OutRechargePriceModel findById(Long id , Integer platformId) {
OutRechargePrice outRechargePrice = outRechargePriceMapper.selectByPrimaryKey(id); OutRechargePrice outRechargePrice = outRechargePriceMapper.selectByPrimaryKey(id);
@ -82,6 +82,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
listMap.put("productType", "3"); listMap.put("productType", "3");
listMap.put("returnType", 1); listMap.put("returnType", 1);
listMap.put("sourceId", outRechargePrice.getId()); listMap.put("sourceId", outRechargePrice.getId());
listMap.put("platformId", platformId);
outRechargePriceModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount()); outRechargePriceModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount());
outRechargePriceModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap)); outRechargePriceModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap));
@ -89,6 +90,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
return outRechargePriceModel; return outRechargePriceModel;
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
public void insertRechargePrice(JSONObject object) { public void insertRechargePrice(JSONObject object) {

@ -67,6 +67,7 @@
<module>hai-schedule</module> <module>hai-schedule</module>
<module>hai-order</module> <module>hai-order</module>
<module>hai-msg</module> <module>hai-msg</module>
<module>v1</module>
</modules> </modules>

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.hai</groupId>
<artifactId>hai-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.hgj</groupId>
<artifactId>hai-v1</artifactId>
<dependencies>
<dependency>
<groupId>com.hai</groupId>
<artifactId>hai-service</artifactId>
<version>PACKT-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources/${env}</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,28 @@
package com;
import com.hai.common.utils.SpringContextUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
// @ComponentScan
@EnableTransactionManagement
@EnableScheduling
@ServletComponentScan
@EnableAspectJAutoProxy(proxyTargetClass = true)
@MapperScan("com.hai.dao")
public class V1Application
{
public static void main( String[] args )
{
ApplicationContext app = SpringApplication.run(V1Application.class, args);
SpringContextUtil.setApplicationContext(app);
}
}

@ -0,0 +1,128 @@
package com.v1.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("/websocket/*")
;
}
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.v1.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.v1.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.v1.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.v1.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,4 @@
package com.v1.config;
public class SignatureConfig {
}

@ -0,0 +1,47 @@
package com.v1.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,13 @@
package com.v1.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 {
}

@ -0,0 +1,19 @@
package com.v1.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: 9902
servlet:
context-path: /v1
#配置是否为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,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,56 @@
server:
port: 9902
servlet:
context-path: /v1
#配置是否为debug模式,debug模式下,不开启权限校验
debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://122.9.135.148:3306/hsg?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: 1
host: 139.159.177.244
port: 36379
password: HF123456.Redis
timeout: 1000
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,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,74 @@
server:
port: 9902
servlet:
context-path: /v1
#配置是否为debug模式,debug模式下,不开启权限校验
debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://192.168.0.63:21100/hsg?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
username: hsg
password: HUfukeji123456!@#
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: 127.0.0.1
port: 36379
password: HF123456.Redis
timeout: 1000
jedis:
pool:
max-active: 20
max-wait: -1
max-idle: 10
min-idle: 0
#thymelea模板配置
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML5
encoding: UTF-8
#热部署文件,页面不产生缓存,及时更新
cache: false
#配置日期返回至前台为时间戳
jackson:
serialization:
write-dates-as-timestamps: true
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
content-type: text/html
mode: HTML5
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,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>
Loading…
Cancel
Save