|
@@ -1,6 +1,7 @@
|
|
|
package com.uas.platform.b2c.common.account.controller;
|
|
package com.uas.platform.b2c.common.account.controller;
|
|
|
|
|
|
|
|
import com.uas.message.mail.service.MailService;
|
|
import com.uas.message.mail.service.MailService;
|
|
|
|
|
+import com.uas.message.sms.service.SmsService;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.common.account.model.UserInfo;
|
|
import com.uas.platform.b2c.common.account.model.UserInfo;
|
|
@@ -13,6 +14,7 @@ import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.model.PageParams;
|
|
import com.uas.platform.core.model.PageParams;
|
|
|
|
|
+import com.uas.platform.core.util.StringUtil;
|
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
import com.uas.platform.core.util.encry.Md5Utils;
|
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -50,7 +52,7 @@ public class UserController {
|
|
|
private MailService mailService;
|
|
private MailService mailService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- private MessageConf messageConf;
|
|
|
|
|
|
|
+ private SmsService smsService;
|
|
|
|
|
|
|
|
private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
|
|
|
|
@@ -149,7 +151,7 @@ public class UserController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 发送验证码
|
|
|
|
|
|
|
+ * 发送邮箱验证码
|
|
|
*
|
|
*
|
|
|
* @param newUserEmail 用户输入新邮箱地址
|
|
* @param newUserEmail 用户输入新邮箱地址
|
|
|
*/
|
|
*/
|
|
@@ -164,7 +166,7 @@ public class UserController {
|
|
|
String checkCode = String.valueOf((int)((Math.random()*9+1)*100000));
|
|
String checkCode = String.valueOf((int)((Math.random()*9+1)*100000));
|
|
|
data.put("checkcode", checkCode);
|
|
data.put("checkcode", checkCode);
|
|
|
try {
|
|
try {
|
|
|
- //mailService.send("a4c45a22-436a-430c-9667-4edfd7d04a27", newUserEmail, data);
|
|
|
|
|
|
|
+ mailService.send("a4c45a22-436a-430c-9667-4edfd7d04a27", newUserEmail, data);
|
|
|
session.setAttribute("checkCode",checkCode);
|
|
session.setAttribute("checkCode",checkCode);
|
|
|
session.setAttribute("checkTime",new Date().getTime());
|
|
session.setAttribute("checkTime",new Date().getTime());
|
|
|
return new ResponseEntity<>(HttpStatus.OK);
|
|
return new ResponseEntity<>(HttpStatus.OK);
|
|
@@ -244,6 +246,125 @@ public class UserController {
|
|
|
throw new IllegalOperatorException("新邮箱地址不能为空");
|
|
throw new IllegalOperatorException("新邮箱地址不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 验证原手机号输入是否正确
|
|
|
|
|
+ * @param userTel
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/checkUserTel", method = RequestMethod.GET)
|
|
|
|
|
+ public ResponseEntity<String> checkUserTel(String userTel) {
|
|
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
|
|
+ if (!StringUtils.isEmpty(userTel)) {
|
|
|
|
|
+ boolean result = user.getUserTel().equals(userTel);
|
|
|
|
|
+ if (result) {
|
|
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
|
|
+ }
|
|
|
|
|
+ assert logger != null;
|
|
|
|
|
+ logger.log("用户信息", "验证用户手机,UU:" + user.getUserUU());
|
|
|
|
|
+ }
|
|
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送手机验证码
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param newUserTel 用户输入新手机号
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/sendTelCheckCode", method = RequestMethod.GET)
|
|
|
|
|
+ public ResponseEntity<String> sendTelCheckCode(String newUserTel,HttpServletRequest request) {
|
|
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
|
|
+ if (!StringUtils.isEmpty(newUserTel)) {
|
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
|
+ //页面Token校验
|
|
|
|
|
+ String pageToken = (String)session.getAttribute("pageToken");
|
|
|
|
|
+ if(pageToken == null || pageToken.equals("")){
|
|
|
|
|
+ throw new IllegalOperatorException("页面信息获取失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String checkCode = String.valueOf((int)((Math.random()*9+1)*100000));
|
|
|
|
|
+ System.out.println(checkCode);
|
|
|
|
|
+ try {
|
|
|
|
|
+ smsService.send("1eba04ae-f3d9-4105-ad32-0196309fabb3", newUserTel, new Object[] { checkCode });
|
|
|
|
|
+ session.setAttribute("telCheckCode",checkCode);
|
|
|
|
|
+ session.setAttribute("telCheckTime",new Date().getTime());
|
|
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ assert logger != null;
|
|
|
|
|
+ logger.log("用户信息", "发送手机验证码,UU:" + user.getUserUU());
|
|
|
|
|
+ }
|
|
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验手机验证码
|
|
|
|
|
+ * @param telCheckCode
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/validTelCheckCode", method = RequestMethod.GET)
|
|
|
|
|
+ public Map<String,Object> validTelCheckCode(String telCheckCode, HttpServletRequest request) {
|
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
|
+ Map<String,Object> result = new HashMap<String,Object>();
|
|
|
|
|
+ if(!StringUtils.isEmpty(telCheckCode)){
|
|
|
|
|
+ Long checkTime = (Long)session.getAttribute("telCheckTime");
|
|
|
|
|
+ Long nowTime = new Date().getTime();
|
|
|
|
|
+ String _checkCode = (String)session.getAttribute("telCheckCode");
|
|
|
|
|
+ //验证码失效
|
|
|
|
|
+ if((nowTime-checkTime)>10*60*1000 || _checkCode==null){
|
|
|
|
|
+ result.put("status",2);
|
|
|
|
|
+ result.put("message","验证码失效");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ //验证码错误
|
|
|
|
|
+ if(!_checkCode.equals(telCheckCode)) {
|
|
|
|
|
+ result.put("status",0);
|
|
|
|
|
+ result.put("message","验证码错误");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ //验证码正确
|
|
|
|
|
+ if(_checkCode.equals(telCheckCode)) {
|
|
|
|
|
+ result.put("status",1);
|
|
|
|
|
+ result.put("message","验证码正确");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ result.put("status",0);
|
|
|
|
|
+ result.put("message","验证码错误");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改手机号
|
|
|
|
|
+ * @param session
|
|
|
|
|
+ * @param userTel
|
|
|
|
|
+ * @param newUserTel
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/updateUserTel", method = RequestMethod.POST)
|
|
|
|
|
+ public ResponseEntity<String> updateUserTel(HttpSession session, String userTel, String newUserTel) {
|
|
|
|
|
+ if (userTel.equals(newUserTel)){
|
|
|
|
|
+ throw new IllegalOperatorException("新手机号与旧手机号相同");
|
|
|
|
|
+ }
|
|
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
|
|
+ if (!StringUtils.isEmpty(newUserTel)) {
|
|
|
|
|
+ if(!userService.isTelUseable(newUserTel)){
|
|
|
|
|
+ throw new IllegalOperatorException("手机号不可用...");
|
|
|
|
|
+ }
|
|
|
|
|
+ user.setUserTel(newUserTel);
|
|
|
|
|
+ user = userService.save(user);
|
|
|
|
|
+ session.setAttribute("user", user);
|
|
|
|
|
+ SystemSession.setUser(user);
|
|
|
|
|
+ assert logger != null;
|
|
|
|
|
+ logger.log("用户信息", "修改用户手机号,UU:" + user.getUserUU());
|
|
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
|
|
+ } else
|
|
|
|
|
+ throw new IllegalOperatorException("新手机号不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据UU获取该企业所有人员信息
|
|
* 根据UU获取该企业所有人员信息
|
|
|
* @param enuu 企业uu号
|
|
* @param enuu 企业uu号
|
|
@@ -368,4 +489,17 @@ public class UserController {
|
|
|
HttpStatus.OK);
|
|
HttpStatus.OK);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取页面token,防止恶意发送手机验证码
|
|
|
|
|
+ * @param request
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/getPageToken", method = RequestMethod.GET)
|
|
|
|
|
+ public ResponseEntity<String> getPageToken(HttpServletRequest request) {
|
|
|
|
|
+ String pageToken = StringUtil.uuid();
|
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
|
+ session.setAttribute("pageToken",pageToken);
|
|
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|