| @@ -1,50 +0,0 @@ | |||
| <?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> | |||
| @@ -1,33 +0,0 @@ | |||
| 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); | |||
| } | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| 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 { | |||
| } | |||
| @@ -1,345 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,152 +0,0 @@ | |||
| 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"); | |||
| } | |||
| } | |||
| @@ -1,32 +0,0 @@ | |||
| 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(); | |||
| } | |||
| } | |||
| @@ -1,98 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,52 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,24 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,71 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,124 +0,0 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| import redis.clients.jedis.JedisPoolConfig; | |||
| import redis.clients.jedis.Protocol; | |||
| import javax.net.ssl.HostnameVerifier; | |||
| import javax.net.ssl.SSLParameters; | |||
| import javax.net.ssl.SSLSocketFactory; | |||
| /** | |||
| * Stormeye | |||
| */ | |||
| @ConfigurationProperties(prefix = "wechat.redis") | |||
| public class RedisProperies extends JedisPoolConfig { | |||
| private String host = Protocol.DEFAULT_HOST; | |||
| private int port = Protocol.DEFAULT_PORT; | |||
| private String password; | |||
| private int database = 1; | |||
| private int connectionTimeout = Protocol.DEFAULT_TIMEOUT; | |||
| private int soTimeout = Protocol.DEFAULT_TIMEOUT; | |||
| private String clientName; | |||
| private boolean ssl; | |||
| private SSLSocketFactory sslSocketFactory; | |||
| private SSLParameters sslParameters; | |||
| private HostnameVerifier hostnameVerifier; | |||
| public boolean isSsl() { | |||
| return ssl; | |||
| } | |||
| public void setSsl(boolean ssl) { | |||
| this.ssl = ssl; | |||
| } | |||
| public SSLSocketFactory getSslSocketFactory() { | |||
| return sslSocketFactory; | |||
| } | |||
| public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { | |||
| this.sslSocketFactory = sslSocketFactory; | |||
| } | |||
| public SSLParameters getSslParameters() { | |||
| return sslParameters; | |||
| } | |||
| public void setSslParameters(SSLParameters sslParameters) { | |||
| this.sslParameters = sslParameters; | |||
| } | |||
| public HostnameVerifier getHostnameVerifier() { | |||
| return hostnameVerifier; | |||
| } | |||
| public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { | |||
| this.hostnameVerifier = hostnameVerifier; | |||
| } | |||
| public String getHost() { | |||
| return host; | |||
| } | |||
| public void setHost(String host) { | |||
| if (host == null || "".equals(host)) { | |||
| host = Protocol.DEFAULT_HOST; | |||
| } | |||
| this.host = host; | |||
| } | |||
| public int getPort() { | |||
| return port; | |||
| } | |||
| public void setPort(int port) { | |||
| this.port = port; | |||
| } | |||
| public String getPassword() { | |||
| return password; | |||
| } | |||
| public void setPassword(String password) { | |||
| if ("".equals(password)) { | |||
| password = null; | |||
| } | |||
| this.password = password; | |||
| } | |||
| public int getDatabase() { | |||
| return database; | |||
| } | |||
| public void setDatabase(int database) { | |||
| this.database = database; | |||
| } | |||
| public String getClientName() { | |||
| return clientName; | |||
| } | |||
| public void setClientName(String clientName) { | |||
| if ("".equals(clientName)) { | |||
| clientName = null; | |||
| } | |||
| this.clientName = clientName; | |||
| } | |||
| public int getConnectionTimeout() { | |||
| return connectionTimeout; | |||
| } | |||
| public void setConnectionTimeout(int connectionTimeout) { | |||
| this.connectionTimeout = connectionTimeout; | |||
| } | |||
| public int getSoTimeout() { | |||
| return soTimeout; | |||
| } | |||
| public void setSoTimeout(int soTimeout) { | |||
| this.soTimeout = soTimeout; | |||
| } | |||
| } | |||
| @@ -1,58 +0,0 @@ | |||
| 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() { | |||
| } | |||
| } | |||
| @@ -1,24 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,79 +0,0 @@ | |||
| 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); | |||
| } | |||
| } | |||
| @@ -1,69 +0,0 @@ | |||
| package com.iformall.config; | |||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| /** | |||
| * Stormeye | |||
| */ | |||
| @ConfigurationProperties(prefix = "wechat.open") | |||
| public class WechatOpenProperties { | |||
| /** | |||
| * 设置微信三方平台的appid | |||
| */ | |||
| private String componentAppId; | |||
| /** | |||
| * 设置微信三方平台的app secret | |||
| */ | |||
| private String componentSecret; | |||
| /** | |||
| * 设置微信三方平台的token | |||
| */ | |||
| private String componentToken; | |||
| /** | |||
| * 设置微信三方平台的EncodingAESKey | |||
| */ | |||
| private String componentAesKey; | |||
| public String getComponentAppId() { | |||
| return componentAppId; | |||
| } | |||
| public void setComponentAppId(String componentAppId) { | |||
| this.componentAppId = componentAppId; | |||
| } | |||
| public String getComponentSecret() { | |||
| return componentSecret; | |||
| } | |||
| public void setComponentSecret(String componentSecret) { | |||
| this.componentSecret = componentSecret; | |||
| } | |||
| public String getComponentToken() { | |||
| return componentToken; | |||
| } | |||
| public void setComponentToken(String componentToken) { | |||
| this.componentToken = componentToken; | |||
| } | |||
| public String getComponentAesKey() { | |||
| return componentAesKey; | |||
| } | |||
| public void setComponentAesKey(String componentAesKey) { | |||
| this.componentAesKey = componentAesKey; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return ToStringBuilder.reflectionToString(this, | |||
| ToStringStyle.MULTI_LINE_STYLE); | |||
| } | |||
| } | |||
| @@ -1,45 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,27 +0,0 @@ | |||
| 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,96 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| import com.iformall.enums.EnumWxAuthorizationStatus; | |||
| import com.iformall.service.WxAuthorizerInfoService; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | |||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Controller; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.IOException; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @Controller | |||
| @RequestMapping("/wt_auth") | |||
| @Api(description = "微信第三方开放平台授权相关接口") | |||
| public class WechatAuthController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @Autowired | |||
| private WxAuthorizerInfoService authorizerInfoService; | |||
| @GetMapping("/goto_auth_url_show") | |||
| @ResponseBody | |||
| public String gotoPreAuthUrlShow() { | |||
| return "<html>" + | |||
| "<body>" + | |||
| "<a href='/api/wt_auth/goto_auth_url'>go</a>" + | |||
| "</body>" + | |||
| "</html>"; | |||
| } | |||
| @GetMapping("/goto_auth_url") | |||
| public void gotoPreAuthUrl(HttpServletRequest request, HttpServletResponse response) { | |||
| String host = request.getHeader("host"); | |||
| String url = "https://" + host + "/api/wt_auth/jump"; | |||
| try { | |||
| url = openService.getWxOpenComponentService().getPreAuthUrl(url); | |||
| response.sendRedirect(url); | |||
| } catch (WxErrorException | IOException e) { | |||
| logger.error("gotoPreAuthUrl", e); | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| @GetMapping("/jump") | |||
| @ResponseBody | |||
| public WxOpenQueryAuthResult jump(@RequestParam("auth_code") String authorizationCode) { | |||
| try { | |||
| WxOpenQueryAuthResult queryAuthResult = openService.getWxOpenComponentService().getQueryAuth(authorizationCode); | |||
| logger.info("getQueryAuth", queryAuthResult); | |||
| WxOpenAuthorizerInfoResult openAuthorizerInfoResult = openService.getWxOpenComponentService().getAuthorizerInfo( | |||
| queryAuthResult.getAuthorizationInfo().getAuthorizerAppid()); | |||
| // save auth info | |||
| authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ | |||
| { | |||
| setAuthorizerAppid(openAuthorizerInfoResult.getAuthorizationInfo().getAuthorizerAppid()); | |||
| setAlias(openAuthorizerInfoResult.getAuthorizerInfo().getAlias()); | |||
| setHeadImg(openAuthorizerInfoResult.getAuthorizerInfo().getHeadImg()); | |||
| setQrcodeUrl(openAuthorizerInfoResult.getAuthorizerInfo().getQrcodeUrl()); | |||
| setAuthorizationStatus(EnumWxAuthorizationStatus.AUTHORIZED.getCode()); | |||
| } | |||
| }); | |||
| return queryAuthResult; | |||
| } catch (WxErrorException e) { | |||
| logger.error("gotoPreAuthUrl", e); | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| @GetMapping("/getMobilePreAuthUrl") | |||
| @ResponseBody | |||
| public String getMobilePreAuthUrl(HttpServletRequest request, HttpServletResponse response) { | |||
| String host = request.getHeader("host"); | |||
| String url = "https://" + host + "/api/wt_auth/jump"; | |||
| try { | |||
| url = openService.getWxOpenComponentService().getMobilePreAuthUrl(url); | |||
| return url; | |||
| } catch (WxErrorException e) { | |||
| logger.error("getMobilePreAuthUrl", e); | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,242 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||
| import com.iformall.enums.EnumWxAuthorizationInfoType; | |||
| import com.iformall.enums.EnumWxAuthorizationStatus; | |||
| import com.iformall.service.WxAuthorizerInfoService; | |||
| import com.iformall.service.WxComponentVerifyTicketService; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage; | |||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage; | |||
| import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage; | |||
| import me.chanjar.weixin.open.bean.message.WxOpenXmlMessage; | |||
| import me.chanjar.weixin.open.bean.result.WxOpenAuthorizerInfoResult; | |||
| import me.chanjar.weixin.open.bean.result.WxOpenQueryAuthResult; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Controller; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.nio.charset.Charset; | |||
| import java.util.Date; | |||
| @Controller | |||
| @RequestMapping("/wxOpen") | |||
| @Api(description = "微信第三方开放平台回调相关接口") | |||
| public class WechatCalllbackController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| protected WxOpenService wxOpenService; | |||
| @Autowired | |||
| private WxComponentVerifyTicketService componentVerifyTicketService; | |||
| @Autowired | |||
| private WxAuthorizerInfoService authorizerInfoService; | |||
| @RequestMapping(value = "/notify", method = RequestMethod.POST) | |||
| @ApiOperation("接收ticket回调") | |||
| public Object receiveTicket(HttpServletRequest request) throws IOException { | |||
| logger.info("[" +getIpAddr() + "]接收微信请求 /wxOpen/notify"); | |||
| InputStream inStream = request.getInputStream(); | |||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = inStream.read(buffer)) != -1) { | |||
| outSteam.write(buffer, 0, len); | |||
| } | |||
| String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||
| logger.info(resultxml); | |||
| outSteam.close(); | |||
| inStream.close(); | |||
| String timestamp = request.getParameter("timestamp"); | |||
| String nonce = request.getParameter("nonce"); | |||
| String signature = request.getParameter("signature"); | |||
| String encType = request.getParameter("encrypt_type"); | |||
| String msgSignature= request.getParameter("msg_signature"); | |||
| /* | |||
| // 测试数据 | |||
| String timestamp = "1545708083"; | |||
| String nonce = "1052028699"; | |||
| String signature = "b5fa8296b46c726cbed35f744944f20f682776a6"; | |||
| String encType = "aes"; | |||
| String msgSignature= "54bec4c513f447cb312fd091bea48326f87aedde"; | |||
| String resultxml = "<xml>\n" + | |||
| " <AppId><![CDATA[wx897e4673286c915d]]></AppId>\n" + | |||
| " <Encrypt><![CDATA[92gl+PCgxooLh85YZ74VX8gNPV3tq2w8br4tuBl2UIc9uJuJiSNBgohFxgS7tRXSMUtr5t+75MiLKlaMKvv4FH5iF3WdYbxjF6ojnA1+MBzD7mf9fo6KkWUdDq+1V0OtrooP4s8iuAC0Lx3elCtWUZXYGnCeP5Y/2A8ZZBwpvcBz73d7n2Kv8QVvLsw2dmrej1b8KGdmRAEbm/oYoVthlAkmoTTAAx+Gj10XTMem1wp1vT/a0mGxN88oJxNZoHdFvAbmc24A7VD4i5VDOt9FqwerqlGXnBX5pBAmOx8ZUsndM8yuf3I54GE9hEPRvdWBiyLb96Lb8ZnjEBlvc9kvs7PpFOSQhkbGMNQKWGW1os8UImr7O3+IiKLuBv2G1pJBb2/kIeZn5v9NuxYLOsXQmb2XijHYMXwCNHCI3Eji22k9XDiiuK1miHlUuL8Gz8X7lN9JuVcE24jd7Ty4H0pThQ==]]></Encrypt>\n" + | |||
| "</xml>"; | |||
| */ | |||
| logger.info("\n接收微信请求:[signature=[{}], encType=[{}], msgSignature=[{}]," | |||
| + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", | |||
| signature, encType, msgSignature, timestamp, nonce, resultxml); | |||
| if (!StringUtils.equalsIgnoreCase("aes", encType) | |||
| || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) { | |||
| throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); | |||
| } | |||
| // aes加密的消息 | |||
| WxOpenXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedXml(resultxml, | |||
| wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); | |||
| this.logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); | |||
| if(inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.COMPONENT_VERIFY_TICKET.getMessage())) { | |||
| // 保存component_verify_ticket | |||
| componentVerifyTicketService.saveOrUpdate(new WxComponentVerifyTicket(){ | |||
| { | |||
| setComponentVerifyTicket(inMessage.getComponentVerifyTicket()); | |||
| setCreateTime(new Date(Long.valueOf(inMessage.getCreateTime() * 1000))); | |||
| setComponentAppid(inMessage.getAppId()); | |||
| setDeadline(new Date(Long.valueOf(System.currentTimeMillis() + (60*60*1000)))); | |||
| } | |||
| }); | |||
| } else if (inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.AUTHORIZED.getMessage()) || | |||
| inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.UPDATEAUTHORIZED.getMessage()) | |||
| ) { | |||
| try { | |||
| WxOpenQueryAuthResult queryAuthResult = wxOpenService.getWxOpenComponentService().getQueryAuth(inMessage.getAuthorizationCode()); | |||
| logger.info("getQueryAuth", queryAuthResult); | |||
| WxOpenAuthorizerInfoResult openAuthorizerInfoResult = wxOpenService.getWxOpenComponentService().getAuthorizerInfo( | |||
| queryAuthResult.getAuthorizationInfo().getAuthorizerAppid()); | |||
| // save auth info | |||
| authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ | |||
| { | |||
| setAuthorizerAppid(openAuthorizerInfoResult.getAuthorizationInfo().getAuthorizerAppid()); | |||
| setAlias(openAuthorizerInfoResult.getAuthorizerInfo().getAlias()); | |||
| setHeadImg(openAuthorizerInfoResult.getAuthorizerInfo().getHeadImg()); | |||
| setQrcodeUrl(openAuthorizerInfoResult.getAuthorizerInfo().getQrcodeUrl()); | |||
| setAuthorizationStatus(EnumWxAuthorizationStatus.AUTHORIZED.getCode()); | |||
| } | |||
| }); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| } else if (inMessage.getInfoType().equals(EnumWxAuthorizationInfoType.UNAUTHORIZED.getMessage())) { | |||
| authorizerInfoService.saveOrUpdate(new WxAuthorizerInfo(){ | |||
| { | |||
| setAuthorizerAppid(inMessage.getAuthorizerAppid()); | |||
| setAuthorizationStatus(EnumWxAuthorizationStatus.UNAUTHORIZED.getCode()); | |||
| } | |||
| }); | |||
| } | |||
| try { | |||
| String out = wxOpenService.getWxOpenComponentService().route(inMessage); | |||
| this.logger.debug("\n组装回复信息:{}", out); | |||
| } catch (WxErrorException e) { | |||
| this.logger.error("notify", e); | |||
| } | |||
| return "success"; | |||
| } | |||
| @RequestMapping(value = "/{appId}/callback") | |||
| @ApiOperation("消息回调") | |||
| public Object callback(@PathVariable("appId") String appId, HttpServletRequest request) throws IOException { | |||
| logger.info("[" +getIpAddr() + "]接收微信请求 /{appId}/callback"); | |||
| InputStream inStream = request.getInputStream(); | |||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = inStream.read(buffer)) != -1) { | |||
| outSteam.write(buffer, 0, len); | |||
| } | |||
| String resultxml = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||
| logger.info(resultxml); | |||
| outSteam.close(); | |||
| inStream.close(); | |||
| String timestamp = request.getParameter("timestamp"); | |||
| String nonce = request.getParameter("nonce"); | |||
| String signature = request.getParameter("signature"); | |||
| String encType = request.getParameter("encrypt_type"); | |||
| String openid = request.getParameter("openid"); | |||
| String msgSignature= request.getParameter("msg_signature"); | |||
| logger.info( | |||
| "\n接收微信请求:[appId=[{}], openid=[{}], signature=[{}], encType=[{}], msgSignature=[{}]," | |||
| + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ", | |||
| appId, openid, signature, encType, msgSignature, timestamp, nonce, resultxml); | |||
| if (!StringUtils.equalsIgnoreCase("aes", encType) | |||
| || !wxOpenService.getWxOpenComponentService().checkSignature(timestamp, nonce, signature)) { | |||
| throw new IllegalArgumentException("非法请求,可能属于伪造的请求!"); | |||
| } | |||
| String out = ""; | |||
| // aes加密的消息 | |||
| WxMpXmlMessage inMessage = WxOpenXmlMessage.fromEncryptedMpXml(resultxml, | |||
| wxOpenService.getWxOpenConfigStorage(), timestamp, nonce, msgSignature); | |||
| logger.debug("\n消息解密后内容为:\n{} ", inMessage.toString()); | |||
| // 全网发布测试用例 | |||
| if (StringUtils.equalsAnyIgnoreCase(appId, "wx570bc396a51b8ff8", "wxd101a85aa106f53e")) { | |||
| try { | |||
| if (StringUtils.equals(inMessage.getMsgType(), "text")) { | |||
| if (StringUtils.equals(inMessage.getContent(), "TESTCOMPONENT_MSG_TYPE_TEXT")) { | |||
| out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml( | |||
| WxMpXmlOutMessage.TEXT().content("TESTCOMPONENT_MSG_TYPE_TEXT_callback") | |||
| .fromUser(inMessage.getToUser()) | |||
| .toUser(inMessage.getFromUser()) | |||
| .build(), | |||
| wxOpenService.getWxOpenConfigStorage() | |||
| ); | |||
| } else if (StringUtils.startsWith(inMessage.getContent(), "QUERY_AUTH_CODE:")) { | |||
| String msg = inMessage.getContent().replace("QUERY_AUTH_CODE:", "") + "_from_api"; | |||
| WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(msg).toUser(inMessage.getFromUser()).build(); | |||
| wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); | |||
| } | |||
| } else if (StringUtils.equals(inMessage.getMsgType(), "event")) { | |||
| WxMpKefuMessage kefuMessage = WxMpKefuMessage.TEXT().content(inMessage.getEvent() + "from_callback").toUser(inMessage.getFromUser()).build(); | |||
| wxOpenService.getWxOpenComponentService().getWxMpServiceByAppid(appId).getKefuService().sendKefuMessage(kefuMessage); | |||
| } | |||
| } catch (WxErrorException e) { | |||
| logger.error("callback", e); | |||
| } | |||
| } else { | |||
| /**判断消息类型,调用对应的方法*/ | |||
| switch (inMessage.getMsgType()){ | |||
| case "event": | |||
| case "text": | |||
| WxMpXmlOutMessage outMessage = wxOpenService.getWxOpenMessageRouter().route(inMessage, appId); | |||
| if (outMessage != null) { | |||
| out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml(outMessage, wxOpenService.getWxOpenConfigStorage()); | |||
| } | |||
| /* | |||
| else { | |||
| WxMpXmlOutMessage outMsg = new WxMpXmlOutTextMessage(); | |||
| outMsg.setCreateTime(System.currentTimeMillis()); | |||
| outMsg.setToUserName(inMessage.getFromUser()); | |||
| outMsg.setFromUserName(inMessage.getToUser()); | |||
| outMsg.setMsgType("text"); | |||
| ((WxMpXmlOutTextMessage) outMsg).setContent(inMessage.getContent()); | |||
| out = WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml(outMsg, wxOpenService.getWxOpenConfigStorage()); | |||
| } | |||
| */ | |||
| else { | |||
| out = "success"; | |||
| } | |||
| break; | |||
| default: | |||
| return "success"; | |||
| } | |||
| } | |||
| logger.info(out); | |||
| return out; | |||
| } | |||
| } | |||
| @@ -1,236 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.google.gson.Gson; | |||
| import com.google.gson.GsonBuilder; | |||
| import com.google.gson.reflect.TypeToken; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||
| import me.chanjar.weixin.open.bean.ma.WxMaOpenCommitExtInfo; | |||
| import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage; | |||
| import me.chanjar.weixin.open.bean.result.*; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.ServletOutputStream; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.util.Map; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/weappCode") | |||
| @Api(description = "微信第三方开发平台-小程序-代码管理") | |||
| public class WechatWeappCodeController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @ApiOperation(value = "为授权的小程序帐号上传小程序代码", notes = "extInfo参考https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html") | |||
| @PostMapping("/codeCommit") | |||
| public ResultData codeCommit(Long templateId, String userVersion, String userDesc, String extInfoStr) { | |||
| try { | |||
| Gson gson= new GsonBuilder().create(); | |||
| WxMaOpenCommitExtInfo extInfo = gson.fromJson(extInfoStr, new TypeToken<WxMaOpenCommitExtInfo>() { }.getType()); | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(extInfo.getExtAppid()); | |||
| logger.info(extInfo.toString()); | |||
| WxOpenResult openRet = openMaService.codeCommit(templateId, userVersion, userDesc, extInfo); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("获取体验小程序的体验二维码") | |||
| @GetMapping("/getQrcode") | |||
| public void getQrcode(String appId, String pagePath, Map<String, String> params, HttpServletResponse response, HttpServletRequest req) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| File file = openMaService.getTestQrcode(pagePath, params); | |||
| ServletOutputStream out = response.getOutputStream(); | |||
| response.reset(); | |||
| response.setContentType("bin"); | |||
| String agent = req.getHeader("user-agent"); | |||
| String filename = "qrcode"; | |||
| if (agent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + new String(filename.getBytes("GB2312"),"ISO-8859-1")); | |||
| } else { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + java.net.URLEncoder.encode(filename,"UTF-8")); | |||
| } | |||
| // 循环取出流中的数据 | |||
| byte[] b = new byte[1024]; | |||
| int len; | |||
| InputStream inStream = new FileInputStream(file); | |||
| while ((len = inStream.read(b)) > 0) | |||
| response.getOutputStream().write(b, 0, len); | |||
| inStream.close(); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } catch (IOException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("获取授权小程序帐号已设置的类目") | |||
| @GetMapping("/getCategory") | |||
| public ResultData getCategory(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaCategoryListResult openRet = openMaService.getCategoryList(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("获取小程序的第三方提交代码的页面配置") | |||
| @GetMapping("/getPage") | |||
| public ResultData getPage(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaPageListResult openRet = openMaService.getPageList(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("将第三方提交的代码包提交审核") | |||
| @PostMapping("/submitAudit") | |||
| public ResultData submitAudit(String appId, String subMesgStr) { | |||
| try { | |||
| WxOpenMaSubmitAuditMessage subMessage = JSON.parseObject(subMesgStr, WxOpenMaSubmitAuditMessage.class); | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaSubmitAuditResult openRet = openMaService.submitAudit(subMessage); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("查询某个指定版本的审核状态") | |||
| @PostMapping("/getAuditstatus") | |||
| public ResultData getAuditstatus(String appId, String auditidStr) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaQueryAuditResult openRet = openMaService.getAuditStatus(Long.valueOf(auditidStr)); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("查询最新一次提交的审核状态") | |||
| @GetMapping("/getLatestAuditstatus") | |||
| public ResultData get_latest_auditstatus(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaQueryAuditResult openRet = openMaService.getLatestAuditStatus(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("发布已通过审核的小程序") | |||
| @PostMapping("/releaesAudited") | |||
| public ResultData releaesAudited(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.releaesAudited(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("小程序版本回退") | |||
| @GetMapping("/revertCodeRelease") | |||
| public ResultData revertCodeRelease(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.revertCodeReleaes(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("查询当前设置的最低基础库版本及各版本用户占比") | |||
| @GetMapping("/getSupportVersion") | |||
| public ResultData getSupportVersion(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| String openRet = openMaService.getSupportVersion(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation("设置最低基础库版本") | |||
| @GetMapping("/setSupportVersion") | |||
| public ResultData setSupportVersion(String appId, String version) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| String openRet = openMaService.setSupportVersion(version); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "小程序审核撤回", notes = "单个帐号每天审核撤回次数最多不超过1次,一个月不超过10次。") | |||
| @GetMapping("/undoCodeAudit") | |||
| public ResultData undoCodeAudit(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| openMaService.undoCodeAudit(); | |||
| return new ResultData(); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| } | |||
| @@ -1,72 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.open.bean.WxOpenMaCodeTemplate; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/weappDraftTemplate") | |||
| @Api(description = "微信第三方开发平台-小程序-代码模版库管理") | |||
| public class WechatWeappDraftTemplateController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @GetMapping("/tempDraftList") | |||
| public ResultData getTempDraftList() { | |||
| try { | |||
| List<WxOpenMaCodeTemplate> list = openService.getWxOpenComponentService().getTemplateDraftList(); | |||
| return new ResultData(list); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @GetMapping("/tempList") | |||
| public ResultData getTempList() { | |||
| try { | |||
| List<WxOpenMaCodeTemplate> list = openService.getWxOpenComponentService().getTemplateList(); | |||
| return new ResultData(list); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @PostMapping("/addToTemplate") | |||
| public ResultData addToTemplate(Long draftId) { | |||
| try { | |||
| openService.getWxOpenComponentService().addToTemplate(draftId); | |||
| return new ResultData(); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @PostMapping("/deleteTemplate") | |||
| public ResultData deleteTemplate(Long templateId) { | |||
| try { | |||
| openService.getWxOpenComponentService().deleteTemplate(templateId); | |||
| return new ResultData(); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,115 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateAddResult; | |||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryGetResult; | |||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateLibraryListResult; | |||
| import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/weappMsgTemplate") | |||
| @Api(description = "微信第三方开发平台-小程序-消息模板设置") | |||
| public class WechatWeappMsgTemplateController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @ApiOperation("获取小程序模板库标题列表") | |||
| @GetMapping("getTmpLibList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData getTmpLibList(String appId, Integer pageNum, Integer pageSize) { | |||
| try { | |||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxMaTemplateLibraryListResult ret = maService.getTemplateService().findTemplateLibraryList(pageNum, pageSize); | |||
| return new ResultData(ret); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("获取模板库某个模板标题下关键词库") | |||
| @GetMapping("getTemplateLibraryKeywordList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "id", value = "页数", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData findTemplateLibraryKeywordList(String appId, String id) { | |||
| try { | |||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxMaTemplateLibraryGetResult ret = maService.getTemplateService().findTemplateLibraryKeywordList(id); | |||
| return new ResultData(ret); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("组合模板并添加至帐号下的个人模板库") | |||
| @PostMapping("addTemplate") | |||
| public ResultData addTemplate( | |||
| @RequestParam(value = "appId") String appId, | |||
| @RequestParam(value = "id") String id, | |||
| @RequestParam(value = "keywordIdList")List<Integer> keywordIdList) { | |||
| try { | |||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxMaTemplateAddResult ret = maService.getTemplateService().addTemplate(id, keywordIdList); | |||
| return new ResultData(ret); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("获取帐号下已存在的模板列表") | |||
| @GetMapping("getTemplateList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "appId", value = "appId", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findTemplateList(String appId, Integer pageNum, Integer pageSize) { | |||
| try { | |||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxMaTemplateListResult ret = maService.getTemplateService().findTemplateList(pageNum, pageSize); | |||
| return new ResultData(ret); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("删除帐号下的某个模板") | |||
| @PostMapping("delTemplate") | |||
| public ResultData delTemplate(@RequestParam(value = "appId") String appId, @RequestParam(value = "templateId") String templateId) { | |||
| try { | |||
| WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| maService.getTemplateService().delTemplate(templateId); | |||
| return new ResultData(); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,126 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.service.wechat.WxOpenService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.open.api.WxOpenMaService; | |||
| import me.chanjar.weixin.open.bean.result.*; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/weappSet") | |||
| @Api(description = "微信第三方开发平台-小程序设置") | |||
| public class WechatWeappSetController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxOpenService openService; | |||
| @ApiOperation("获取小程序服务器域名") | |||
| @GetMapping("/getDomain") | |||
| public ResultData modifyDomain(String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.getDomain(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "设置小程序服务器域名", notes = "{\n" + | |||
| " \"action\":\"add\",\n" + | |||
| " \"requestdomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||
| " \"wsrequestdomain\":[\"wss://www.qq.com\",\"wss://www.qq.com\"],\n" + | |||
| " \"uploaddomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||
| " \"downloaddomain\":[\"https://www.qq.com\",\"https://www.qq.com\"],\n" + | |||
| " }") | |||
| @PostMapping("/modifyDomain") | |||
| public ResultData modifyDomain(@RequestParam(value = "appId") String appId, @RequestParam(value = "action") String action, | |||
| @RequestParam(value = "requestDomain") List<String> requestDomain, @RequestParam(value = "wsrequestdomain") List<String> wsrequestdomain, | |||
| @RequestParam(value = "uploaddomain") List<String> uploaddomain, @RequestParam(value = "downloaddomain") List<String> downloaddomain) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenMaDomainResult openRet = openMaService.modifyDomain(action, | |||
| requestDomain, wsrequestdomain, | |||
| uploaddomain, downloaddomain); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "设置小程序业务域名", notes = "{\n" + | |||
| " \"action\":\"add\",\n" + | |||
| " \"webviewdomain\":[\"https://www.qq.com\",\"https://m.qq.com\"]\n" + | |||
| " }") | |||
| @PostMapping("/setWebViewDomain") | |||
| public ResultData setWebViewDomain(@RequestParam(value = "appId") String appId, @RequestParam(value = "action") String action, | |||
| @RequestParam(value = "urlList") List<String> urlList) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| String openRet = openMaService.setWebViewDomain(action, urlList); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "绑定微信用户为小程序体验者", notes = "") | |||
| @PostMapping("/bindTester") | |||
| public ResultData bindTester(@RequestParam(value = "appId") String appId, @RequestParam(value = "wechatId") String wechatId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.bindTester(wechatId); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "解除绑定小程序的体验者", notes = "") | |||
| @PostMapping("/unbindTester") | |||
| public ResultData unbindTester(@RequestParam(value = "appId") String appId, @RequestParam(value = "wechatId") String wechatId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.unbindTester(wechatId); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| @ApiOperation(value = "获取体验者列表", notes = "") | |||
| @PostMapping("/getTesterList") | |||
| public ResultData getTesterList(@RequestParam(value = "appId") String appId) { | |||
| try { | |||
| WxOpenMaService openMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||
| WxOpenResult openRet = openMaService.getTesterList(); | |||
| logger.info(openRet.toString()); | |||
| return new ResultData(openRet); | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(Result.ERROR); | |||
| } | |||
| } | |||
| @@ -1,110 +0,0 @@ | |||
| package com.iformall.domain.po; | |||
| import lombok.Data; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "wx_authorizer_info") | |||
| @Data | |||
| public class WxAuthorizerInfo implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| /**微信公众账号基本信息表id,关联微信公众号基本信息表*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信公众账号基本信息表id,关联微信公众号基本信息表",name="officialAccountId") | |||
| private Long officialAccountId; | |||
| /**授权方appid*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="授权方appid",name="authorizerAppid") | |||
| private String authorizerAppid; | |||
| /**授权方头像*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="授权方头像",name="headImg") | |||
| private String headImg; | |||
| /**授权方公众号所设置的微信号,可能为空*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="授权方公众号所设置的微信号,可能为空",name="alias") | |||
| private String alias; | |||
| /**二维码图片的URL,开发者最好自行也进行保存*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="二维码图片的URL,开发者最好自行也进行保存",name="qrcodeUrl") | |||
| private String qrcodeUrl; | |||
| /**创建时间*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| /**授权状态,0为已授权,1为已取消授权*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="授权状态,0为已授权,1为已取消授权",name="authorizationStatus") | |||
| private Integer authorizationStatus; | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,OfficialAccountId_ASC("`official_account_id` ASC"),OfficialAccountId_DESC("`official_account_id` DESC") | |||
| ,AuthorizerAppid_ASC("`authorizer_appid` ASC"),AuthorizerAppid_DESC("`authorizer_appid` DESC") | |||
| ,HeadImg_ASC("`head_img` ASC"),HeadImg_DESC("`head_img` DESC") | |||
| ,Alias_ASC("`alias` ASC"),Alias_DESC("`alias` DESC") | |||
| ,QrcodeUrl_ASC("`qrcode_url` ASC"),QrcodeUrl_DESC("`qrcode_url` DESC") | |||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||
| ,AuthorizationStatus_ASC("`authorization_status` ASC"),AuthorizationStatus_DESC("`authorization_status` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxAuthorizerInfo.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,98 +0,0 @@ | |||
| package com.iformall.domain.po; | |||
| import lombok.Data; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "wx_component_verify_ticket") | |||
| @Data | |||
| public class WxComponentVerifyTicket implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| /**微信第三方componentAppid*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信第三方componentAppid",name="componentAppid") | |||
| private String componentAppid; | |||
| /**微信第三方component_verify_ticket*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="微信第三方component_verify_ticket",name="componentVerifyTicket") | |||
| private String componentVerifyTicket; | |||
| /**创建时间*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| /**失效时间*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="失效时间",name="deadline") | |||
| private Date deadline; | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,ComponentAppid_ASC("`component_appid` ASC"),ComponentAppid_DESC("`component_appid` DESC") | |||
| ,ComponentVerifyTicket_ASC("`component_verify_ticket` ASC"),ComponentVerifyTicket_DESC("`component_verify_ticket` DESC") | |||
| ,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC") | |||
| ,Deadline_ASC("`deadline` ASC"),Deadline_DESC("`deadline` DESC") | |||
| ; | |||
| private String value; | |||
| Field(String value){ | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxComponentVerifyTicket.Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| java.util.List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,38 +0,0 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumWxAuthorizationInfoType { | |||
| COMPONENT_VERIFY_TICKET(1, "component_verify_ticket"), | |||
| UNAUTHORIZED(2, "unauthorized"), | |||
| AUTHORIZED(3, "authorized"), | |||
| UPDATEAUTHORIZED(4, "updateauthorized") | |||
| ; | |||
| public static EnumWxAuthorizationInfoType getEnum(Integer code) { | |||
| for (EnumWxAuthorizationInfoType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumWxAuthorizationInfoType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -1,38 +0,0 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumWxAuthorizationStatus { | |||
| // 0-authorized, 1-unauthorized | |||
| AUTHORIZED(0, "authorized"), | |||
| UNAUTHORIZED(1, "unauthorized") | |||
| ; | |||
| public static EnumWxAuthorizationStatus getEnum(Integer code) { | |||
| for (EnumWxAuthorizationStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumWxAuthorizationStatus(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -1,17 +0,0 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| public interface WxAuthorizerInfoMapper extends CommonMapper<WxAuthorizerInfo, Long> { | |||
| List<WxAuthorizerInfo> findList(WxAuthorizerInfo wxAuthorizerInfo); | |||
| } | |||
| @@ -1,17 +0,0 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||
| public interface WxComponentVerifyTicketMapper extends CommonMapper<WxComponentVerifyTicket, Long> { | |||
| List<WxComponentVerifyTicket> findList(WxComponentVerifyTicket wxComponentVerifyTicket); | |||
| } | |||
| @@ -1,48 +0,0 @@ | |||
| package com.iformall.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| public interface WxAuthorizerInfoService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxAuthorizerInfo> listAsPage(WxAuthorizerInfo record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxAuthorizerInfo getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxAuthorizerInfo record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -1,41 +0,0 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||
| public interface WxComponentVerifyTicketService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxComponentVerifyTicket> listAsPage(WxComponentVerifyTicket record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxComponentVerifyTicket getById(Long id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxComponentVerifyTicket record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| } | |||
| @@ -1,65 +0,0 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||
| import com.iformall.service.WxAuthorizerInfoService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| @Service | |||
| public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxAuthorizerInfoMapper wxAuthorizerInfoMapper; | |||
| @Override | |||
| public PageInfo<WxAuthorizerInfo> listAsPage(WxAuthorizerInfo record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxAuthorizerInfoMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxAuthorizerInfo getById(Long id) { | |||
| return wxAuthorizerInfoMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxAuthorizerInfo record) { | |||
| WxAuthorizerInfo authorizerInfo = null; | |||
| try { | |||
| WxAuthorizerInfo aiQ = new WxAuthorizerInfo(); | |||
| aiQ.setAuthorizerAppid(record.getAuthorizerAppid()); | |||
| authorizerInfo = wxAuthorizerInfoMapper.selectOne(aiQ); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| if (authorizerInfo == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxAuthorizerInfoMapper.insertSelective(record); | |||
| } else { | |||
| record.setId(authorizerInfo.getId()); | |||
| wxAuthorizerInfoMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxAuthorizerInfoMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -1,64 +0,0 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxComponentVerifyTicket; | |||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | |||
| import com.iformall.service.WxComponentVerifyTicketService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| @Service | |||
| public class WxComponentVerifyTicketServiceImpl implements WxComponentVerifyTicketService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxComponentVerifyTicketMapper wxComponentVerifyTicketMapper; | |||
| @Override | |||
| public PageInfo<WxComponentVerifyTicket> listAsPage(WxComponentVerifyTicket record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxComponentVerifyTicketMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxComponentVerifyTicket getById(Long id) { | |||
| return wxComponentVerifyTicketMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxComponentVerifyTicket record) { | |||
| WxComponentVerifyTicket wxComponentVerifyTicket = null; | |||
| try { | |||
| WxComponentVerifyTicket ctQ = new WxComponentVerifyTicket(); | |||
| ctQ.setComponentAppid(record.getComponentAppid()); | |||
| wxComponentVerifyTicket = wxComponentVerifyTicketMapper.selectOne(ctQ); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| if (wxComponentVerifyTicket == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| wxComponentVerifyTicketMapper.insertSelective(record); | |||
| } else { | |||
| record.setId(wxComponentVerifyTicket.getId()); | |||
| wxComponentVerifyTicketMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(Long id) { | |||
| wxComponentVerifyTicketMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -1,223 +0,0 @@ | |||
| package com.iformall.service.wechat; | |||
| import com.iformall.mapper.WxComponentVerifyTicketMapper; | |||
| import me.chanjar.weixin.open.api.impl.WxOpenInMemoryConfigStorage; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import redis.clients.jedis.Jedis; | |||
| import redis.clients.jedis.JedisPool; | |||
| import redis.clients.util.Pool; | |||
| public class WxOpenInRedisDBConfigStorage extends WxOpenInMemoryConfigStorage { | |||
| private final static String COMPONENT_VERIFY_TICKET_KEY = "wechat_component_verify_ticket:"; | |||
| private final static String COMPONENT_ACCESS_TOKEN_KEY = "wechat_component_access_token:"; | |||
| private final static String AUTHORIZER_REFRESH_TOKEN_KEY = "wechat_authorizer_refresh_token:"; | |||
| private final static String AUTHORIZER_ACCESS_TOKEN_KEY = "wechat_authorizer_access_token:"; | |||
| private final static String JSAPI_TICKET_KEY = "wechat_jsapi_ticket:"; | |||
| private final static String CARD_API_TICKET_KEY = "wechat_card_api_ticket:"; | |||
| protected final Pool<Jedis> jedisPool; | |||
| /** | |||
| * redis 存储的 key 的前缀,可为空 | |||
| */ | |||
| private String keyPrefix; | |||
| private String componentVerifyTicketKey; | |||
| private String componentAccessTokenKey; | |||
| private String authorizerRefreshTokenKey; | |||
| private String authorizerAccessTokenKey; | |||
| private String jsapiTicketKey; | |||
| private String cardApiTicket; | |||
| @Autowired | |||
| WxComponentVerifyTicketMapper wxComponentVerifyTicketMapper; | |||
| public WxOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool) { | |||
| this.jedisPool = jedisPool; | |||
| } | |||
| public WxOpenInRedisDBConfigStorage(Pool<Jedis> jedisPool, String keyPrefix) { | |||
| this.jedisPool = jedisPool; | |||
| this.keyPrefix = keyPrefix; | |||
| } | |||
| public WxOpenInRedisDBConfigStorage(JedisPool jedisPool) { | |||
| this.jedisPool = jedisPool; | |||
| } | |||
| @Override | |||
| public void setComponentAppId(String componentAppId) { | |||
| super.setComponentAppId(componentAppId); | |||
| String prefix = StringUtils.isBlank(keyPrefix) ? "" : | |||
| (StringUtils.endsWith(keyPrefix, ":") ? keyPrefix : (keyPrefix + ":")); | |||
| componentVerifyTicketKey = prefix + COMPONENT_VERIFY_TICKET_KEY.concat(componentAppId); | |||
| componentAccessTokenKey = prefix + COMPONENT_ACCESS_TOKEN_KEY.concat(componentAppId); | |||
| authorizerRefreshTokenKey = prefix + AUTHORIZER_REFRESH_TOKEN_KEY.concat(componentAppId); | |||
| authorizerAccessTokenKey = prefix + AUTHORIZER_ACCESS_TOKEN_KEY.concat(componentAppId); | |||
| this.jsapiTicketKey = JSAPI_TICKET_KEY.concat(componentAppId); | |||
| this.cardApiTicket = CARD_API_TICKET_KEY.concat(componentAppId); | |||
| } | |||
| @Override | |||
| public String getComponentVerifyTicket() { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.get(this.componentVerifyTicketKey); | |||
| } | |||
| } | |||
| @Override | |||
| public void setComponentVerifyTicket(String componentVerifyTicket) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.set(this.componentVerifyTicketKey, componentVerifyTicket); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| @Override | |||
| public String getComponentAccessToken() { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.get(this.componentAccessTokenKey); | |||
| } | |||
| } | |||
| @Override | |||
| public boolean isComponentAccessTokenExpired() { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.ttl(this.componentAccessTokenKey) < 2; | |||
| } | |||
| } | |||
| @Override | |||
| public void expireComponentAccessToken(){ | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.expire(this.componentAccessTokenKey, 0); | |||
| } | |||
| } | |||
| @Override | |||
| public void updateComponentAccessTokent(String componentAccessToken, int expiresInSeconds) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.setex(this.componentAccessTokenKey, expiresInSeconds - 200, componentAccessToken); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| private String getKey(String prefix, String appId) { | |||
| return prefix.endsWith(":") ? prefix.concat(appId) : prefix.concat(":").concat(appId); | |||
| } | |||
| @Override | |||
| public String getAuthorizerRefreshToken(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.get(this.getKey(this.authorizerRefreshTokenKey, appId)); | |||
| } | |||
| } | |||
| @Override | |||
| public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.set(this.getKey(this.authorizerRefreshTokenKey, appId), authorizerRefreshToken); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| @Override | |||
| public String getAuthorizerAccessToken(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.get(this.getKey(this.authorizerAccessTokenKey, appId)); | |||
| } | |||
| } | |||
| @Override | |||
| public boolean isAuthorizerAccessTokenExpired(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.ttl(this.getKey(this.authorizerAccessTokenKey, appId)) < 2; | |||
| } | |||
| } | |||
| @Override | |||
| public void expireAuthorizerAccessToken(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.expire(this.getKey(this.authorizerAccessTokenKey, appId), 0); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| @Override | |||
| public void updateAuthorizerAccessToken(String appId, String authorizerAccessToken, int expiresInSeconds) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.setex(this.getKey(this.authorizerAccessTokenKey, appId), expiresInSeconds - 200, authorizerAccessToken); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| /* | |||
| @Override | |||
| public void changeAuthorizationStatus(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.expire(this.getKey(this.authorizerAccessTokenKey, appId), 0); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| */ | |||
| @Override | |||
| public String getJsapiTicket(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.get(this.getKey(this.jsapiTicketKey, appId)); | |||
| } | |||
| } | |||
| @Override | |||
| public boolean isJsapiTicketExpired(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.ttl(this.getKey(this.jsapiTicketKey, appId)) < 2; | |||
| } | |||
| } | |||
| @Override | |||
| public void expireJsapiTicket(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.expire(this.getKey(this.jsapiTicketKey, appId), 0); | |||
| } | |||
| } | |||
| @Override | |||
| public void updateJsapiTicket(String appId, String jsapiTicket, int expiresInSeconds) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.setex(this.getKey(this.jsapiTicketKey, appId), expiresInSeconds - 200, jsapiTicket); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| @Override | |||
| public String getCardApiTicket(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.get(this.getKey(this.cardApiTicket, appId)); | |||
| } | |||
| } | |||
| @Override | |||
| public boolean isCardApiTicketExpired(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| return jedis.ttl(this.getKey(this.cardApiTicket, appId)) < 2; | |||
| } | |||
| } | |||
| @Override | |||
| public void expireCardApiTicket(String appId) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.expire(this.getKey(this.cardApiTicket, appId), 0); | |||
| } | |||
| } | |||
| @Override | |||
| public void updateCardApiTicket(String appId, String cardApiTicket, int expiresInSeconds) { | |||
| try (Jedis jedis = this.jedisPool.getResource()) { | |||
| jedis.setex(this.getKey(this.cardApiTicket, appId), expiresInSeconds - 200, cardApiTicket); | |||
| } | |||
| // TODO update to DB | |||
| } | |||
| } | |||
| @@ -1,64 +0,0 @@ | |||
| package com.iformall.service.wechat; | |||
| import com.iformall.config.RedisProperies; | |||
| import com.iformall.config.WechatOpenProperties; | |||
| import me.chanjar.weixin.open.api.impl.WxOpenMessageRouter; | |||
| import me.chanjar.weixin.open.api.impl.WxOpenServiceImpl; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||
| import org.springframework.stereotype.Service; | |||
| import redis.clients.jedis.JedisPool; | |||
| import javax.annotation.PostConstruct; | |||
| /** | |||
| * Stormeye WU | |||
| */ | |||
| @Service | |||
| @EnableConfigurationProperties({WechatOpenProperties.class, RedisProperies.class}) | |||
| public class WxOpenService extends WxOpenServiceImpl { | |||
| private Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WechatOpenProperties wechatProperties; | |||
| @Autowired | |||
| private RedisProperies redisProperies; | |||
| private static JedisPool pool; | |||
| private WxOpenMessageRouter wxOpenMessageRouter; | |||
| @PostConstruct | |||
| public void init() { | |||
| WxOpenInRedisDBConfigStorage configStorage = new WxOpenInRedisDBConfigStorage(getJedisPool()); | |||
| configStorage.setComponentAppId(wechatProperties.getComponentAppId()); | |||
| configStorage.setComponentAppSecret(wechatProperties.getComponentSecret()); | |||
| configStorage.setComponentToken(wechatProperties.getComponentToken()); | |||
| configStorage.setComponentAesKey(wechatProperties.getComponentAesKey()); | |||
| setWxOpenConfigStorage(configStorage); | |||
| wxOpenMessageRouter = new WxOpenMessageRouter(this); | |||
| wxOpenMessageRouter.rule().handler((wxMpXmlMessage, map, wxMpService, wxSessionManager) -> { | |||
| logger.info("\n接收到 {} 公众号请求消息,内容:{}", wxMpService.getWxMpConfigStorage().getAppId(), wxMpXmlMessage); | |||
| return null; | |||
| }).next(); | |||
| } | |||
| public WxOpenMessageRouter getWxOpenMessageRouter() { | |||
| return wxOpenMessageRouter; | |||
| } | |||
| private JedisPool getJedisPool() { | |||
| if (pool == null) { | |||
| synchronized (WxOpenService.class) { | |||
| if (pool == null) { | |||
| pool = new JedisPool(redisProperies, redisProperies.getHost(), | |||
| redisProperies.getPort(), redisProperies.getConnectionTimeout(), | |||
| redisProperies.getSoTimeout(), redisProperies.getPassword(), | |||
| redisProperies.getDatabase(), redisProperies.getClientName(), | |||
| redisProperies.isSsl(), redisProperies.getSslSocketFactory(), | |||
| redisProperies.getSslParameters(), redisProperies.getHostnameVerifier()); | |||
| } | |||
| } | |||
| } | |||
| return pool; | |||
| } | |||
| } | |||
| @@ -1,51 +0,0 @@ | |||
| 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; | |||
| } | |||
| } | |||
| @@ -1,90 +0,0 @@ | |||
| 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 | |||
| @@ -1,84 +0,0 @@ | |||
| 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 | |||
| @@ -1,84 +0,0 @@ | |||
| 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 | |||
| @@ -1,58 +0,0 @@ | |||
| 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@ | |||
| @@ -1,100 +0,0 @@ | |||
| <?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> | |||
| @@ -1,60 +0,0 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxAuthorizerInfoMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxAuthorizerInfo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="authorizer_appid" jdbcType="VARCHAR" property="authorizerAppid" /> | |||
| <result column="head_img" jdbcType="VARCHAR" property="headImg" /> | |||
| <result column="alias" jdbcType="VARCHAR" property="alias" /> | |||
| <result column="qrcode_url" jdbcType="VARCHAR" property="qrcodeUrl" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||
| <result column="authorization_status" jdbcType="INTEGER" property="authorizationStatus" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`authorizer_appid`,`head_img`,`alias`,`qrcode_url`,`create_time`,`authorization_status` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != authorizerAppid "> | |||
| and `authorizer_appid` like concat('%', #{authorizerAppid},'%') | |||
| </if> | |||
| <if test=" null != headImg "> | |||
| and `head_img` like concat('%', #{headImg},'%') | |||
| </if> | |||
| <if test=" null != alias "> | |||
| and `alias` like concat('%', #{alias},'%') | |||
| </if> | |||
| <if test=" null != qrcodeUrl "> | |||
| and `qrcode_url` like concat('%', #{qrcodeUrl},'%') | |||
| </if> | |||
| <if test=" null != createTime "> | |||
| and `create_time` = #{createTime} | |||
| </if> | |||
| <if test=" null != authorizationStatus "> | |||
| and `authorization_status` = #{authorizationStatus} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxAuthorizerInfo" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_authorizer_info | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -1,52 +0,0 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxComponentVerifyTicketMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxComponentVerifyTicket"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="component_appid" jdbcType="VARCHAR" property="componentAppid" /> | |||
| <result column="component_verify_ticket" jdbcType="VARCHAR" property="componentVerifyTicket" /> | |||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> | |||
| <result column="deadline" jdbcType="TIMESTAMP" property="deadline" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`component_appid`,`component_verify_ticket`,`create_time`,`deadline` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != componentAppid "> | |||
| and `component_appid` like concat('%', #{componentAppid},'%') | |||
| </if> | |||
| <if test=" null != componentVerifyTicket "> | |||
| and `component_verify_ticket` like concat('%', #{componentVerifyTicket},'%') | |||
| </if> | |||
| <if test=" null != createTime "> | |||
| and `create_time` = #{createTime} | |||
| </if> | |||
| <if test=" null != deadline "> | |||
| and `deadline` = #{deadline} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxComponentVerifyTicket" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_component_verify_ticket | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -17,7 +17,6 @@ | |||
| <module>mallinkCApi</module> | |||
| <module>mallinkBApi</module> | |||
| <module>mallinkSchedule</module> | |||
| <module>mallinkWechatOpen</module> | |||
| </modules> | |||
| <parent> | |||