| @@ -28,28 +28,12 @@ | |||||
| <artifactId>mybatis-multi-tenancy</artifactId> | <artifactId>mybatis-multi-tenancy</artifactId> | ||||
| <version>1.0</version> | <version>1.0</version> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-mp</artifactId> | |||||
| <version>${weixin-java-mp.version}</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-open</artifactId> | |||||
| <version>${weixin-java-open.version}</version> | |||||
| </dependency> | |||||
| <dependency> | <dependency> | ||||
| <groupId>commons-fileupload</groupId> | <groupId>commons-fileupload</groupId> | ||||
| <artifactId>commons-fileupload</artifactId> | <artifactId>commons-fileupload</artifactId> | ||||
| <version>1.3.3</version> | <version>1.3.3</version> | ||||
| </dependency> | </dependency> | ||||
| <dependency> | |||||
| <groupId>com.google.zxing</groupId> | |||||
| <artifactId>core</artifactId> | |||||
| <version>3.3.3</version> | |||||
| </dependency> | |||||
| </dependencies> | </dependencies> | ||||
| <build> | <build> | ||||
| @@ -13,6 +13,9 @@ import com.iformall.service.WxTagsService; | |||||
| import com.iformall.shiro.UserSession; | import com.iformall.shiro.UserSession; | ||||
| import org.apache.shiro.SecurityUtils; | import org.apache.shiro.SecurityUtils; | ||||
| import org.apache.shiro.session.Session; | import org.apache.shiro.session.Session; | ||||
| import org.apache.shiro.session.UnknownSessionException; | |||||
| import org.apache.shiro.subject.Subject; | |||||
| import org.apache.shiro.util.ThreadContext; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -91,33 +94,33 @@ public class AsyncTask { | |||||
| List<CUserBaseInfoT> successList = datalist.getList(); | List<CUserBaseInfoT> successList = datalist.getList(); | ||||
| List<CUserBaseInfoT> failList = datalist.getFailList(); | List<CUserBaseInfoT> failList = datalist.getFailList(); | ||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| int total = successList.size() + failList.size(); | int total = successList.size() + failList.size(); | ||||
| int all_success = successList.size(); | int all_success = successList.size(); | ||||
| int all_fail = failList.size(); | int all_fail = failList.size(); | ||||
| //添加到redis里 | //添加到redis里 | ||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, false); | |||||
| logger.info("验证通过的数量: " + successList.size()); | |||||
| logger.info("验证未通过的数量: " + failList.size()); | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||||
| try { | |||||
| successList.parallelStream().forEach(uBase -> { | |||||
| // 异步无法获取到原有的session,所以再注入一下session | |||||
| Session session = SecurityUtils.getSubject().getSession(); | |||||
| session.setAttribute(UserSession.userInfo, user); | |||||
| session.setAttribute(UserSession.userId, user.getId()); | |||||
| session.setAttribute(UserSession.tenantId, tenantId); | |||||
| wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase); | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:"+e.getMessage()); | |||||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||||
| if(successList.size() > 0) { | |||||
| WxTags wxTagsQ = new WxTags(); | |||||
| List<WxTags> tagList = wxTagsService.findList(wxTagsQ); | |||||
| try { | |||||
| successList.parallelStream().forEach(uBase -> { | |||||
| try { | |||||
| wxCUserBasicInfoService.importOneMem(tenantId, importKey, tagList, uBase); | |||||
| } catch (UnknownSessionException ue) { | |||||
| logger.error("session :"+ue.getMessage()); | |||||
| } | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||||
| e.printStackTrace(); | |||||
| logger.error("导入模板失败:"+e.getMessage()); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -17,7 +17,7 @@ public class TenantInfoImpl implements TenantInfo { | |||||
| try { | try { | ||||
| tenantId = (String) SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId); | tenantId = (String) SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId); | ||||
| } catch (InvalidSessionException e) { | } catch (InvalidSessionException e) { | ||||
| logger.error(e.getMessage()); | |||||
| logger.error("InvalidSession: " + e.getMessage()); | |||||
| } | } | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -57,27 +57,6 @@ aws: | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | ||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | jasypt: | ||||
| encryptor: | encryptor: | ||||
| password: oRqdnDbK5pj3eMmB | password: oRqdnDbK5pj3eMmB | ||||
| @@ -53,29 +53,6 @@ aws: | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | ||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| @@ -53,27 +53,6 @@ aws: | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | ||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | ||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | fm: | ||||
| exception: true | exception: true | ||||
| @@ -46,7 +46,7 @@ | |||||
| `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, | `tenant_id`,`filepath`,`status`,`contract_number`,`deposit`,`pay_date`,`is_del`,`merchant_name`, | ||||
| `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`, | `brand`,`business_id`,`shop_type`,`shop_id`,`updatetime`,`createtime`,`link_person`,`link_phone`, | ||||
| `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, | `pay_account`,`filename`,`lease`,`type`,`revenue`,`adjust_ratio`,`adjust_period`,`pay_ratio`, | ||||
| `start_date`,`end_date`,`apply_status`,`bank_name`,'rent_shop_type' | |||||
| `start_date`,`end_date`,`apply_status`,`bank_name`,`rent_shop_type` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -80,7 +80,7 @@ | |||||
| <if test=" null != type ">and `type` = #{type}</if> | <if test=" null != type ">and `type` = #{type}</if> | ||||
| <if test=" null != startDate ">and `start_date` = #{startDate}</if> | <if test=" null != startDate ">and `start_date` = #{startDate}</if> | ||||
| <if test=" null != endDate ">and `end_date` = #{endDate}</if> | <if test=" null != endDate ">and `end_date` = #{endDate}</if> | ||||
| <if test=" null != rentShopType ">and `rent_shop_type` = #{rentShopType}</if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| @@ -151,7 +151,7 @@ | |||||
| select s.id,s.shop_number shopNumber,s.build_area buildArea, | select s.id,s.shop_number shopNumber,s.build_area buildArea, | ||||
| s.img_url imgUrl,s.operation_area operationArea, | s.img_url imgUrl,s.operation_area operationArea, | ||||
| s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId, | s.status,b.building_name building,f.floor_name floor,m.`name` merchantName,m.id merchantId, | ||||
| m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone | |||||
| m.link_person linkPerson,m.link_phone linkPhone,s.manager,s.manager_phone managerPhone, | |||||
| s.type,s.point_type pointType | s.type,s.point_type pointType | ||||
| from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0 | from wx_shop s left join wx_merchant_shop ms on ms.shop_id=s.id and ms.is_del=0 | ||||
| left join wx_merchant m on ms.merchant_id=m.id | left join wx_merchant m on ms.merchant_id=m.id | ||||
| @@ -0,0 +1,50 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||||
| <modelVersion>4.0.0</modelVersion> | |||||
| <parent> | |||||
| <artifactId>mallink</artifactId> | |||||
| <groupId>com.iformall</groupId> | |||||
| <version>1.0</version> | |||||
| </parent> | |||||
| <artifactId>mallinkWechatOpen</artifactId> | |||||
| <properties> | |||||
| <weixin-java-mp.version>3.3.0</weixin-java-mp.version> | |||||
| <weixin-java-open.version>3.3.0</weixin-java-open.version> | |||||
| </properties> | |||||
| <dependencies> | |||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-open</artifactId> | |||||
| <version>${weixin-java-open.version}</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.github.binarywang</groupId> | |||||
| <artifactId>weixin-java-mp</artifactId> | |||||
| <version>${weixin-java-mp.version}</version> | |||||
| </dependency> | |||||
| <dependency> | |||||
| <groupId>com.google.zxing</groupId> | |||||
| <artifactId>core</artifactId> | |||||
| <version>3.3.3</version> | |||||
| </dependency> | |||||
| </dependencies> | |||||
| <build> | |||||
| <plugins> | |||||
| <plugin> | |||||
| <groupId>org.springframework.boot</groupId> | |||||
| <artifactId>spring-boot-maven-plugin</artifactId> | |||||
| <configuration> | |||||
| <executable>true</executable> | |||||
| </configuration> | |||||
| </plugin> | |||||
| </plugins> | |||||
| </build> | |||||
| </project> | |||||
| @@ -0,0 +1,33 @@ | |||||
| package com.iformall; | |||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.boot.SpringApplication; | |||||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||||
| import tk.mybatis.spring.annotation.MapperScan; | |||||
| /** | |||||
| * @author stormeye | |||||
| * @date 2019-01-14 | |||||
| */ | |||||
| @SpringBootApplication | |||||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||||
| @EnableSwagger2 | |||||
| @EnableEncryptableProperties | |||||
| public class WechatOpenApplication { | |||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | |||||
| SpringApplication.run(WechatOpenApplication.class, args); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.common; | |||||
| import tk.mybatis.mapper.common.BaseMapper; | |||||
| import tk.mybatis.mapper.common.IdsMapper; | |||||
| import tk.mybatis.mapper.common.Marker; | |||||
| import tk.mybatis.mapper.common.special.InsertListMapper; | |||||
| import java.io.Serializable; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2017-12-27 | |||||
| */ | |||||
| public interface CommonMapper<T, ID extends Serializable> extends BaseMapper<T>, IdsMapper<T>, InsertListMapper<T>, Marker { | |||||
| } | |||||
| @@ -0,0 +1,345 @@ | |||||
| package com.iformall.common; | |||||
| import java.text.MessageFormat; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2017-12-28. | |||||
| */ | |||||
| public enum ErrorCode { | |||||
| /** | |||||
| * 系统级别 | |||||
| * 1000-1999 | |||||
| */ | |||||
| SYS_SERVER_ERROR(1000, "服务器请求异常"), | |||||
| SYS_PARAMETER_ERROR(1001, "参数不合法"), | |||||
| SYS_PARAMETER_NOT_NULL(1002, "参数不能为空"), | |||||
| SYS_PARAMETER_TYPE_ERROR(1003, "参数类型异常"), | |||||
| SYS_PARAMETER_CAST_ERROR(1004, "参数转换异常"), | |||||
| SYS_PARAMETER_EMPTY_ERROR(1005, "参数转换异常"), | |||||
| SYS_BEAN_EMPTY_PROPERTY_ERROR(1006, "实体转换异常"), | |||||
| SYS_MEDIATYPE_NOT_SUPPORT(1007, "不支持的媒体类型"), | |||||
| SYS_NULLPOINTER_ERROR(1008, "空指针异常"), | |||||
| SYS_METHOD_NOT_SUPPORT(1009, "不支持的请求类型"), | |||||
| SYS_CLASSCAST_ERROR(1010, "类型转换异常"), | |||||
| SYS_NUMBER_FORMAT_ERROR(1011, "数字转化异常"), | |||||
| SYS_EXTEND_JSON_ERROR(1012, "JSON格式异常"), | |||||
| SYS_REPEAT_SUBMIT_EXCEPTION(1013, "请勿重复操作"), | |||||
| /** | |||||
| * 数据库 | |||||
| */ | |||||
| DB_FAIL(1045, "数据库访问出错"), | |||||
| /** | |||||
| * 网络 | |||||
| */ | |||||
| TOO_MANY_REQUEST(1050, "太多的请求访问"), | |||||
| LOGIN_DENIED(1051, "登录失败"), | |||||
| NET_TOKEN_INVALID(1052, "TOKEN无效"), | |||||
| NET_TOKEN_EMPTY(1053, "TOKEN不能为空"), | |||||
| /** | |||||
| * 业务级别 | |||||
| */ | |||||
| /** | |||||
| * 用户2000-2099 | |||||
| */ | |||||
| USER_IS_NOT_MEMBER(1989,"用户还未授权手机号成为会员"), | |||||
| USER_PHONE_IS_NOT_FOUND(1990,"手机号不存在"), | |||||
| USER_DEL_SELF(1991,"用户删除自己"), | |||||
| USER_NOT_ADMIN(1992,"用户非超管"), | |||||
| USER_NO_PERMISSION(1993,"用户无此权限"), | |||||
| USER_USE_ROLE(1994,"用户使用此角色"), | |||||
| USER_IS_EMPTY(2000, "用户不存在"), | |||||
| PASSWORD_ERROR(2001, "密码错误"), | |||||
| LOGIN_USER_OR_PWD_ERROR(2002, "用户名或密码错误"), | |||||
| USER_IS_LOCKED(2003, "用户已经被锁定不能登录,请与管理员联系"), | |||||
| NEW_USER_FAILD(2004, "创建新用户失败"), | |||||
| BUSER_NOT_IN_APP(2005, "用户不是此app用户"), | |||||
| KAPCHA_NOT_VALID(2006, "验证码已失效"), | |||||
| KAPCHA_NOT_EQUAL(2007, "验证码不正确"), | |||||
| USER_NAME_IS_FOUND(2008,"用户名已存在"), | |||||
| USER_PHONE_IS_FOUND(2009,"手机号已存在"), | |||||
| /** | |||||
| * 商场/商户 | |||||
| */ | |||||
| MALL_INFO_NOT_FOUND(2010, "商场信息没找到"), | |||||
| MERCHANT_INFO_NOT_FOUND(2011, "商户信息没找到"), | |||||
| MERCHANT_INFO_NOT_EQUAL(2012, "商户信息不对应"), | |||||
| MERCHANT_INFO_NOT_VALID(2013, "商户信息禁用"), | |||||
| /** | |||||
| * 券 | |||||
| */ | |||||
| COUPON_IS_EMPTY(2020, "此券不存在"), | |||||
| COUPON_IS_NOT_FREE(2021, "此券不免费"), | |||||
| COUPON_IS_TAKE_OFF(2022, "此券已作废"), | |||||
| COUPON_IS_EXPIRED(2023, "此券已过期"), | |||||
| COUPON_IS_SELL_OUT(2024, "此券已售罄"), | |||||
| COUPON_TYPE_IS_NOT_ACTIVE(2025, "此券不能用于主动领取"), | |||||
| COUPON_TYPE_IS_NOT_PASSIVE(2026, "此券不能用于定向投放"), | |||||
| COUPON_CHANNEL_IS_EXISTED(2027, "此券已投放过"), | |||||
| COUPON_CHANNEL_IS_TAKE_OFF(2031, "此券已下架"), | |||||
| COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), | |||||
| COUPON_SEND_IS_INVALID(2029, "此发券渠道不存在"), | |||||
| COUPON_SEND_IS_INVALID_TIME(2030, "发放时间不能晚于使用时间"), | |||||
| COUPON_MERCHANT_NOT_FOUND(2031, "卡券关联商户未发现"), | |||||
| PUSH_LIMIT_UP_TO_1DAYLIMIT(2040, "此用户一天内发券到达疲劳度限制"), | |||||
| PUSH_LIMIT_UP_TO_COUPONLIMIT(2041, "此用户发此券到达疲劳度限制"), | |||||
| PUSH_LIMIT_NOT_INRANG(2042, "不在疲劳度允许的时间段"), | |||||
| /** | |||||
| * 车流 2040 | |||||
| */ | |||||
| CAR_PARK_NOT_FOUND(2049, "车场未找到"), | |||||
| CAR_VENDOR_NOT_SUPPORT(2050, "不支持的停车厂家"), | |||||
| ETCP_LOGIN_FAIL(2051, "ETCP共同登录失败"), | |||||
| ETCP_BIND_FAIL(2052, "ETCP绑车牌失败"), | |||||
| ETCP_UNBIND_FAIL(2053, "ETCP解绑车牌失败"), | |||||
| ETCP_STOP_FEE_FAIL(2054, "ETCP停车费失败"), | |||||
| ETCP_QUAN_TEMP_FAIL(2055, "ETCP优免券模板失败"), | |||||
| ETCP_QUAN_SEND_FAIL(2056, "ETCP优免券发放失败"), | |||||
| ETCP_CMD_FAIL(2057, "ETCP网络异常"), | |||||
| TJD_BIND_FAIL(2060,"TJD绑车牌失败"), | |||||
| TJD_UNBIND_FAIL(2061,"TJD解绑车牌失败"), | |||||
| TJD_STOP_FEE_FAIL(2062, "TJD停车费失败"), | |||||
| TJD_DEDUCE_FEE_FAIL(2063, "TJD停车费抵扣失败"), | |||||
| /** | |||||
| * 券 | |||||
| */ | |||||
| GAME_NOT_FOUND(2070, "游戏未找到"), | |||||
| /** | |||||
| * 订单 | |||||
| */ | |||||
| REMAIN_IS_EMPTY(3000, "库存不足"), | |||||
| ORDER_IS_LIMITED(3001, "购买超限"), | |||||
| ORDER_IS_FAIL(3002, "订单失败"), | |||||
| ORDER_IS_NOT_FIND(3003, "订单不存在"), | |||||
| ORDER_IS_NOT_PAY(3004, "订单已不能进行支付"), | |||||
| ORDER_SAVE_ERR(3005,"订单保存失败"), | |||||
| ORDER_UPDATE_ERR(3006,"订单更新失败"), | |||||
| REMAIN_BACK_FAIL(3007, "库存恢复失败"), | |||||
| /** | |||||
| * 卡券 | |||||
| */ | |||||
| COUPON_ORDER_SAVE_ERR(3999, "卡券保存失败"), | |||||
| COUPON_ORDER_IS_NULL(4000, "卡券不存在"), | |||||
| COUPON_ORDER_IS_USED(4001, "卡券已核销"), | |||||
| COUPON_ORDER_IS_OVER_TIME(4002, "卡券已过期"), | |||||
| COUPON_ORDER_IS_INVALID(4003, "卡券已经作废"), | |||||
| COUPON_ORDER_BUSER_IS_NULL(4004, "卡券B端用户不存在"), | |||||
| COUPON_ORDER_MERANT_IS_NULL(4005, "卡券商户不存在"), | |||||
| /** | |||||
| * 卡 | |||||
| */ | |||||
| CARD_IS_NOT_FOUND(9001, "优惠卡不存在"), | |||||
| CARD_REMAIN_AMOUNT_IS_NOT_ENOUGH(9002, "优惠卡余额不足"), | |||||
| CARD_IS_NOT_COST(9003, "优惠卡未消费,退款请用卡券退款,钱直接退回购买人手里"), | |||||
| /** | |||||
| * 卡消费 | |||||
| */ | |||||
| CARD_SPEND_IS_PAID(9050, "卡消费已支付"), | |||||
| /** | |||||
| * 微信 | |||||
| */ | |||||
| SESSION_KEY_DECODE_ERR(11001, "session_key/openId解密失败"), | |||||
| NICK_NAME_DECODE_ERR(11002, "nickName,unionId解密失败"), | |||||
| PHONE_DECODE_ERR(11003, "Phone解密失败"), | |||||
| NICK_NAME_NOT_FOUND(11004, "nickName,unionId未授权"), | |||||
| PHONE_NOT_FOUND(11005, "Phone未授权"), | |||||
| PHONE_IS_ENCRYPTED(11006, "Phone已加密"), | |||||
| TEMPLATE_SEND_FAILED(11007, "模板消息发送失败"), | |||||
| WE_RUN_DATA_DECODE_ERR(11008, "运动信息解密失败"), | |||||
| /** | |||||
| * 支付 | |||||
| */ | |||||
| PAY_ORDER_REFUND(11994, "订单退款中"), | |||||
| PAY_ORDER_PAYING(11995, "订单支付中"), | |||||
| PAY_ORDER_NOT_PAY(11996, "订单未支付"), | |||||
| PAY_ORDER_CLOSED(11997, "订单已关闭"), | |||||
| PAY_ORDER_REVERSE(11998, "订单已撤销"), | |||||
| PAY_ORDER_NOT_FOUND(12000, "支付订单不存在"), | |||||
| PAY_ORDER_EXIST(12001, "支付订单已存在"), | |||||
| PAY_ORDER_ERROR(12002, "支付订单异常"), | |||||
| PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR(12003 , "支付验签失败"), | |||||
| PAY_ORDER_IS_ZERO(12004, "支付订单金额为0"), | |||||
| PAY_ORDER_IS_NOT_PAYMENT(12005, "不是支付订单"), | |||||
| PREPAY_ID_IS_EMPTY(12006, "prepay_id是空值"), | |||||
| PAY_ORDER_QUERY_ERROR(12007, "支付订单查询异常"), | |||||
| REFUND_ORDER_EXIST(12010, "退款订单已存在"), | |||||
| REFUND_PAY_ORDER_IS_NOT_EXIST(12011, "退款支付订单不存在"), | |||||
| REFUND_PAY_ORDER_IS_ZERO(12012, "退款支付订单金额为0"), | |||||
| REFUND_ORDER_ERROR(12013, "退款订单异常"), | |||||
| REFUND_ORDER_NOTIFY_CHECK_SIGN_ERROR(12014, "退款验签失败"), | |||||
| REFUND_ORDER_BUSER_IS_NULL(12015, "B端用户不存在"), | |||||
| REFUND_ORDER_BUSER_NOT_EQUAL(12016, "B端用户无操作权限"), | |||||
| APP_ID_NOT_FOUND(12020, "APPID没找到"), | |||||
| MCH_INFO_NOT_FOUND(12021, "微信商户平台信息没找到"), | |||||
| MCH_INFO_NOT_EQUAL(12022, "微信商户平台信息不对应"), | |||||
| API_KEY_NOT_FOUND(12023, "支付密钥未配置"), | |||||
| CERT_PATH_NOT_FOUND(12024, "双向证书未配置"), | |||||
| PROFIT_SHARING_REQUEST_FAILED(12030, "分账请求失败"), | |||||
| PROFIT_SHARING_APPLY_FAILED(12031, "分账业务失败"), | |||||
| PROFIT_SHARING_RETURN_INVALID(12032, "分账请求返回校验失败"), | |||||
| PROFIT_SHARING_RECEIVER_INVALID(12033, "分账接受方查寻无效"), | |||||
| PROFIT_SHARING_QUERY_REQUEST_FAILED(12034, "分账查询请求失败"), | |||||
| PROFIT_SHARING_QUERY_APPLY_FAILED(12035, "分账查询业务失败"), | |||||
| PROFIT_SHARING_QUERY_RETURN_INVALID(12036, "分账查询返回校验失败"), | |||||
| PROFIT_SHARING_RECEIVER_ADD_FAILED(12037, "分账账户添加失败"), | |||||
| PROFIT_SHARING_RECEIVER_DEL_FAILED(12038, "分账账户删除失败"), | |||||
| PROFIT_SHARING_NUM_UP_LIMIT(12039, "分账次数超限"), | |||||
| /** | |||||
| * 核销 | |||||
| */ | |||||
| VERIFY_ERROR(12050, "核销异常"), | |||||
| MSG_REPEAT_SEND(12061, "短信重新发送"), | |||||
| /** | |||||
| * 解单 | |||||
| */ | |||||
| DALIY_REPORT_VOLUME_TODAY_NULL(12070, "今日解单不存在"), | |||||
| DALIY_REPORT_VOLUME_WEEK_NULL(12071, "无解单数据"), | |||||
| /** | |||||
| * 模板消息 | |||||
| */ | |||||
| TEMPLATE_NOT_FOUND(12090, "模板不存在"), | |||||
| /** | |||||
| * | |||||
| * 短信 | |||||
| * | |||||
| * */ | |||||
| MSG_SERVER_NOT_FIND(12100,"您还未接入短信运营商,请联系平台管理员"), | |||||
| MSG_TEMPLATE_REPEAT(12101,"您添加的短信模板已存在"), | |||||
| MSG_SIGNATURE_CONTENT_ERROR(12102,"短信签名或内容错误"), | |||||
| MSG_TEMPLATE_CREATE_ERROR(12103,"创建模板失败"), | |||||
| MSG_VERIFY_CODE_NOT_FOUND(12104,"短信验证码不存在或失效"), | |||||
| MSG_TEMPLATE_NOT_FOUND(12105,"短信模板不存在"), | |||||
| MSG_REQUEST_PARAMS_ERROR(12106,"参数错误"), | |||||
| MSG_SEND_ERROR(12107,"发送短信失败"), | |||||
| MSG_METHOD_REQUEST_ERROR(12108,"接口请求错误"), | |||||
| MSG_PHONE_NOT_FOUND(12109,"请输入手机号"), | |||||
| MSG_SEND_WAY_CHOOSE_ERROR(12110,"请确定发送的方式"), | |||||
| MSG_SUM_ZERO(12111,"短信数量为0"), | |||||
| MSG_SUM_INSUFFICENT(12112,"短信数量不足"), | |||||
| MSG_NO_VALID_PHONE(12113,"没有可以发送的手机号"), | |||||
| MSG_SEND_INTERFACE_ERROR(12114,"短信运营商返回错误"), | |||||
| /** | |||||
| * 会员 | |||||
| */ | |||||
| MEM_IMPORT_ERR(13000, "模板导入失败,请检查数据,尝试重新导入"), | |||||
| MEM_SCORE_NOT_ENOUGH(13001, "成长值不够扣减值"), | |||||
| /** | |||||
| * 标签 | |||||
| */ | |||||
| TAGS_MATCHED_NULL(14000, "此标签没命中用户"), | |||||
| /** | |||||
| * 租赁合同 | |||||
| * */ | |||||
| RENT_CONTRACT_IS_NOT_FOUND(15000,"租赁合同不存在"), | |||||
| RENT_CONTRACT_IS_TERMINATED(15001,"租赁合同已终止"), | |||||
| RENT_CONTRACT_WITH_SHOP_IS_FOUND(15002,"店铺存在已关联的合同"), | |||||
| /** | |||||
| * 物业合同 | |||||
| * */ | |||||
| PROPERTY_CONTRACT_IS_NOT_FOUND(16000,"物业合同不存在"), | |||||
| /** | |||||
| * 租赁账单 | |||||
| * */ | |||||
| BILL_RENT_IS_NOT_FOUND(17000,"租赁账单不存在"), | |||||
| /** | |||||
| * 租赁押金账单 | |||||
| * */ | |||||
| BILL_RENT_DEPOSIT_IS_NOT_FOUND(18000,"租赁押金账单不存在"), | |||||
| /** | |||||
| * 物业账单 | |||||
| * */ | |||||
| BILL_PROPERTY_IS_NOT_FOUND(19000,"物业账单不存在"), | |||||
| /** | |||||
| * 物业押金账单 | |||||
| * */ | |||||
| BILL_PROPERTY_DEPOSIT_IS_NOT_FOUND(20000,"物业押金账单不存在"), | |||||
| /** | |||||
| * 日常费用账单 | |||||
| * */ | |||||
| BILL_ROUTINE_IS_NOT_FOUND(21000,"账单不存在"), | |||||
| BILL_UPDATE_FAILED(21001,"账单更新失败"), | |||||
| BILL_OWE_ZERO(21002,"账单欠缴为0"), | |||||
| BILL_PAY_ERROR(21003,"账单支付错误"), | |||||
| /** | |||||
| * 商铺 | |||||
| * */ | |||||
| SHOP_IS_NOT_FOUND(22000,"商铺不存在"), | |||||
| SHOP_IS_RENT(22001,"商铺已出租"), | |||||
| WIWIDE_INFO_NOT_FOUND(23001,"迈外迪信息未找到"), | |||||
| ; | |||||
| private int code; | |||||
| private String message; | |||||
| ErrorCode(int code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public int getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage(Object... param) { | |||||
| if (param.length == 0) { | |||||
| return message; | |||||
| } | |||||
| return MessageFormat.format(message, param); | |||||
| } | |||||
| public static ErrorCode getByCode(int code) { | |||||
| ErrorCode[] values = ErrorCode.values(); | |||||
| for (ErrorCode value : values) { | |||||
| if (value.getCode() == code) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,152 @@ | |||||
| package com.iformall.common; | |||||
| public class IdWorker { | |||||
| // ==============================Fields=========================================== | |||||
| /** 开始时间截 (2015-01-01) */ | |||||
| private final long twepoch = 1489111610226L; | |||||
| /** 机器id所占的位数 */ | |||||
| private final long workerIdBits = 5L; | |||||
| /** 数据标识id所占的位数 */ | |||||
| private final long dataCenterIdBits = 5L; | |||||
| /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */ | |||||
| private final long maxWorkerId = -1L ^ (-1L << workerIdBits); | |||||
| /** 支持的最大数据标识id,结果是31 */ | |||||
| private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits); | |||||
| /** 序列在id中占的位数 */ | |||||
| private final long sequenceBits = 12L; | |||||
| /** 机器ID向左移12位 */ | |||||
| private final long workerIdShift = sequenceBits; | |||||
| /** 数据标识id向左移17位(12+5) */ | |||||
| private final long dataCenterIdShift = sequenceBits + workerIdBits; | |||||
| /** 时间截向左移22位(5+5+12) */ | |||||
| private final long timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits; | |||||
| /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */ | |||||
| private final long sequenceMask = -1L ^ (-1L << sequenceBits); | |||||
| /** 工作机器ID(0~31) */ | |||||
| private long workerId; | |||||
| /** 数据中心ID(0~31) */ | |||||
| private long dataCenterId; | |||||
| /** 毫秒内序列(0~4095) */ | |||||
| private long sequence = 0L; | |||||
| /** 上次生成ID的时间截 */ | |||||
| private long lastTimestamp = -1L; | |||||
| ///////////////////////////////////////////////////////////////////////////////// | |||||
| private static class IdGenHolder { | |||||
| private static final IdWorker instance = new IdWorker(); | |||||
| } | |||||
| public static IdWorker get(){ | |||||
| return IdGenHolder.instance; | |||||
| } | |||||
| public IdWorker() { | |||||
| this(0L, 0L); | |||||
| } | |||||
| //==============================Constructors===================================== | |||||
| /** | |||||
| * 构造函数 | |||||
| * @param workerId 工作ID (0~31) | |||||
| * @param dataCenterId 数据中心ID (0~31) | |||||
| */ | |||||
| public IdWorker(long workerId, long dataCenterId) { | |||||
| if (workerId > maxWorkerId || workerId < 0) { | |||||
| throw new IllegalArgumentException(String.format("workerId can't be greater than %d or less than 0", maxWorkerId)); | |||||
| } | |||||
| if (dataCenterId > maxDataCenterId || dataCenterId < 0) { | |||||
| throw new IllegalArgumentException(String.format("dataCenterId can't be greater than %d or less than 0", maxDataCenterId)); | |||||
| } | |||||
| this.workerId = workerId; | |||||
| this.dataCenterId = dataCenterId; | |||||
| } | |||||
| // ==============================Methods========================================== | |||||
| /** | |||||
| * 获得下一个ID (该方法是线程安全的) | |||||
| * @return SnowflakeId | |||||
| */ | |||||
| public synchronized long nextId() { | |||||
| long timestamp = timeGen(); | |||||
| //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常 | |||||
| if (timestamp < lastTimestamp) { | |||||
| throw new RuntimeException( | |||||
| String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp)); | |||||
| } | |||||
| //如果是同一时间生成的,则进行毫秒内序列 | |||||
| if (lastTimestamp == timestamp) { | |||||
| sequence = (sequence + 1) & sequenceMask; | |||||
| //毫秒内序列溢出 | |||||
| if (sequence == 0) { | |||||
| //阻塞到下一个毫秒,获得新的时间戳 | |||||
| timestamp = tilNextMillis(lastTimestamp); | |||||
| } | |||||
| } | |||||
| //时间戳改变,毫秒内序列重置 | |||||
| else { | |||||
| sequence = 0L; | |||||
| } | |||||
| //上次生成ID的时间截 | |||||
| lastTimestamp = timestamp; | |||||
| //移位并通过或运算拼到一起组成64位的ID | |||||
| return ((timestamp - twepoch) << timestampLeftShift) // | |||||
| | (dataCenterId << dataCenterIdShift) // | |||||
| | (workerId << workerIdShift) // | |||||
| | sequence; | |||||
| } | |||||
| /** | |||||
| * 阻塞到下一个毫秒,直到获得新的时间戳 | |||||
| * @param lastTimestamp 上次生成ID的时间截 | |||||
| * @return 当前时间戳 | |||||
| */ | |||||
| protected long tilNextMillis(long lastTimestamp) { | |||||
| long timestamp = timeGen(); | |||||
| while (timestamp <= lastTimestamp) { | |||||
| timestamp = timeGen(); | |||||
| } | |||||
| return timestamp; | |||||
| } | |||||
| /** | |||||
| * 返回以毫秒为单位的当前时间 | |||||
| * @return 当前时间(毫秒) | |||||
| */ | |||||
| protected long timeGen() { | |||||
| return System.currentTimeMillis(); | |||||
| } | |||||
| //==============================Test============================================= | |||||
| /** 测试 */ | |||||
| public static void main(String[] args) { | |||||
| System.out.println(System.currentTimeMillis()); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| long startTime = System.nanoTime(); | |||||
| for (int i = 0; i < 50000; i++) { | |||||
| long id = idWorker.nextId(); | |||||
| System.out.println(id); | |||||
| System.out.println(String.valueOf(id)); | |||||
| System.out.println(String.valueOf(id).length()); | |||||
| } | |||||
| System.out.println((System.nanoTime()-startTime)/1000000+"ms"); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,32 @@ | |||||
| package com.iformall.common; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2018-01-05. | |||||
| */ | |||||
| public class Result { | |||||
| public int code; | |||||
| public String message; | |||||
| public static final int SUCCESS = 200; | |||||
| public static final int ERROR = 500; | |||||
| public static final int UNLOGIN = 701; | |||||
| public Result() { | |||||
| this.code = 200; | |||||
| this.message = "success"; | |||||
| } | |||||
| public Result(int code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Result(ErrorCode errorCode) { | |||||
| this.code = errorCode.getCode(); | |||||
| this.message = errorCode.getMessage(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,98 @@ | |||||
| package com.iformall.common; | |||||
| import java.beans.BeanInfo; | |||||
| import java.beans.Introspector; | |||||
| import java.beans.PropertyDescriptor; | |||||
| import java.util.ArrayList; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * @author chenkx | |||||
| * @date 2018-01-05. | |||||
| */ | |||||
| public class ResultData extends Result { | |||||
| public Object data; | |||||
| public ResultData() { | |||||
| super(); | |||||
| } | |||||
| public ResultData(Object data) { | |||||
| this(); | |||||
| this.data = data; | |||||
| } | |||||
| public static ResultData returnResultObject(int code) { | |||||
| String value = ErrorCode.getByCode(code).getMessage(); | |||||
| return new ResultData(code, value); | |||||
| } | |||||
| public ResultData(Enum<?>[] ens) { | |||||
| List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); | |||||
| for (Enum<?> en : ens) { | |||||
| Map<String, Object> map = enumToMap(en); | |||||
| list.add(map); | |||||
| } | |||||
| data = list; | |||||
| } | |||||
| private Map<String, Object> enumToMap(Enum<?> en) { | |||||
| Map<String, Object> map = new HashMap<>(); | |||||
| try { | |||||
| BeanInfo info = Introspector.getBeanInfo(en.getClass()); | |||||
| PropertyDescriptor[] descriptors = info.getPropertyDescriptors(); | |||||
| for (PropertyDescriptor property : descriptors) { | |||||
| if (property.getPropertyType().getName().equals(Class.class.getName())) { | |||||
| continue; | |||||
| } | |||||
| Object value = property.getReadMethod().invoke(en); | |||||
| map.put(property.getName(), value); | |||||
| } | |||||
| } catch (Exception ex) { | |||||
| throw new RuntimeException(ex); | |||||
| } | |||||
| return map; | |||||
| } | |||||
| public ResultData(int code, Exception e) { | |||||
| super(code, e.toString()); | |||||
| } | |||||
| public ResultData(int code, String message) { | |||||
| super(code, message); | |||||
| } | |||||
| public ResultData(int code, String message, Object data) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| this.data = data; | |||||
| } | |||||
| public ResultData(ErrorCode errorCode, Object data) { | |||||
| this.code = errorCode.getCode(); | |||||
| this.message = errorCode.getMessage(); | |||||
| this.data = data; | |||||
| } | |||||
| public ResultData(ErrorCode errorCode) { | |||||
| this.code = errorCode.getCode(); | |||||
| this.message = errorCode.getMessage(); | |||||
| } | |||||
| public HashMap<String, Object> toHashMap() { | |||||
| HashMap<String, Object> map = new HashMap<>(3); | |||||
| map.put("code", this.code); | |||||
| map.put("message", this.message); | |||||
| map.put("data", data); | |||||
| return map; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,52 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "aws") | |||||
| public class AwsProperty { | |||||
| // AWS ACCESS KEY | |||||
| private String access; | |||||
| private String secret; | |||||
| private String clientRegion; | |||||
| private String bucketName; | |||||
| public String getAccess() { | |||||
| return access; | |||||
| } | |||||
| public void setAccess(String access) { | |||||
| this.access = access; | |||||
| } | |||||
| public String getSecret() { | |||||
| return secret; | |||||
| } | |||||
| public void setSecret(String secret) { | |||||
| this.secret = secret; | |||||
| } | |||||
| public String getClientRegion() { | |||||
| return clientRegion; | |||||
| } | |||||
| public void setClientRegion(String clientRegion) { | |||||
| this.clientRegion = clientRegion; | |||||
| } | |||||
| public String getBucketName() { | |||||
| return bucketName; | |||||
| } | |||||
| public void setBucketName(String bucketName) { | |||||
| this.bucketName = bucketName; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||||
| import org.springframework.stereotype.Component; | |||||
| /** | |||||
| * @author Stormeye | |||||
| */ | |||||
| @Component | |||||
| @ConfigurationProperties(prefix = "pay") | |||||
| public class PayProperty { | |||||
| /** | |||||
| * 真实支付 | |||||
| */ | |||||
| private boolean real; | |||||
| public boolean isReal() { | |||||
| return real; | |||||
| } | |||||
| public void setReal(boolean real) { | |||||
| this.real = real; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,71 @@ | |||||
| package com.iformall.config; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.cache.CacheManager; | |||||
| 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.cache.RedisCacheConfiguration; | |||||
| import org.springframework.data.redis.cache.RedisCacheManager; | |||||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | |||||
| import java.time.Duration; | |||||
| import java.util.HashMap; | |||||
| import java.util.HashSet; | |||||
| import java.util.Map; | |||||
| import java.util.Set; | |||||
| /** | |||||
| * Created by Stormeye on 2018/10/1. | |||||
| */ | |||||
| @Configuration | |||||
| @EnableCaching | |||||
| public class RedisConfig extends CachingConfigurerSupport { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| //缓存管理器 | |||||
| @Bean | |||||
| public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||||
| /* | |||||
| //user信息缓存配置 | |||||
| RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||||
| Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||||
| redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||||
| //初始化一个RedisCacheWriter | |||||
| RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||||
| // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||||
| // ClassLoader loader = this.getClass().getClassLoader(); | |||||
| // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||||
| // RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||||
| // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||||
| RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||||
| //设置默认超过期时间是30秒 | |||||
| defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||||
| //初始化RedisCacheManager | |||||
| RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||||
| return cacheManager; | |||||
| */ | |||||
| RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); // 生成一个默认配置,通过config对象即可对缓存进行自定义配置 | |||||
| config = config.entryTtl(Duration.ofMinutes(1)) // 设置缓存的默认过期时间,也是使用Duration设置 | |||||
| .disableCachingNullValues(); // 不缓存空值 | |||||
| // 设置一个初始化的缓存空间set集合 | |||||
| Set<String> cacheNames = new HashSet<>(); | |||||
| cacheNames.add("my-redis-cache1"); | |||||
| cacheNames.add("my-redis-cache2"); | |||||
| // 对每个缓存空间应用不同的配置 | |||||
| Map<String, RedisCacheConfiguration> configMap = new HashMap<>(); | |||||
| configMap.put("my-redis-cache1", config); | |||||
| configMap.put("my-redis-cache2", config.entryTtl(Duration.ofSeconds(120))); | |||||
| RedisCacheManager cacheManager = RedisCacheManager.builder(connectionFactory) // 使用自定义的缓存配置初始化一个cacheManager | |||||
| .initialCacheNames(cacheNames) // 注意这两句的调用顺序,一定要先调用该方法设置初始化的缓存名,再初始化相关的配置 | |||||
| .withInitialCacheConfigurations(configMap) | |||||
| .build(); | |||||
| return cacheManager; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,58 @@ | |||||
| package com.iformall.config; | |||||
| import java.io.IOException; | |||||
| import java.util.Optional; | |||||
| import javax.servlet.Filter; | |||||
| import javax.servlet.FilterChain; | |||||
| import javax.servlet.FilterConfig; | |||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletRequest; | |||||
| import javax.servlet.ServletResponse; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| /** | |||||
| * 前后端分离RESTful接口过滤器 | |||||
| * | |||||
| * @author xuguoqin | |||||
| * | |||||
| */ | |||||
| public class RestFilter implements Filter { | |||||
| @Override | |||||
| public void init(FilterConfig filterConfig) throws ServletException { | |||||
| } | |||||
| @Override | |||||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||||
| throws IOException, ServletException { | |||||
| HttpServletRequest req = null; | |||||
| if (request instanceof HttpServletRequest) { | |||||
| req = (HttpServletRequest) request; | |||||
| } | |||||
| HttpServletResponse res = null; | |||||
| if (response instanceof HttpServletResponse) { | |||||
| res = (HttpServletResponse) response; | |||||
| } | |||||
| if (req != null && res != null) { | |||||
| //设置允许传递的参数 | |||||
| res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); | |||||
| //设置允许带上cookie | |||||
| res.setHeader("Access-Control-Allow-Credentials", "true"); | |||||
| String origin = Optional.ofNullable(req.getHeader("Origin")).orElse(req.getHeader("Referer")); | |||||
| //设置允许的请求来源 | |||||
| res.setHeader("Access-Control-Allow-Origin", origin); | |||||
| //设置允许的请求方法 | |||||
| res.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS"); | |||||
| } | |||||
| chain.doFilter(request, response); | |||||
| } | |||||
| @Override | |||||
| public void destroy() { | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,24 @@ | |||||
| package com.iformall.config; | |||||
| import org.springframework.context.annotation.Bean; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.client.ClientHttpRequestFactory; | |||||
| import org.springframework.http.client.SimpleClientHttpRequestFactory; | |||||
| import org.springframework.web.client.RestTemplate; | |||||
| @Configuration | |||||
| public class RestTemplateConfig { | |||||
| @Bean | |||||
| public RestTemplate restTemplate(ClientHttpRequestFactory factory) { | |||||
| return new RestTemplate(factory); | |||||
| } | |||||
| @Bean | |||||
| public ClientHttpRequestFactory simpleClientHttpRequestFactory() { | |||||
| SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); | |||||
| factory.setReadTimeout(5000);//ms | |||||
| factory.setConnectTimeout(10000);//ms | |||||
| return factory; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,79 @@ | |||||
| package com.iformall.config; | |||||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||||
| import com.fasterxml.jackson.databind.DeserializationConfig; | |||||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||||
| import com.fasterxml.jackson.databind.module.SimpleModule; | |||||
| import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||||
| import org.springframework.context.annotation.Configuration; | |||||
| import org.springframework.http.converter.HttpMessageConverter; | |||||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||||
| import org.springframework.web.servlet.config.annotation.CorsRegistry; | |||||
| import org.springframework.web.servlet.config.annotation.EnableWebMvc; | |||||
| import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |||||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.BigInteger; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.List; | |||||
| @Configuration | |||||
| @EnableWebMvc | |||||
| public class WebConfig implements WebMvcConfigurer { | |||||
| @Override | |||||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||||
| registry.addResourceHandler("swagger-ui.html") | |||||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||||
| registry.addResourceHandler("/webjars/**") | |||||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||||
| //registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/"); | |||||
| } | |||||
| @Override | |||||
| public void addCorsMappings(CorsRegistry registry) { | |||||
| registry.addMapping("/**") | |||||
| .allowedOrigins("*") | |||||
| .allowCredentials(true) | |||||
| .allowedMethods("GET", "POST", "DELETE", "PUT") | |||||
| .maxAge(3600); | |||||
| } | |||||
| @Override | |||||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||||
| MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||||
| //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||||
| ObjectMapper objectMapper = new ObjectMapper(); | |||||
| SimpleModule simpleModule = new SimpleModule(); | |||||
| //不显示为null的字段 | |||||
| objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||||
| DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||||
| // 设置反序列化日期格式、忽略不存在get、set的属性 | |||||
| objectMapper.setConfig( | |||||
| dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||||
| .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||||
| ); | |||||
| //序列化将Long转String类型 | |||||
| simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||||
| simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||||
| SimpleModule bigIntegerModule = new SimpleModule(); | |||||
| //序列化将BigInteger转String类型 | |||||
| bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||||
| SimpleModule bigDecimalModule = new SimpleModule(); | |||||
| //序列化将BigDecimal转String类型 | |||||
| bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||||
| objectMapper.registerModule(simpleModule); | |||||
| objectMapper.registerModule(bigDecimalModule); | |||||
| objectMapper.registerModule(bigIntegerModule); | |||||
| jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||||
| converters.add(jackson2HttpMessageConverter); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,45 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.utils.IPUtil; | |||||
| import org.springframework.web.bind.WebDataBinder; | |||||
| import org.springframework.web.bind.annotation.InitBinder; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.web.context.request.RequestContextHolder; | |||||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.beans.PropertyEditorSupport; | |||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | |||||
| @RestController | |||||
| public class BaseController { | |||||
| @InitBinder | |||||
| public void InitBinder(WebDataBinder dataBinder) { | |||||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||||
| public void setAsText(String value) { | |||||
| try { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||||
| } catch(ParseException e) { | |||||
| try { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||||
| } catch (ParseException e1) { | |||||
| setValue(null); | |||||
| } | |||||
| } | |||||
| } | |||||
| public String getAsText() { | |||||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||||
| } | |||||
| }); | |||||
| } | |||||
| public String getIpAddr() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String ipaddress = IPUtil.getIpAddr(request); | |||||
| return ipaddress; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,27 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ResultData; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| @RestController | |||||
| @Api(description = "登录相关接口") | |||||
| public class HomeController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Value("${version}") | |||||
| private String version; | |||||
| @ApiOperation("获取后端版本号") | |||||
| @GetMapping("/version") | |||||
| public ResultData version() { | |||||
| return new ResultData(version); | |||||
| } | |||||
| } | |||||
| @@ -1,18 +1,11 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxAuthorizerInfo; | import com.iformall.domain.po.WxAuthorizerInfo; | ||||
| import com.iformall.enums.EnumWxAuthorizationInfoType; | |||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | import com.iformall.enums.EnumWxAuthorizationStatus; | ||||
| import com.iformall.service.WxAuthorizerInfoService; | import com.iformall.service.WxAuthorizerInfoService; | ||||
| import com.iformall.service.wechat.WxOpenService; | import com.iformall.service.wechat.WxOpenService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||||
| import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | |||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | ||||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -24,7 +17,6 @@ import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.List; | |||||
| /** | /** | ||||
| * Stormeye Wu | * Stormeye Wu | ||||
| @@ -2,26 +2,15 @@ package com.iformall.controller; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.enums.EnumWxAuthorizationStatus; | |||||
| import com.iformall.service.WxAuthorizerInfoService; | |||||
| import com.iformall.service.wechat.WxOpenService; | import com.iformall.service.wechat.WxOpenService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||||
| import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | ||||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | |||||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Controller; | |||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | import java.util.List; | ||||
| /** | /** | ||||
| @@ -1,7 +1,5 @@ | |||||
| package com.iformall.service.wechat; | package com.iformall.service.wechat; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | import com.iformall.mapper.WxComponentVerifyTicketMapper; | ||||
| import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| @@ -0,0 +1,51 @@ | |||||
| package com.iformall.utils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.net.InetAddress; | |||||
| import java.net.UnknownHostException; | |||||
| public class IPUtil { | |||||
| private final static Logger logger = LoggerFactory.getLogger(IPUtil.class); | |||||
| public static String getIpAddr(HttpServletRequest request) { | |||||
| String ipAddress = request.getHeader("x-forwarded-for"); | |||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("Proxy-Client-IP"); | |||||
| } | |||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknow".equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("WL-Proxy-Client-IP"); | |||||
| } | |||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("HTTP_CLIENT_IP"); | |||||
| } | |||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getHeader("HTTP_X_FORWARDED_FOR"); | |||||
| } | |||||
| if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { | |||||
| ipAddress = request.getRemoteAddr(); | |||||
| if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) { | |||||
| //根据网卡获取本机配置的IP地址 | |||||
| InetAddress inetAddress = null; | |||||
| try { | |||||
| inetAddress = InetAddress.getLocalHost(); | |||||
| } catch (UnknownHostException e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| ipAddress = inetAddress.getHostAddress(); | |||||
| } | |||||
| } | |||||
| //对于通过多个代理的情况,第一个IP为客户端真实的IP地址,多个IP按照','分割 | |||||
| if (null != ipAddress && ipAddress.length() > 15) { | |||||
| //"***.***.***.***".length() = 15 | |||||
| if (ipAddress.indexOf(",") > 0) { | |||||
| ipAddress = ipAddress.substring(0, ipAddress.indexOf(",")); | |||||
| } | |||||
| } | |||||
| return ipAddress; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,90 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://202.165.179.86:3306/mallinkDev?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false | |||||
| username: ENC(dZ8fmrtuBMQYaRytKQgTqg==) | |||||
| password: ENC(WGu0+1DPIHrqorDhrbq1+7wr7xNG53mN) | |||||
| type: com.alibaba.druid.pool.DruidDataSource | |||||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||||
| filters: stat | |||||
| maxActive: 20 | |||||
| initialSize: 1 | |||||
| maxWait: 60000 | |||||
| minIdle: 1 | |||||
| timeBetweenEvictionRunsMillis: 60000 | |||||
| minEvictableIdleTimeMillis: 300000 | |||||
| validationQuery: select 'x' | |||||
| testWhileIdle: true | |||||
| testOnBorrow: false | |||||
| testOnReturn: false | |||||
| poolPreparedStatements: true | |||||
| maxOpenPreparedStatements: 20 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| #jackson: | |||||
| #date-format: yyyy-MM-dd HH:mm:ss | |||||
| # REDIS | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 50 | |||||
| max-idle: 50 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(R0bER9E9OB9/YQcpNXMyYDwofNVb8/pFl4nrApS8mi0=) | |||||
| password: ENC(50YqJd0iK/2r2YnmEd5RKaki3ktU73UDapBJrVYfqmc=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | |||||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | |||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 202.165.179.86 | |||||
| port: 6379 | |||||
| password: ENC(aYJ3Wr2UWtkORRQjjrWWpz2ZeTISsHOA) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 500 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| jasypt: | |||||
| encryptor: | |||||
| password: oRqdnDbK5pj3eMmB | |||||
| fm: | |||||
| exception: false | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall.mapper: debug | |||||
| path: ./logs/s | |||||
| @@ -0,0 +1,84 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false | |||||
| username: ENC(NUzgQOdJnCbVLKT6BaX0aw==) | |||||
| password: ENC(mvuoDRiu0jqYaKNRwwTuXZ6U7aoIaqsjdiPqTLgi/nY=) | |||||
| type: com.alibaba.druid.pool.DruidDataSource | |||||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||||
| filters: stat | |||||
| maxActive: 20 | |||||
| initialSize: 1 | |||||
| maxWait: 60000 | |||||
| minIdle: 1 | |||||
| timeBetweenEvictionRunsMillis: 60000 | |||||
| minEvictableIdleTimeMillis: 300000 | |||||
| validationQuery: select 'x' | |||||
| testWhileIdle: true | |||||
| testOnBorrow: false | |||||
| testOnReturn: false | |||||
| poolPreparedStatements: true | |||||
| maxOpenPreparedStatements: 20 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| # REDIS | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 8 | |||||
| max-idle: 8 | |||||
| max-wait: -1 | |||||
| min-idle: 0 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(I2YKxnRVPY7J1r/bwzwHOhQCjj3nVqCWEbVTJvBq7y0=) | |||||
| password: ENC(APQMO9XQRzMKd0eap+oSSOYH9MQe/r5K0YFF9A9mizU=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | |||||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | |||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(8gYU47Fu93NUJPhwPCiPbAT+6VFA1YDx1egK4Z0Nl6w=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | |||||
| exception: true | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall: debug | |||||
| path: ./logs/s | |||||
| @@ -0,0 +1,84 @@ | |||||
| spring: | |||||
| # JDBC | |||||
| datasource: | |||||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false | |||||
| username: ENC(Uc0AjgkytxHHCwZrmDASWg==) | |||||
| password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=) | |||||
| type: com.alibaba.druid.pool.DruidDataSource | |||||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||||
| filters: stat | |||||
| maxActive: 20 | |||||
| initialSize: 1 | |||||
| maxWait: 60000 | |||||
| minIdle: 1 | |||||
| timeBetweenEvictionRunsMillis: 60000 | |||||
| minEvictableIdleTimeMillis: 300000 | |||||
| validationQuery: select 'x' | |||||
| testWhileIdle: true | |||||
| testOnBorrow: false | |||||
| testOnReturn: false | |||||
| poolPreparedStatements: true | |||||
| maxOpenPreparedStatements: 20 | |||||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=6000" | |||||
| # REDIS | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 8 | |||||
| max-idle: 8 | |||||
| max-wait: -1 | |||||
| min-idle: 0 | |||||
| mail: | |||||
| host: smtp.exmail.qq.com | |||||
| username: ENC(HFbRXtAFVxU36Hk0yT3reyvRuLrw3RhMlbxFj9Ev/VY=) | |||||
| password: ENC(pk4+/3C5n2hMYmgi+VTqI4P1m77DllW8y4KElMXXmIo=) # 授权密码 | |||||
| properties: | |||||
| mail: | |||||
| smtp: | |||||
| auth: true | |||||
| starttls: | |||||
| enable: true | |||||
| aws: | |||||
| clientRegion: cn-northwest-1 | |||||
| bucketName: iformall-net | |||||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | |||||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | |||||
| wechat: | |||||
| open: | |||||
| componentAppId: "wx897e4673286c915d" | |||||
| componentSecret: "cdfdfda65c45689beb6766c4c427eed2" | |||||
| componentToken: "formall2018" | |||||
| componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||||
| redis: | |||||
| host: 127.0.0.1 | |||||
| port: 6379 | |||||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||||
| timeout: 3600 | |||||
| expire: 1800 #30分钟 | |||||
| database: 1 | |||||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||||
| jedis: | |||||
| pool: | |||||
| max-active: 100 | |||||
| max-idle: 100 | |||||
| max-wait: -1 | |||||
| min-idle: 10 | |||||
| fm: | |||||
| exception: true | |||||
| logging: | |||||
| level: | |||||
| tk.mybatis: debug | |||||
| com.iformall: debug | |||||
| path: ./logs/s | |||||
| @@ -0,0 +1,58 @@ | |||||
| server: | |||||
| port: 6000 | |||||
| servlet: | |||||
| context-path: /O | |||||
| spring: | |||||
| application: | |||||
| name: mallink | |||||
| profiles: | |||||
| active: dev | |||||
| jackson: | |||||
| date-format: yyyy-MM-dd HH:mm:ss | |||||
| time-zone: GMT+8 | |||||
| default-property-inclusion: non_null | |||||
| servlet: | |||||
| multipart: | |||||
| max-file-size: 2MB | |||||
| max-request-size: 2MB | |||||
| cache: | |||||
| type: REDIS | |||||
| cache-names: redis_cache #缓存的名字(可以不指定) | |||||
| redis: | |||||
| time-to-live: 60000ms #很重要,缓存的有效时间,以便缓存的过期(单位为毫秒) | |||||
| # @{link} https://github.com/abel533 | |||||
| #Mybatis | |||||
| mybatis: | |||||
| type-aliases-package: com.iformall.domain.po | |||||
| mapper-locations: classpath:mapper/*Mapper.xml | |||||
| configuration: | |||||
| map-underscore-to-camel-case: true | |||||
| cache-enabled: true | |||||
| lazy-loading-enabled: true | |||||
| use-generated-keys: true | |||||
| default-fetch-size: 100 | |||||
| default-statement-timeout: 10 | |||||
| #PageHelper | |||||
| pagehelper: | |||||
| helperDialect: mysql | |||||
| reasonable: false | |||||
| supportMethodsArguments: true | |||||
| params: count=countSql | |||||
| offset-as-page-num: true | |||||
| page-size-zero: true | |||||
| row-bounds-with-count: true | |||||
| mapper: | |||||
| mappers: | |||||
| - com.iformall.common.CommonMapper | |||||
| pay: | |||||
| real: true | |||||
| version: @project.version@ | |||||
| @@ -0,0 +1,100 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <configuration scan="true" scanPeriod="10 seconds"> | |||||
| <!-- 外部指定路径 --> | |||||
| <springProperty scop="context" name="logPath" source="logging.path" /> | |||||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |||||
| <encoder> | |||||
| <Pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] --%mdc{client}%msg%n</Pattern> | |||||
| </encoder> | |||||
| </appender> | |||||
| <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/trace.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/trace.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| </appender> | |||||
| <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/info.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/info.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>INFO</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/debug.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/debug.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>DEBUG</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/warn.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/warn.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>WARN</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||||
| <file>${logPath}/error.log</file> | |||||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||||
| <FileNamePattern>${logPath}/daily/error.%d{yyyy-MM-dd}.log</FileNamePattern> | |||||
| <maxHistory>180</maxHistory> <!-- 保留180天 --> | |||||
| </rollingPolicy> | |||||
| <layout> | |||||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||||
| </layout> | |||||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||||
| <level>ERROR</level> | |||||
| <onMatch>ACCEPT</onMatch> | |||||
| <onMismatch>DENY</onMismatch> | |||||
| </filter> | |||||
| </appender> | |||||
| <root level="TRACE"> | |||||
| <appender-ref ref="TRACE_FILE" /> | |||||
| <appender-ref ref="INFO_FILE" /> | |||||
| <!-- <appender-ref ref="DEBUG_FILE" /> --> | |||||
| <!-- <appender-ref ref="WARN_FILE" /> --> | |||||
| <appender-ref ref="ERROR_FILE" /> | |||||
| </root> | |||||
| <root level="INFO"> | |||||
| <appender-ref ref="STDOUT" /> | |||||
| </root> | |||||
| </configuration> | |||||
| @@ -17,6 +17,7 @@ | |||||
| <module>mallinkCApi</module> | <module>mallinkCApi</module> | ||||
| <module>mallinkBApi</module> | <module>mallinkBApi</module> | ||||
| <module>mallinkSchedule</module> | <module>mallinkSchedule</module> | ||||
| <module>mallinkWechatOpen</module> | |||||
| </modules> | </modules> | ||||
| <parent> | <parent> | ||||