消息发布重构方法 增加业务参数
This commit is contained in:
@ -33,4 +33,6 @@ public class MessageRaw {
|
||||
/* 授权用户列表 */
|
||||
private List<String> users;
|
||||
|
||||
/* 业务参数 */
|
||||
private Map<String, Object> servicecode;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class BizMessagePublisher {
|
||||
/**
|
||||
* 广播消息
|
||||
*
|
||||
* @param tilte 消息标题
|
||||
* @param title 消息标题
|
||||
* @param category 消息类别
|
||||
* @param templateCode 消息模板编码
|
||||
* @param body 消息内容
|
||||
@ -40,7 +40,7 @@ public class BizMessagePublisher {
|
||||
/**
|
||||
* 像指定用户群发布消息
|
||||
*
|
||||
* @param tilte 消息标题
|
||||
* @param title 消息标题
|
||||
* @param category 消息类别
|
||||
* @param templateCode 消息模板编码
|
||||
* @param body 消息内容
|
||||
@ -50,7 +50,24 @@ public class BizMessagePublisher {
|
||||
*/
|
||||
public Optional<MessageResult> publishToSpecialUsers(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params, List<String> grantUsers) {
|
||||
return publishMessage(title, category, templateCode, body, params, grantUsers);
|
||||
return this.publishToSpecialUsers(title,category,templateCode,body,params,grantUsers,null);
|
||||
}
|
||||
/**
|
||||
* 像指定用户群发布消息
|
||||
*
|
||||
* @param title 消息标题
|
||||
* @param category 消息类别
|
||||
* @param templateCode 消息模板编码
|
||||
* @param body 消息内容
|
||||
* @param params 消息参数
|
||||
* @param grantUsers 目标用户列表
|
||||
* @param servicecode 业务参数
|
||||
* @return 消息结果
|
||||
*/
|
||||
public Optional<MessageResult> publishToSpecialUsers(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params,
|
||||
List<String> grantUsers,Map<String, Object> servicecode) {
|
||||
return publishMessage(title, category, templateCode, body, params, grantUsers,servicecode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,8 +87,30 @@ public class BizMessagePublisher {
|
||||
Assert.notNull(body, "消息内容为空");
|
||||
Assert.notNull(params, "消息参数为空");
|
||||
|
||||
return this.publishMessage(title,category,templateCode,body,params,grantUsers,null);
|
||||
}
|
||||
/**
|
||||
* @param title
|
||||
* @param category
|
||||
* @param templateCode
|
||||
* @param body
|
||||
* @param params
|
||||
* @param grantUsers
|
||||
* @param servicecode 业务参数
|
||||
* @return
|
||||
*/
|
||||
private Optional<MessageResult> publishMessage(String title, String category, String templateCode,
|
||||
Map<String, Object> body, Map<String, Object> params, List<String> grantUsers,
|
||||
Map<String, Object> servicecode) {
|
||||
Assert.notNull(title, "消息标题为空");
|
||||
Assert.notNull(category, "消息类别编号为空");
|
||||
Assert.notNull(templateCode, "模板编号为空");
|
||||
Assert.notNull(body, "消息内容为空");
|
||||
Assert.notNull(params, "消息参数为空");
|
||||
Assert.notNull(servicecode, "业务参数为空");
|
||||
|
||||
return client.postMessage(new MessageRaw().setTitle(title).setCategory(category)
|
||||
.setTemplateCode(templateCode).setBody(body).setExtra(params).setUsers(grantUsers));
|
||||
.setTemplateCode(templateCode).setBody(body).setExtra(params).setUsers(grantUsers).setServicecode(servicecode));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user