1.6.0版本消息调整
短信增强
#pai-common-mc
短信发送
配置
application.yml or nacos->pai-xxx-xx.yaml
pai:
sms:
enable: true
fixed-code: 1234
配置介绍
pai.sms.enable=false,默认值是true,false的时候关闭短信的发送
pai.sms.fixed-code,默认值是1234,使用verificationGeneratorHelper工具类获取随机的验证码
当enable为false的时候,验证码是当前设置的fixedCode
代码示例
注入工具类
@Resource
private VerificationGeneratorHelper verificationGeneratorHelper;
//获取数字的验证码
String code = verificationGeneratorHelper.getNumberCode();
String code = verificationGeneratorHelper.getNumberCode(Integer);
//获取字符的随机验证码
String code = verificationGeneratorHelper.getCode();
String code = verificationGeneratorHelper.getCode(Integer);
1.1.0版本后的配置
从1.1.0版本开始,我们将采用配置页面标识字段和业务标识字段来实现消息跳转。
如果涉及消息页面跳转,则必须要配置页面标识
即页面管理中的页面标识(开发者后台->应用套件->页面管理)- pageWebId
用于PC端消息跳转 - pageAppId
用于小程序消息跳转 - pageH5Id
用于小程序消息H5页面跳转
- pageWebId
业务标识字段则根据业务需求自行决定,可填可不填。
- actionCode
用于页面根据不同的业务消息作出不同的显示或操作
比如说:流程的待办消息、已办消息,它所对应的业务标识就是todo、done
- actionCode
示例:
HashMap<String, String> map = new HashMap<>(7);
// 设置业务标识
map.put("actionCode", actionCode);
//设置页面标识
map.put("pageAppId", properties.getPageAppId());
map.put("pageWebId", properties.getPageWebId());
map.put("pageH5Id", properties.getPageH5Id());
//消息实体类
innerUserBody.setParam(map);
innerUser对象调整
参数说明:
businessSystemId :填写套件的标识
categoryCode :模版编号
priority :紧急程度 PriorityEnum
sendUserName :发送人的名称
sendUserOrgId :发送人的组织
receiveUserType : ”user“ “staff”,关系到ReceiveUser 接收人的id
receiveUserIds :接受人的id
pageAppId :app的页面id
pageH5Id :h5的页面id
pageWebId:pc的页面id
imageUrl :富文本的可以通过传递图片url来覆盖模版的图片
param :模版中的参数内容 {title}
事例:
String moban = "MP_10000205";
String title = "柬媒评论:中国不应是唯一的新冠溯源目标";
String content = "近日,,新冠病毒防范疫情被政治化。……";
InnerUserBody innerUserBody = InnerUserBody.builder()
.businessSystemId("cn.flyrise.cy")
.categoryCode(moban)
.enterpriseId(loginUser.getEntId())
.sendUserId(uid)
.priority(PriorityEnum.EXTRA_URGENT)
.sendUserName("系统管理员")
.sendUserOrgId()
.sendUserOrgName()
.receiveUserType("user")
.receiveUserIds(new String[]{loginUser.getUserId()})
.pageAppId("xxx")
.imageUrl("https://inews.gtimg.com/newsapp_bt/0/13890773403/1000")
.pageH5Id("H5Id")
.param("param1", "value1")
.param("param2", "value2")
.build();
消息发送的状态订阅
需要通过套件去订阅mc_result 主题,并且businessSystemId 填写套件的标识,其他配置参考消息订阅能力
@PulsarListener(suiteKey = "cn.flyrise.mc",topic = "mc_result")
public void consumer2(PulsarMessage<String> string) {
System.out.println("PulsarConsumer Listener3: !!! msg:"+string.getValue());
}
1.1.0版本前的配置
在1.1.0版本前,我们需要配置消息跳转的页面路径、小程序ID,如下方:
//新建模板时得到的消息编号
public final static String CATEGORY_CODE = "MP_10000021";
//自定义的pc端跳转页面,不同套件跳转页面不同
public final static String WS_URL = "http://pai.flyrise.cn/cloud-attendance/exception-list";
//自定义的app端跳转页面,不同套件跳转页面不同
public final static String JPUSH_URL = "pages/sign-in/sign-calendar";
//app端跳转页面为小程序时,需配置小程序ID
public final static String MIRCO_APP_ID = "__UNI__3D0884F";
从1.1.0版本开始,我们不再支持这种的写法,如果你仍使用1.1.0版本前的配置,请调整为1.1.0版本后的写法。