1
This commit is contained in:
@@ -133,6 +133,26 @@ public class WXUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据unionId获取SuperAdmin的接收人列表
|
||||
* @param unionId 联盟ID
|
||||
* @return 接收人列表(企业微信用户ID,多个用逗号分隔),如果未配置则返回null
|
||||
*/
|
||||
public static String getTouserByUnionId(String unionId) {
|
||||
if (unionId == null || unionId.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (SuperAdmin admin : super_admins.values()) {
|
||||
if (unionId.equals(admin.getUnionId())) {
|
||||
String touser = admin.getTouser();
|
||||
if (touser != null && !touser.trim().isEmpty()) {
|
||||
return touser.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> splitStringByLength(String input, int length) {
|
||||
List<String> result = new ArrayList<>();
|
||||
@@ -218,6 +238,10 @@ public class WXUtil {
|
||||
}
|
||||
|
||||
public void sendTextMessage(String wxid, String content, Integer msgType, String fromwxid, Boolean hiddenTime) {
|
||||
sendTextMessage(wxid, content, msgType, fromwxid, hiddenTime, null);
|
||||
}
|
||||
|
||||
public void sendTextMessage(String wxid, String content, Integer msgType, String fromwxid, Boolean hiddenTime, String touser) {
|
||||
// 全部打印
|
||||
//logger.info("发送文本消息 msgType: {} wxid: {} fromwxid: {} content: {}", msgType, wxid, fromwxid, content);
|
||||
// 先在content顶部插入时间戳
|
||||
@@ -264,6 +288,10 @@ public class WXUtil {
|
||||
data.put("msgType", msgType);
|
||||
data.put("fromWxid", fromwxid);
|
||||
data.put("hiddenTime", hiddenTime);
|
||||
// 如果提供了接收人列表,添加到数据中
|
||||
if (touser != null && !touser.trim().isEmpty()) {
|
||||
data.put("touser", touser.trim());
|
||||
}
|
||||
wxReqDate.setData(data);
|
||||
// wxReqDate 转成 JSONObject
|
||||
JSONObject message = JSON.parseObject(JSON.toJSONString(wxReqDate));
|
||||
|
||||
Reference in New Issue
Block a user