SMSUtils.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //package com.example.civilizedcity.common;
  2. //
  3. //import com.alibaba.fastjson.JSONObject;
  4. //import lombok.Data;
  5. //import lombok.experimental.Accessors;
  6. //import lombok.extern.slf4j.Slf4j;
  7. //import org.springframework.beans.factory.InitializingBean;
  8. //import org.springframework.beans.factory.annotation.Autowired;
  9. //import org.springframework.beans.factory.annotation.Value;
  10. //import org.springframework.scheduling.annotation.EnableAsync;
  11. //import org.springframework.scheduling.annotation.EnableScheduling;
  12. //import org.springframework.stereotype.Component;
  13. //
  14. //import java.util.HashMap;
  15. //import java.util.Map;
  16. //
  17. //@Slf4j
  18. //@Component
  19. //@EnableScheduling //开启定时任务
  20. //@EnableAsync //开启多线程
  21. //public class SMSUtils implements InitializingBean {
  22. // @Autowired
  23. // HttpUtils httpUtils;
  24. // @Value("${yz.sms.api}")
  25. // String smsAPI;
  26. //
  27. // @Value("${yz.sms.appid}")
  28. // String appid;
  29. //
  30. // // @Async
  31. //// @Scheduled(cron = "0 30 8 * * ?") //时隔多少秒
  32. // public void SendMessage(Message message) throws Exception {
  33. // long nowMills = System.currentTimeMillis();
  34. // String timestamp = String.valueOf(nowMills);
  35. // String secret = appid + timestamp;
  36. //
  37. // Map<String, String> header = new HashMap<>();
  38. // header.put("x-appid", appid);
  39. // header.put("x-timestamp", timestamp);
  40. // header.put("x-sign", EncryptUtils.md5(appid + secret, timestamp));
  41. //
  42. // Map<String, String> body = new HashMap<>();
  43. // body.put("PhoneNumbers", message.getTel());
  44. // body.put("SignName", message.getSign());
  45. // body.put("TemplateCode", message.getCode());
  46. // body.put("TemplateParam", message.getContent());
  47. //
  48. // httpUtils.post(smsAPI, header, JSONObject.toJSONString(body, false));
  49. //
  50. // }
  51. //
  52. // @Override
  53. // public void afterPropertiesSet() throws Exception {
  54. // }
  55. //
  56. // @Data
  57. // @Accessors(chain = true)
  58. // public static class Message {
  59. // String code;
  60. // String tel;
  61. // String sign;
  62. // String content;
  63. // }
  64. //
  65. //}