123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package com.chinacreator.videoalliance.smc.action;
- import com.chinacreator.common.exception.BusinessException;
- import com.chinacreator.common.util.DESUtil;
- import com.chinacreator.videoalliance.smc.bean.SmsSendBean;
- import com.chinacreator.videoalliance.smc.dao.SmsSendDao;
- import com.chinacreator.videoalliance.smc.util.SendSmsUtil;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import java.util.HashMap;
- import java.util.Map;
- @Controller
- public class ChannelSendSmsAction {
- @Autowired
- private SmsSendDao smsSendDao;
- @RequestMapping("/channelSmsSend.do")
- @ResponseBody
- public Object send(HttpServletRequest request, HttpServletResponse response) throws Exception {
- Map<String,String> map = new HashMap<String, String>();
- String resultCode = "0";
- String errorInfo = "";
- try{
- String channel = request.getParameter("channel");
- String content = request.getParameter("content");
- String userid = request.getParameter("userid");
- if(StringUtils.isEmpty(channel) || StringUtils.isEmpty(userid)){
- throw new BusinessException("9002", "参数错误");
- }
- SmsSendBean bean = smsSendDao.querySmsConfig(channel);
- if(bean == null){
- throw new BusinessException("9003", "渠道不存在");
- }
- userid = DESUtil.decode(userid, bean.getPwd());
- if(content == null){
- content = bean.getContent();
- }
- // SmsUtil.sendSms(userid,content);
- SendSmsUtil.send(userid,content);
- }catch(Exception e){
- e.printStackTrace();
- if(e instanceof BusinessException){
- resultCode = ((BusinessException) e).getCode();
- errorInfo = e.getMessage();
- }else{
- resultCode = "8000";
- errorInfo = "系统忙,请稍后再试";
- }
- }finally {
- map.put("resultCode", resultCode);
- map.put("errorInfo", errorInfo);
- }
- return map;
- }
- public static void main(String[] args) throws Exception, Exception {
- //20474
- // List<String> list = ReadUtil.read("f:1.txt");
- // int n = list.size();
- // for (String string : list) {
- // System.out.println(n--);
- // String result =URLUtil.get("http://114.255.201.238:8092/videoif/channelSmsSend.do?channel=letvsms&userid="+URLEncoder.encode(DESUtil.encode(string, "idfdse33"),"utf-8"));
- // System.out.println(result);
- // }
- // ChannelSendSmsAction cs = new ChannelSendSmsAction();
- // cs.sendSms("18673687435","这是一条测试短信20200310");
- // HashMap params = new HashMap();
- // String pwd = "net3gvideo";
- // params.put("SP_NUMBER", "10655117");
- // params.put("CHANNEK_ID", "video");
- // params.put("USERMOB", "18673197465");
- // params.put("SMS_CONTENT", "this is a message");
- // Gson gson = (new GsonBuilder()).disableHtmlEscaping().serializeNulls().create();
- System.out.println("--123---");
- }
- }
|