package com.ningdatech.carapi.loginbycode;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.ningdatech.carapi.loginbycode.utils.AliSmsUtil;

/**
 * @author CMM
 * @since 2022/12/28 14:44
 */

public class AliSmsTest {
    public static void main(String[] args) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String sd = sdf.format(new Date());
        String phone = "********";
        String template = "********";
        String name = "********";
        Map map = new HashMap<>(4);
        map.put("transportNo",name);
        map.put("hour",sd);
        // 对象转json
        JSONObject jsonObject = (JSONObject) JSONObject.toJSON(map);
        AliSmsUtil aliSmsUtil = new AliSmsUtil();
        // 发送短信
        SendSmsResponse sendSmsResponse = aliSmsUtil.sendSms(phone,jsonObject,template);
        if("OK".equals(sendSmsResponse.getCode())){
            System.out.println("发送成功");
        }else {
            System.out.println("发送失败");
        }
    }
}
