REQ-3201: 指定发送人

This commit is contained in:
yanglin 2024-12-26 12:36:05 +08:00
parent d0578022b9
commit 9be0b55009
2 changed files with 6 additions and 6 deletions

View File

@ -25,6 +25,7 @@ public class SendTemplateMessageParam {
/** /**
* 发送人 * 发送人
*/ */
@NotBlank(message = "发送人不能为空")
private PersonAccountAttribute sender; private PersonAccountAttribute sender;
/** /**
@ -47,6 +48,7 @@ public class SendTemplateMessageParam {
/** /**
* 消息模板ID * 消息模板ID
*/ */
@NotBlank(message = "消息模板ID不能为空")
private String msgTemplateId; private String msgTemplateId;
/** /**

View File

@ -40,7 +40,6 @@ import cn.axzo.im.service.RobotMsgTemplateService;
import cn.axzo.im.updatable.UpdatableMessageManager; import cn.axzo.im.updatable.UpdatableMessageManager;
import cn.axzo.im.updatable.UpdatableMessageQueryService; import cn.axzo.im.updatable.UpdatableMessageQueryService;
import cn.axzo.im.updatable.UpdateSupport; import cn.axzo.im.updatable.UpdateSupport;
import cn.axzo.im.utils.BizAssertions;
import cn.axzo.pokonyan.exception.Aassert; import cn.axzo.pokonyan.exception.Aassert;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -178,20 +177,19 @@ public class MessageController implements MessageApi {
@Transactional @Transactional
public ApiResult<MessageTaskResp> sendTemplateMessageAsync(SendTemplateMessageParam request) { public ApiResult<MessageTaskResp> sendTemplateMessageAsync(SendTemplateMessageParam request) {
log.info("sendTemplateMessageAsync, request={}", request); log.info("sendTemplateMessageAsync, request={}", request);
String templateImAccount = check(request);
PersonAccountAttribute sender = request.getSender(); PersonAccountAttribute sender = request.getSender();
BizAssertions.assertTrue(sender != null || StringUtils.isNotBlank(request.getMsgTemplateId()),
"消息模板ID和发送人必须选其一");
String sendImAccount; String sendImAccount;
if (sender != null) { if (sender.getAppType() != null) {
AccountAbsentQuery accountQuery = new AccountAbsentQuery(); AccountAbsentQuery accountQuery = new AccountAbsentQuery();
accountQuery.setAppType(sender.getAppType().getCode()); accountQuery.setAppType(sender.getAppType().getCode());
accountQuery.setPersonId(sender.getPersonId()); accountQuery.setPersonId(sender.getPersonId());
accountQuery.setOuId(sender.getOuId()); accountQuery.setOuId(sender.getOuId());
accountQuery.setAppType(sender.getAppType().getCode());
List<UserAccountResp> accounts = accountService.registerAccountIfAbsent(accountQuery); List<UserAccountResp> accounts = accountService.registerAccountIfAbsent(accountQuery);
sendImAccount = accounts.get(0).getImAccount(); sendImAccount = accounts.get(0).getImAccount();
} else { } else {
//todo: 根据类型验证模版是否配置了机器人 sendImAccount = templateImAccount;
sendImAccount = check(request);
} }
MessageTask.BizData bizData = MessageTask.BizData.builder() MessageTask.BizData bizData = MessageTask.BizData.builder()