飞书通知优化及添加会销协作人通知增加移动端跳转
This commit is contained in:
@@ -86,19 +86,18 @@ public class EventCenterHttpRequest {
|
||||
public void sendFeiShuNotice(FeiShuNoticeMsgEnum msgEnum, List<String> receiverIds, Object... objects) throws ApiException {
|
||||
//1. 组织消息参数,SendMsgRequest 的 cardParams,需要填入的参数为模板中 ${} 中的参数
|
||||
HashMap<String, String> cardParams = new HashMap<>();
|
||||
String pathVariable = getPathVariable(msgEnum, objects);
|
||||
String PCPath = null;
|
||||
String mobilePath = null;
|
||||
String PCPath = getPath(msgEnum.getPCPath(), false, objects);
|
||||
String mobilePath = getPath(msgEnum.getMobilePath(), true, objects);
|
||||
try {
|
||||
PCPath = URLEncoder.encode(msgEnum.getPCPath() + pathVariable, "UTF-8");
|
||||
mobilePath = URLEncoder.encode(msgEnum.getMobilePath() + pathVariable, "UTF-8");
|
||||
PCPath = URLEncoder.encode(PCPath, "UTF-8");
|
||||
mobilePath = URLEncoder.encode(mobilePath, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ApiException("URL 编码错误");
|
||||
}
|
||||
String PCWholePath = PCLinkUrl + PCPath;
|
||||
String mobileWholePath = mobileLinkUrl + mobilePath;
|
||||
cardParams.put("title", msgEnum.getTitle());
|
||||
cardParams.put("content", MessageFormat.format(msgEnum.getContent(),objects));
|
||||
cardParams.put("content", MessageFormat.format(msgEnum.getContent(), objects));
|
||||
cardParams.put("img_key", msgEnum.getImageMediaId());
|
||||
cardParams.put("common_url", PCWholePath);
|
||||
cardParams.put("pc_url", PCWholePath);
|
||||
@@ -168,25 +167,25 @@ public class EventCenterHttpRequest {
|
||||
createSingleEvent(createEventRequest);
|
||||
}
|
||||
|
||||
private String getPathVariable(FeiShuNoticeMsgEnum msgEnum, Object... objects) {
|
||||
StringBuilder pathVariable = new StringBuilder();
|
||||
switch (msgEnum) {
|
||||
case EXHIBITION_COLLABORATOR:
|
||||
pathVariable.append("?id=").append(objects[0]);
|
||||
System.arraycopy(objects, 1, objects, 0, objects.length - 1);
|
||||
break;
|
||||
case PARTNER_SIGNUP_EXHIBITION:
|
||||
pathVariable.append("?lineId=")
|
||||
.append(objects[0])
|
||||
.append("&clueType=private")
|
||||
.append("&partnerId=")
|
||||
.append(objects[1]);
|
||||
System.arraycopy(objects, 2, objects, 0, objects.length - 2);
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
/**
|
||||
* 根据消息路径模板返回格式化参数后的路径
|
||||
* @param pathPattern 路径模板
|
||||
* @param whetherSpliceParamsArray 是否裁剪参数,将数组用于格式化的参数从数组中裁剪
|
||||
* @param objects 参数数组
|
||||
* @return 格式化后的带参数路径
|
||||
*/
|
||||
private String getPath(String pathPattern, boolean whetherSpliceParamsArray, Object... objects) {
|
||||
//无需格式化
|
||||
if (!pathPattern.contains("{0}")) {
|
||||
return pathPattern;
|
||||
}
|
||||
return new String(pathVariable);
|
||||
MessageFormat messageFormat = new MessageFormat(pathPattern);
|
||||
int paramsCount = messageFormat.getFormatsByArgumentIndex().length;
|
||||
String wholePath = messageFormat.format(objects);
|
||||
if (whetherSpliceParamsArray) {
|
||||
System.arraycopy(objects, paramsCount, objects, 0, objects.length - paramsCount);
|
||||
}
|
||||
return wholePath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user