sinake
2 天以前 5177b16eb9450f98fa79e702cc5c1bcfe302e15f
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.ruoyi.web.controller.common;
 
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.RSAPublicKeyExample;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.sms.smsUtils;
import com.ruoyi.framework.config.ServerConfig;
import com.smartor.domain.HtmlContentVO;
import com.smartor.domain.smsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
 
@RestController
@Api(description = "知信接口")
@RequestMapping("/sms")
public class SmsController {
    @Value("${xhsmsPath}")
    private String xhsmsPath;
 
    @Value("${xhsmsAccount}")
    private String xhsmsAccount;
 
    @Value("${xhsmsPwd}")
    private String xhsmsPwd;
 
    @Value("${localIP}")
    private String ip;
 
    @Value("${req_path}")
    private String req_path;
 
    @Value("${pub_key}")
    private String pub_key;
 
 
    /**
     * @param
     * @return
     */
    @ApiOperation("短信发送")
    @PostMapping("/send")
    public AjaxResult send(@RequestBody smsVO vo) {
        String sendMsg=smsUtils.sendSms(xhsmsPath,xhsmsAccount,xhsmsPwd,vo.getPhone(),vo.getContent());
        return AjaxResult.success(sendMsg);
    }
    /**
     * @param
     * @return
     */
    @ApiOperation("短信发送")
    @PostMapping("/sendAsk")
    public AjaxResult sendAsk(@RequestBody smsVO vo) throws UnsupportedEncodingException {
//        String format = String.format("%03X", vo.getId());
//        String url=ip + ":" + req_path + "/wt?p=" + format;
        RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
        String taskId = rsaPublicKeyExample.encryptedData(vo.getTaskId().toString(), pub_key);
        String patid = rsaPublicKeyExample.encryptedData(vo.getPatId().toString(), pub_key);
        String url = null;
        url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "&param2=" + patid + "&param3=" + URLEncoder.encode(vo.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false";
 
        String content="您好,邀请您填写出院调查表,请点击" + url + "填写。感谢您配合!";
 
        String sendMsg=smsUtils.sendSms(xhsmsPath,xhsmsAccount,xhsmsPwd,vo.getPhone(),content);
        return AjaxResult.success(sendMsg);
    }
}