forked from rongchao/epmet-cloud-rizhao
20 changed files with 642 additions and 22 deletions
@ -0,0 +1,80 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import com.alibaba.fastjson.annotation.JSONField; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @description: 微信订阅消息FormDTO |
||||
|
* @author: liushaowen |
||||
|
* @date: 2020/10/21 14:29 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class WxSubscribeMessageFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 客户id |
||||
|
*/ |
||||
|
@NotBlank(message = "客户id不能为空") |
||||
|
private String customerId; |
||||
|
/** |
||||
|
* 客户端类型 居民端:resi 工作端:work |
||||
|
*/ |
||||
|
@NotBlank(message = "客户端类型不能为空") |
||||
|
private String clientType; |
||||
|
|
||||
|
/** |
||||
|
* 接收者(用户)的 userId |
||||
|
*/ |
||||
|
@NotBlank(message = "接收用户id不能为空") |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 行为类型(存title字段的中间值) 入组申请、党员认证等 |
||||
|
*/ |
||||
|
@NotBlank(message = "行为类型不能为空") |
||||
|
private String behaviorType; |
||||
|
|
||||
|
/** |
||||
|
* 消息内容 |
||||
|
*/ |
||||
|
@NotBlank(message = "消息内容不能为空") |
||||
|
private String messageContent; |
||||
|
|
||||
|
/** |
||||
|
* 消息时间 |
||||
|
*/ |
||||
|
@NotNull(message = "消息时间不能为空") |
||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss") |
||||
|
private Date messageTime; |
||||
|
|
||||
|
/** |
||||
|
* 所需下发的订阅模板id |
||||
|
*/ |
||||
|
@NotBlank(message = "模板id不能为空") |
||||
|
private String templateId; |
||||
|
|
||||
|
/** |
||||
|
* 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。 |
||||
|
*/ |
||||
|
private String page; |
||||
|
|
||||
|
/** |
||||
|
* 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 |
||||
|
*/ |
||||
|
private String miniprogramState; |
||||
|
|
||||
|
/** |
||||
|
* 进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN |
||||
|
*/ |
||||
|
private String lang; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,50 @@ |
|||||
|
package com.epmet.constant; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @description: 微信订阅消息常量 |
||||
|
* @author: liushaowen |
||||
|
* @date: 2020/10/21 17:45 |
||||
|
*/ |
||||
|
|
||||
|
public interface WxmpMessageConstant { |
||||
|
String SEND_MESSAGE = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token="; |
||||
|
|
||||
|
String ERR_CODE = "errcode"; |
||||
|
|
||||
|
String ERR_MSG = "errmsg"; |
||||
|
|
||||
|
int USER_REFUSED = 43101; |
||||
|
|
||||
|
String AUTHORIZER_ACCESS_TOKEN = "authorizer_access_token"; |
||||
|
|
||||
|
String RESI = "resi"; |
||||
|
|
||||
|
String WORK = "work"; |
||||
|
|
||||
|
String ACCESS_TOKEN = "access_token"; |
||||
|
|
||||
|
String TOUSER = "touser"; |
||||
|
|
||||
|
String TEMPLATE_ID = "template_id"; |
||||
|
|
||||
|
String PAGE = "page"; |
||||
|
|
||||
|
String TITLE = "title"; |
||||
|
|
||||
|
String MESSAGE_CONTENT = "message_content"; |
||||
|
|
||||
|
String MESSAGE_TIME = "message_time"; |
||||
|
|
||||
|
String DATA = "data"; |
||||
|
|
||||
|
String MINIPROGRAM_STATE = "miniprogram_state"; |
||||
|
|
||||
|
String LANG = "lang"; |
||||
|
|
||||
|
String SUCCESS = "success"; |
||||
|
|
||||
|
String ERROR = "error"; |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package com.epmet.exception; |
||||
|
|
||||
|
/** |
||||
|
* @description: |
||||
|
* @author: liushaowen |
||||
|
* @date: 2020/10/22 11:07 |
||||
|
*/ |
||||
|
|
||||
|
public class WxSubscribeException extends Exception { |
||||
|
private String openId; |
||||
|
|
||||
|
/** |
||||
|
* Constructs a new exception with the specified detail message. The |
||||
|
* cause is not initialized, and may subsequently be initialized by |
||||
|
* a call to {@link #initCause}. |
||||
|
* |
||||
|
* @param message the detail message. The detail message is saved for |
||||
|
* later retrieval by the {@link #getMessage()} method. |
||||
|
*/ |
||||
|
public WxSubscribeException(String message, String openId) { |
||||
|
super(message); |
||||
|
this.openId = openId; |
||||
|
} |
||||
|
|
||||
|
public String getOpenId() { |
||||
|
return openId; |
||||
|
} |
||||
|
|
||||
|
public void setOpenId(String openId) { |
||||
|
this.openId = openId; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package com.epmet.redis; |
||||
|
|
||||
|
import com.epmet.commons.tools.redis.RedisUtils; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @description: 微信订阅Redis |
||||
|
* @author: liushaowen |
||||
|
* @date: 2020/10/21 15:28 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component |
||||
|
public class WxmpMessageRedis { |
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
/** |
||||
|
* @Description 获取刷新 |
||||
|
* @param key = epmet:wechartthird:authorizerrefreshtoken:customerId:clientType 前缀+客户ID+客户端类型 |
||||
|
* @author zxc |
||||
|
*/ |
||||
|
public Map<String,Object> getAuthorizerRefreshToken(String key){ |
||||
|
Map<String, Object> result = redisUtils.hGetAll("epmet:wechartthird:authorizerrefreshtoken:" + key); |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue