tj
6 天以前 b428226d0cf78bbb843fa17bffb1e338230fae6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.mzl.flower.web.v2.sms;
 
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.config.sms.TosSmsProperties;
import com.mzl.flower.dto.request.sms.SmsTaskDTO;
import com.mzl.flower.service.sms.TosSmsService;
import com.volcengine.model.request.SmsSendRequest;
import com.volcengine.model.response.SmsSendResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
 
@Api(value = "火山短信", tags = "火山短信")
@RestController
@RequestMapping("/v2/tos/sms")
public class TosSmsController extends BaseController {
 
    @Autowired
    private TosSmsService tosSmsService;
 
    @Autowired
    private TosSmsProperties tosSmsProperties;
 
    private String template="";
 
    @PostMapping(value = "/send")
    @ApiOperation(value = "发送短信任务", httpMethod = "POST")
    public ResponseEntity<ReturnDataDTO> send() throws IOException {
        SmsSendRequest req = new SmsSendRequest();
        req.setPhoneNumbers("17768997336");
        req.setSmsAccount(tosSmsProperties.getSmsAccount());
        req.setTemplateId(tosSmsProperties.getTemplateId());
        req.setSign(tosSmsProperties.getSign());
 
        Map<String,String> param = new HashMap<>();
        param.put("code","123456");
        req.setTemplateParamByMap(param);
        SmsSendResponse smsSendResponse = tosSmsService.sendSms(req);
        return returnData(R.SUCCESS.getCode(), smsSendResponse);
    }
 
 
}