|
|
|
@ -1,14 +1,22 @@
|
|
|
|
|
package com.java3y.austin.web.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.java3y.austin.common.enums.RespStatusEnum;
|
|
|
|
|
import com.java3y.austin.service.api.domain.BatchSendRequest;
|
|
|
|
|
import com.java3y.austin.service.api.domain.SendRequest;
|
|
|
|
|
import com.java3y.austin.service.api.domain.SendResponse;
|
|
|
|
|
import com.java3y.austin.service.api.service.RecallService;
|
|
|
|
|
import com.java3y.austin.service.api.service.SendService;
|
|
|
|
|
import com.java3y.austin.web.annotation.AustinAspect;
|
|
|
|
|
import com.java3y.austin.web.exception.CommonException;
|
|
|
|
|
import com.java3y.austin.web.interceptor.TokenInterceptor;
|
|
|
|
|
import com.java3y.austin.web.service.MessageTemplateService;
|
|
|
|
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
@ -29,6 +37,9 @@ public class SendController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private RecallService recallService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MessageTemplateService messageTemplateService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单个文案下发相同的人
|
|
|
|
@ -39,6 +50,9 @@ public class SendController {
|
|
|
|
|
@ApiOperation(value = "下发接口", notes = "多渠道多类型下发消息,目前支持邮件和短信,类型支持:验证码、通知类、营销类。")
|
|
|
|
|
@PostMapping("/send")
|
|
|
|
|
public SendResponse send(@RequestBody SendRequest sendRequest) {
|
|
|
|
|
if(!messageTemplateService.hasPermission(Collections.singleton(sendRequest.getMessageTemplateId()), TokenInterceptor.CREAT_THREAD_LOCAL.get())) {
|
|
|
|
|
throw new CommonException(RespStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), RespStatusEnum.CLIENT_BAD_PARAMETERS.getMsg());
|
|
|
|
|
}
|
|
|
|
|
return sendService.send(sendRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -51,6 +65,9 @@ public class SendController {
|
|
|
|
|
@ApiOperation(value = "batch下发接口", notes = "多渠道多类型下发消息,目前支持邮件和短信,类型支持:验证码、通知类、营销类。")
|
|
|
|
|
@PostMapping("/batchSend")
|
|
|
|
|
public SendResponse batchSend(@RequestBody BatchSendRequest batchSendRequest) {
|
|
|
|
|
if(!messageTemplateService.hasPermission(Collections.singleton(batchSendRequest.getMessageTemplateId()), TokenInterceptor.CREAT_THREAD_LOCAL.get())) {
|
|
|
|
|
throw new CommonException(RespStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), RespStatusEnum.CLIENT_BAD_PARAMETERS.getMsg());
|
|
|
|
|
}
|
|
|
|
|
return sendService.batchSend(batchSendRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,6 +80,9 @@ public class SendController {
|
|
|
|
|
@ApiOperation(value = "撤回消息接口", notes = "优先根据messageId撤回消息,如果messageId不存在则根据模板id撤回")
|
|
|
|
|
@PostMapping("/recall")
|
|
|
|
|
public SendResponse recall(@RequestBody SendRequest sendRequest) {
|
|
|
|
|
if(!messageTemplateService.hasPermission(Collections.singleton(sendRequest.getMessageTemplateId()), TokenInterceptor.CREAT_THREAD_LOCAL.get())) {
|
|
|
|
|
throw new CommonException(RespStatusEnum.CLIENT_BAD_PARAMETERS.getCode(), RespStatusEnum.CLIENT_BAD_PARAMETERS.getMsg());
|
|
|
|
|
}
|
|
|
|
|
return recallService.recall(sendRequest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|