Pu Zhibing
2024-12-17 203abdf7b779e6f8f226e147fa40516b77143f14
修改第三方账号
1个文件已添加
40 ■■■■■ 已修改文件
UserAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SmsUtil.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
UserAHTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SmsUtil.java
New file
@@ -0,0 +1,40 @@
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"));
        }
    }
}