| | |
| | | package com.nq.controller; |
| | | |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | |
| | | import com.nq.pojo.SiteSmsLog; |
| | | import com.nq.service.ISiteSmsLogService; |
| | | import com.nq.service.ISmsService; |
| | | |
| | | import com.nq.utils.DateTimeUtil; |
| | | import com.nq.utils.PhoneUtil; |
| | | import com.nq.utils.sms.SmsConstants; |
| | | import com.nq.utils.smsUtil.smsUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | 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; |
| | | |
| | | @Controller |
| | | @RequestMapping({"/api/sms/"}) |
| | |
| | | @Autowired |
| | | ISiteSmsLogService iSiteSmsLogService; |
| | | |
| | | //注册用户 短信发送 |
| | | /** 注册用户短信发送(需图形验证码) */ |
| | | @RequestMapping({"sendRegSms.do"}) |
| | | @ResponseBody |
| | | public ServerResponse sendRegSms(String phoneNum) { |
| | | if (StringUtils.isBlank(phoneNum)) { |
| | | return ServerResponse.createByErrorMsg("发送失败,手机号不能为空"); |
| | | public ServerResponse sendRegSms(String phoneNum, String captchaCode, String captchaToken, HttpServletRequest request) { |
| | | log.info("sendRegSms phone={}", phoneNum); |
| | | return iSmsService.sendRegSms(phoneNum, captchaCode, captchaToken, request); |
| | | } |
| | | |
| | | log.info("smsphone"+phoneNum); |
| | | |
| | | return iSmsService.sendAliyunSMS(phoneNum, "SMS_468990815"); |
| | | } |
| | | |
| | | //找回密码 短信发送 |
| | | // @RequestMapping({"sendForgetSms.do"}) |
| | | // @ResponseBody |
| | | // public ServerResponse sendForgetSms(String phoneNum) { |
| | | // return this.iSmsService.sendAliyunSMS(phoneNum, "SMS_174915941"); |
| | | // } |
| | | //找回密码 短信发送 |
| | | /** 找回密码短信发送 */ |
| | | @RequestMapping({"sendForgetSms.do"}) |
| | | @ResponseBody |
| | | public ServerResponse sendForgetSms(String phoneNum) { |
| | | if (!SmsConstants.isVerifyEnabled()) { |
| | | return ServerResponse.createBySuccess(); |
| | | } |
| | | if (StringUtils.isBlank(phoneNum)) { |
| | | return ServerResponse.createByErrorMsg("发送失败,手机号不能为空"); |
| | | } |
| | | if (!PhoneUtil.isValidChinaMobile(phoneNum)) { |
| | | return ServerResponse.createByErrorMsg("请输入正确的手机号码"); |
| | | } |
| | | phoneNum = PhoneUtil.normalizeChinaMobile(phoneNum); |
| | | |
| | | smsUtil smsUtil = new smsUtil(); |
| | | log.info("smsphone"+phoneNum); |
| | | log.info("sendForgetSms phone={}", phoneNum); |
| | | String code = smsUtil.sendForgetSms(phoneNum); |
| | | if (!StringUtils.isEmpty(code)) { |
| | | SiteSmsLog siteSmsLog = new SiteSmsLog(); |
| | |
| | | return ServerResponse.createByErrorMsg("短信发送失败,请重试"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |