New file |
| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/12/17 9:25 |
| | | */ |
| | | public class SmsUtil { |
| | | |
| | | |
| | | /** |
| | | * 发送短信 |
| | | * https://doc.zthysms.com/web/#/1/14 |
| | | * @param mobile |
| | | * @param content |
| | | */ |
| | | public static void sendZTHYSms(String mobile, String content){ |
| | | HttpRequest post = HttpUtil.createPost("https://api-shss.zthysms.com/v2/sendSms"); |
| | | post.contentType("application/json"); |
| | | JSONObject body = new JSONObject(); |
| | | Long tKey = System.currentTimeMillis() / 1000; |
| | | body.put("username", "GZAHKJhy"); |
| | | body.put("password", SecureUtil.md5(SecureUtil.md5("@zLa@cB0") + tKey)); |
| | | body.put("tKey", tKey); |
| | | body.put("mobile", mobile); |
| | | body.put("content", "【安合出行】" + content); |
| | | post.body(body.toJSONString()); |
| | | HttpResponse execute = post.execute(); |
| | | JSONObject result = JSON.parseObject(execute.body()); |
| | | if(200 != result.getInteger("code")){ |
| | | throw new RuntimeException(result.getString("msg")); |
| | | } |
| | | } |
| | | } |