潘志宝
2024-12-23 5bf42aa9950058f391805e6fb8d7376f4378924b
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.controller.admin.sms;
H 2
3 import com.iailab.framework.common.pojo.CommonResult;
4 import com.iailab.framework.common.util.servlet.ServletUtils;
5 import com.iailab.module.system.framework.sms.core.enums.SmsChannelEnum;
6 import com.iailab.module.system.service.sms.SmsSendService;
7 import io.swagger.v3.oas.annotations.Operation;
8 import io.swagger.v3.oas.annotations.tags.Tag;
9 import org.springframework.web.bind.annotation.PostMapping;
10 import org.springframework.web.bind.annotation.RequestMapping;
11 import org.springframework.web.bind.annotation.RestController;
12
13 import javax.annotation.Resource;
14 import javax.annotation.security.PermitAll;
15 import javax.servlet.http.HttpServletRequest;
16
17 import static com.iailab.framework.common.pojo.CommonResult.success;
18
19 @Tag(name = "管理后台 - 短信回调")
20 @RestController
21 @RequestMapping("/system/sms/callback")
22 public class SmsCallbackController {
23
24     @Resource
25     private SmsSendService smsSendService;
26
27     @PostMapping("/aliyun")
28     @PermitAll
29     @Operation(summary = "阿里云短信的回调", description = "参见 https://help.aliyun.com/zh/sms/developer-reference/configure-delivery-receipts-1 文档")
30     public CommonResult<Boolean> receiveAliyunSmsStatus(HttpServletRequest request) throws Throwable {
31         String text = ServletUtils.getBody(request);
32         smsSendService.receiveSmsStatus(SmsChannelEnum.ALIYUN.getCode(), text);
33         return success(true);
34     }
35
36     @PostMapping("/tencent")
37     @PermitAll
38     @Operation(summary = "腾讯云短信的回调", description = "参见 https://cloud.tencent.com/document/product/382/59178 文档")
39     public CommonResult<Boolean> receiveTencentSmsStatus(HttpServletRequest request) throws Throwable {
40         String text = ServletUtils.getBody(request);
41         smsSendService.receiveSmsStatus(SmsChannelEnum.TENCENT.getCode(), text);
42         return success(true);
43     }
44
45 }