package com.yihu.jw.care.util; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.yihu.jw.sms.service.TXYSmsService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** * Created by Bing on 2021/5/29. */ @Component public class MessageUtil { @Autowired private TXYSmsService txySmsService; private static Logger logger = LoggerFactory.getLogger(MessageUtil.class); public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{ JSONObject sendObj = new JSONObject(); sendObj.put("templateCode",templateCode); if (params.length>0){ JSONArray paramArr =JSONArray.parseArray(JSON.toJSONString(params)); sendObj.put("templateParamArr",paramArr); }else { JSONArray paramArr =new JSONArray(); sendObj.put("templateParamArr",paramArr); } return txySmsService.sendMessageJson(mobile,sendObj); } }