use of com.jeecg.dingtalk.api.message.vo.TextMessage in project jeecg-boot by jeecgboot.
the class ThirdAppDingtalkServiceImpl method sendMessageResponse.
public Response<String> sendMessageResponse(MessageDTO message, boolean verifyConfig) {
if (verifyConfig && !thirdAppConfig.isDingtalkEnabled()) {
return null;
}
String accessToken = this.getAccessToken();
if (accessToken == null) {
return null;
}
// 封装钉钉消息
String content = message.getContent();
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
Message<TextMessage> textMessage = new Message<>(agentId, new TextMessage(content));
if (message.isToAll()) {
textMessage.setTo_all_user(true);
} else {
String[] toUsers = message.getToUser().split(",");
// 通过第三方账号表查询出第三方userId
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, THIRD_TYPE);
List<String> dtUserIds = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
textMessage.setUserid_list(dtUserIds);
}
return JdtMessageAPI.sendTextMessage(textMessage, accessToken);
}
use of com.jeecg.dingtalk.api.message.vo.TextMessage in project kms by mahonelau.
the class ThirdAppDingtalkServiceImpl method sendMessageResponse.
public Response<String> sendMessageResponse(MessageDTO message, boolean verifyConfig) {
if (verifyConfig && !thirdAppConfig.isDingtalkEnabled()) {
return null;
}
String accessToken = this.getAccessToken();
if (accessToken == null) {
return null;
}
// 封装钉钉消息
String content = message.getContent();
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
Message<TextMessage> textMessage = new Message<>(agentId, new TextMessage(content));
if (message.isToAll()) {
textMessage.setTo_all_user(true);
} else {
String[] toUsers = message.getToUser().split(",");
// 通过第三方账号表查询出第三方userId
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, ThirdAppConfig.DINGTALK.toLowerCase());
List<String> dtUserIds = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
textMessage.setUserid_list(dtUserIds);
}
return JdtMessageAPI.sendTextMessage(textMessage, accessToken);
}
use of com.jeecg.dingtalk.api.message.vo.TextMessage in project kykms by mahonelau.
the class ThirdAppDingtalkServiceImpl method sendMessageResponse.
public Response<String> sendMessageResponse(MessageDTO message, boolean verifyConfig) {
if (verifyConfig && !thirdAppConfig.isDingtalkEnabled()) {
return null;
}
String accessToken = this.getAccessToken();
if (accessToken == null) {
return null;
}
// 封装钉钉消息
String content = message.getContent();
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
Message<TextMessage> textMessage = new Message<>(agentId, new TextMessage(content));
if (message.isToAll()) {
textMessage.setTo_all_user(true);
} else {
String[] toUsers = message.getToUser().split(",");
// 通过第三方账号表查询出第三方userId
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, ThirdAppConfig.DINGTALK.toLowerCase());
List<String> dtUserIds = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
textMessage.setUserid_list(dtUserIds);
}
return JdtMessageAPI.sendTextMessage(textMessage, accessToken);
}
Aggregations