package common.utils;

import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.github.qcloudsms.httpclient.HTTPException;
import com.video.config.smsConfig;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

/**
 * @Author: binguo
 * @Date: 2023/4/20 星期四 8:26
 * @Description: common
 * @Version: 1.0
 */
public class smsUtil {
    @Autowired
    private static smsConfig smsConfig;

    /**
     * 发送单条短信验证码
     * @param smmCode 短信验证码
     * @param phoneNumber 手机号
     * @return
     */
    public static void sendSingleMessage(String smmCode, String phoneNumber) throws HTTPException, IOException {
        String[] params = {smmCode,Integer.toString(smsConfig.getSmsMin())};
        SmsSingleSender ssender = new SmsSingleSender(smsConfig.getAppID(), smsConfig.getAppKey());
        SmsSingleSenderResult result = ssender.sendWithParam("86", phoneNumber, smsConfig.getTemplateId(), params, smsConfig.getSmsSign(), "", "");
        System.out.println(result);
    };
}
