Search in sources :

Example 1 with TextMessage

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);
}
Also used : ActionCardMessage(com.jeecg.dingtalk.api.message.vo.ActionCardMessage) Message(com.jeecg.dingtalk.api.message.vo.Message) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage)

Example 2 with TextMessage

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);
}
Also used : ActionCardMessage(com.jeecg.dingtalk.api.message.vo.ActionCardMessage) Message(com.jeecg.dingtalk.api.message.vo.Message) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage)

Example 3 with TextMessage

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);
}
Also used : ActionCardMessage(com.jeecg.dingtalk.api.message.vo.ActionCardMessage) Message(com.jeecg.dingtalk.api.message.vo.Message) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage) TextMessage(com.jeecg.dingtalk.api.message.vo.TextMessage)

Aggregations

ActionCardMessage (com.jeecg.dingtalk.api.message.vo.ActionCardMessage)3 Message (com.jeecg.dingtalk.api.message.vo.Message)3 TextMessage (com.jeecg.dingtalk.api.message.vo.TextMessage)3