This commit is contained in:
ran.shang
2025-06-11 09:42:13 +08:00
commit 7e38b8d971
1935 changed files with 132836 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package com.newyetai.sdk.workwechat.util;
import java.util.Map;
import com.google.common.collect.Maps;
import com.newyetai.sdk.robot.constant.WorkWechatMsgTypeEnum;
import com.newyetai.sdk.robot.model.IWorkWechatMsg;
import com.newyetai.sdk.workwechat.model.WwrTextMsg;
/**
* @author sr on 2020-07-06
*/
public class WorkWechatUtils {
private static final String MSG_TYPE = "msgtype";
/**
* 转换消息发送对象数据
*
* @param msg
* @return
* @author sr on 2020-07-06
*/
public static Map<String, Object> parsePostData(IWorkWechatMsg msg) {
Map<String, Object> data = Maps.newHashMap();
String msgType = msg.getMsgType();
data.put(MSG_TYPE, msgType);
if (WorkWechatMsgTypeEnum.TEXT.getType().equals(msgType)) {
// 文本消息截取500长度
WwrTextMsg textMsg = (WwrTextMsg) msg;
String context = textMsg.getContent();
if (context.length() > 500) {
textMsg.setContent(textMsg.getContent().substring(0, 500));
}
}
data.put(msgType, msg);
return data;
}
}