Search in sources :

Example 1 with WeChatSender

use of org.hzero.boot.message.entity.WeChatSender in project choerodon-message by open-hand.

the class RelSendMessageController method sendAllMessageWithReceipt.

@ApiOperation(value = "关联发送消息,邮件/短信/站内信/微信/钉钉(返回发送结果,若服务端开启了异步发送则不返回)")
@Permission(level = ResourceLevel.ORGANIZATION)
@PostMapping("/all/with-receipt")
public ResponseEntity<List<Message>> sendAllMessageWithReceipt(@PathVariable("organizationId") Long organizationId, @RequestBody @Encrypt AllSender sender) {
    List<Message> result = new ArrayList<>();
    MessageSender messageSender = sender.getMessageSender();
    WeChatSender weChatSender = sender.getWeChatSender();
    DingTalkSender dingTalkSender = sender.getDingTalkSender();
    if (messageSender != null) {
        messageSender.setTenantId(organizationId);
        validObject(messageSender);
        result.addAll(relSendMessageService.relSendMessageReceipt(messageSender, organizationId));
    }
    if (weChatSender != null) {
        weChatSender.setTenantId(organizationId);
        validObject(weChatSender);
        weChatSender.setLang(StringUtils.hasText(weChatSender.getLang()) ? weChatSender.getLang() : messageClientProperties.getDefaultLang());
        result.addAll(relSendMessageService.relSendMessageReceipt(weChatSender));
    }
    if (dingTalkSender != null) {
        dingTalkSender.setTenantId(organizationId);
        validObject(dingTalkSender);
        dingTalkSender.setLang(StringUtils.hasText(dingTalkSender.getLang()) ? dingTalkSender.getLang() : messageClientProperties.getDefaultLang());
        result.addAll(relSendMessageService.relSendMessageReceipt(dingTalkSender));
    }
    return Results.success(result);
}
Also used : WeChatSender(org.hzero.boot.message.entity.WeChatSender) Message(org.hzero.message.domain.entity.Message) MessageSender(org.hzero.boot.message.entity.MessageSender) ArrayList(java.util.ArrayList) DingTalkSender(org.hzero.boot.message.entity.DingTalkSender) ApiOperation(io.swagger.annotations.ApiOperation) Permission(io.choerodon.swagger.annotation.Permission)

Example 2 with WeChatSender

use of org.hzero.boot.message.entity.WeChatSender in project choerodon-message by open-hand.

the class RelSendMessageController method sendAllMessage.

@ApiOperation(value = "关联发送消息,邮件/短信/站内信/微信/钉钉")
@Permission(level = ResourceLevel.ORGANIZATION)
@PostMapping("/all")
public ResponseEntity<Map<String, Integer>> sendAllMessage(@PathVariable("organizationId") Long organizationId, @RequestBody @Encrypt AllSender sender) {
    Map<String, Integer> result = new HashMap<>(16);
    MessageSender messageSender = sender.getMessageSender();
    WeChatSender weChatSender = sender.getWeChatSender();
    DingTalkSender dingTalkSender = sender.getDingTalkSender();
    if (messageSender != null) {
        messageSender.setTenantId(organizationId);
        validObject(messageSender);
        result.putAll(relSendMessageService.relSendMessage(messageSender, organizationId));
    }
    if (weChatSender != null) {
        weChatSender.setTenantId(organizationId);
        validObject(weChatSender);
        weChatSender.setLang(StringUtils.hasText(weChatSender.getLang()) ? weChatSender.getLang() : messageClientProperties.getDefaultLang());
        result.putAll(relSendMessageService.relSendMessage(weChatSender));
    }
    if (dingTalkSender != null) {
        dingTalkSender.setTenantId(organizationId);
        validObject(dingTalkSender);
        dingTalkSender.setLang(StringUtils.hasText(dingTalkSender.getLang()) ? dingTalkSender.getLang() : messageClientProperties.getDefaultLang());
        result.putAll(relSendMessageService.relSendMessage(dingTalkSender));
    }
    return Results.success(result);
}
Also used : WeChatSender(org.hzero.boot.message.entity.WeChatSender) HashMap(java.util.HashMap) MessageSender(org.hzero.boot.message.entity.MessageSender) DingTalkSender(org.hzero.boot.message.entity.DingTalkSender) ApiOperation(io.swagger.annotations.ApiOperation) Permission(io.choerodon.swagger.annotation.Permission)

Aggregations

Permission (io.choerodon.swagger.annotation.Permission)2 ApiOperation (io.swagger.annotations.ApiOperation)2 DingTalkSender (org.hzero.boot.message.entity.DingTalkSender)2 MessageSender (org.hzero.boot.message.entity.MessageSender)2 WeChatSender (org.hzero.boot.message.entity.WeChatSender)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Message (org.hzero.message.domain.entity.Message)1