<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package com.bcxin.backend.utils;

import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.bcxin.backend.configs.SmsConfig;
import com.bcxin.backend.dtos.HuaWeiSmsContent;
import com.bcxin.backend.dtos.SmsResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class MessageUtil {
	final static Logger logger = LoggerFactory.getLogger(MessageUtil.class);

	/**
	 * 鍙戦€佸崕涓虹煭淇�
	 * @param huaWeiSmsContent
	 * @return
	 */
	public static boolean sendHuaWeiSMS(HuaWeiSmsContent huaWeiSmsContent) {
		boolean flag = false;
		Map&lt;String,Object&gt; params =  new HashMap&lt;&gt;();
		//鐜鏍囪瘑
        huaWeiSmsContent.setChannel(SmsConfig.getChannel());
		huaWeiSmsContent.setPlatform(SmsConfig.getPlatform());
		params.put("data", JSON.toJSONString(huaWeiSmsContent));
		params.put("token", MD5Util.string2MD5("BCXIN" + huaWeiSmsContent.getMobile() + DateUtil.formatDate(DateUtil.date())));
		String result = HttpUtil.post(SmsConfig.getUrl(),params);

		SmsResult smsResult = JSON.parseObject(result,SmsResult.class);
		flag = smsResult.isSuccess();
		System.out.println(result);
		logger.info(result);

		return flag;
	}
	public static void testSendHuaWeiSMS(HuaWeiSmsContent huaWeiSmsContent) {
		Map&lt;String,Object&gt; params =  new HashMap&lt;&gt;();
		//鐜鏍囪瘑
		params.put("data", JSON.toJSONString(huaWeiSmsContent));
		params.put("token", MD5Util.string2MD5("BCXIN" + huaWeiSmsContent.getMobile() + DateUtil.formatDate(DateUtil.date())));
		String result = HttpUtil.post("http://msg.bcxin.com.cn:9165/sms/huawei/sendSMS",params);
		System.out.println(result);
		logger.info(result);
	}




	public static void main(String[] args) {
		HuaWeiSmsContent huaWeiSmsContent = new HuaWeiSmsContent();
		huaWeiSmsContent.setPlatform("V5");
		huaWeiSmsContent.setChannel("test");
		huaWeiSmsContent.setSmsCode("B1");
		huaWeiSmsContent.setParams("闈掑悍骞�,ZP鍩硅鏈烘瀯瀹夋帓鎮ㄤ簬2022-03-15 09:17:01.0杩涜銆婂浗瀹朵繚瀹夊憳璇併€嬭€冭瘯锛岃鎮ㄥ姟蹇呮彁鍓嶅埌娴嬭瘯鎵爜绛惧埌銆傚眾鏃惰鑱旂郴銆愯€冪偣鑱旂郴浜恒€戯細awn3SQyY :鎵嬫満鍙�:");
		huaWeiSmsContent.setMobile("15750701070");
		MessageUtil.testSendHuaWeiSMS(huaWeiSmsContent);
	}

}
</pre></body></html>