|
|
@@ -1,34 +1,43 @@
|
|
|
package com.uas.platform.b2c.common.account.controller;
|
|
|
|
|
|
-import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
+import com.uas.message.mail.service.MailService;
|
|
|
+import com.uas.message.sms.service.SmsService;
|
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
|
+import com.uas.platform.b2c.common.account.model.UserCacheEnterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.UserInfo;
|
|
|
+import com.uas.platform.b2c.common.account.model.UserQuestion;
|
|
|
+import com.uas.platform.b2c.common.account.service.UserQuestionService;
|
|
|
import com.uas.platform.b2c.common.account.service.UserService;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.support.log.UsageBufferedLogger;
|
|
|
-import com.uas.platform.b2c.trade.inquiry.model.TradeCharge;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.logging.BufferedLoggerManager;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
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.serializer.FlexJsonUtils;
|
|
|
+import com.wordnik.swagger.annotations.ApiOperation;
|
|
|
+import com.wordnik.swagger.annotations.ApiParam;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-
|
|
|
-import javax.persistence.criteria.CriteriaBuilder;
|
|
|
-import javax.persistence.criteria.CriteriaQuery;
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.persistence.criteria.Root;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpSession;
|
|
|
-import java.util.List;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
/**
|
|
|
* 用户信息的请求
|
|
|
@@ -43,6 +52,15 @@ public class UserController {
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MailService mailService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SmsService smsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserQuestionService uqService;
|
|
|
+
|
|
|
private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
|
|
|
/**
|
|
|
@@ -66,6 +84,8 @@ public class UserController {
|
|
|
throw new IllegalOperatorException("您当前的账号不存在,或未登录!不能设置图像。");
|
|
|
}
|
|
|
user.setImageUrl(imageUrl);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "设置头像路径,UU:" + user.getUserUU());
|
|
|
return userService.save(user);
|
|
|
}
|
|
|
|
|
|
@@ -80,7 +100,7 @@ public class UserController {
|
|
|
* @param password 用户输入密码
|
|
|
*/
|
|
|
@RequestMapping(value = "/checkPassword", method = RequestMethod.GET)
|
|
|
- public ResponseEntity<String> checkPassword(String password) {
|
|
|
+ public ResponseEntity<String> checkPassword(final String password) {
|
|
|
User sysUser = SystemSession.getUser();
|
|
|
User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
if (!StringUtils.isEmpty(password)) {
|
|
|
@@ -100,16 +120,24 @@ public class UserController {
|
|
|
* @param password 用户输入密码
|
|
|
*/
|
|
|
@RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
|
|
|
- public ResponseEntity<String> updatePassword(HttpSession session, String password, String newPassword) {
|
|
|
- if (password.equals(newPassword)){
|
|
|
+ public ResponseEntity<String> updatePassword(final HttpSession session, final String password, final String newPassword,final Short secLevel) {
|
|
|
+ if (password.equals(newPassword)) {
|
|
|
throw new IllegalOperatorException("新密码与旧密码相同");
|
|
|
}
|
|
|
+ if(newPassword.length()<8 || newPassword.matches("^[0-9]*$") || newPassword.matches("^[A-Za-z]*$")){
|
|
|
+ throw new IllegalOperatorException("密码强度不够,请重新输入");
|
|
|
+ }
|
|
|
+ if(newPassword.length()>20){
|
|
|
+ throw new IllegalOperatorException("密码超过20位,请重新输入");
|
|
|
+ }
|
|
|
User sysUser = SystemSession.getUser();
|
|
|
User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
- Enterprise enterprise = user.getEnterprise();
|
|
|
if (!StringUtils.isEmpty(newPassword)) {
|
|
|
+ user.setPwdSecLevel(secLevel);
|
|
|
user = userService.updatePassword(user, password, newPassword);
|
|
|
- user.setEnterprise(enterprise);
|
|
|
+ if(sysUser.getEnterprise()!=null){
|
|
|
+ user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
|
|
|
+ }
|
|
|
session.setAttribute("user", user);
|
|
|
SystemSession.setUser(user);
|
|
|
assert logger != null;
|
|
|
@@ -119,16 +147,421 @@ public class UserController {
|
|
|
throw new IllegalOperatorException("新密码不能为空");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 验证用户输入的邮箱地址是否正确
|
|
|
+ *
|
|
|
+ * @param userEmail 用户输入邮箱地址
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/checkUserEmail", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<String> checkUserEmail(final String userEmail) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(userEmail)) {
|
|
|
+ boolean result = user.getUserEmail().equals(userEmail);
|
|
|
+ if (result) {
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送邮箱验证码
|
|
|
+ *
|
|
|
+ * @param newUserEmail 用户输入新邮箱地址
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/sendCheckCode", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<String> sendCheckCode(final String newUserEmail, final HttpSession session) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(newUserEmail)) {
|
|
|
+ //发送邮件
|
|
|
+ ModelMap data = new ModelMap();
|
|
|
+ String checkCode = String.valueOf((int) ((Math.random() * 9 + 1) * 100000));
|
|
|
+ data.put("checkcode", checkCode);
|
|
|
+ try {
|
|
|
+ mailService.send("a4c45a22-436a-430c-9667-4edfd7d04a27", newUserEmail, data);
|
|
|
+ session.setAttribute("checkCode", checkCode);
|
|
|
+ session.setAttribute("checkTime", new Date().getTime());
|
|
|
+ session.setAttribute("newUserEmail",newUserEmail);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "发送用户邮箱地址,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验验证码是否正确
|
|
|
+ * @param checkCode 用户输入验证码
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/validCheckCode", method = RequestMethod.GET)
|
|
|
+ public Map<String, Object> validCheckCode(final String checkCode, final String newUserEmail,final HttpServletRequest request) {
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ Map<String,Object> result = new HashMap<String,Object>();
|
|
|
+ if (!StringUtils.isEmpty(checkCode) && !StringUtils.isEmpty(newUserEmail)) {
|
|
|
+ Long checkTime = (Long) session.getAttribute("checkTime");
|
|
|
+ Long nowTime = new Date().getTime();
|
|
|
+ String _checkCode = (String) session.getAttribute("checkCode");
|
|
|
+ String _newUserEmail = (String) session.getAttribute("newUserEmail");
|
|
|
+ //验证码失效
|
|
|
+ if((nowTime-checkTime)>10 * 60 * 1000 || _checkCode == null) {
|
|
|
+ result.put("status", 2);
|
|
|
+ result.put("message", "验证码失效");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //验证码错误
|
|
|
+ if (!_checkCode.equals(checkCode) || !_newUserEmail.equals(newUserEmail)) {
|
|
|
+ result.put("status", 0);
|
|
|
+ result.put("message", "验证码错误");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //验证码正确
|
|
|
+ if (_checkCode.equals(checkCode)) {
|
|
|
+ result.put("status", 1);
|
|
|
+ result.put("message", "验证码正确");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("status", 0);
|
|
|
+ result.put("message", "验证码错误");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户邮箱
|
|
|
+ * @param session
|
|
|
+ * @param userEmail
|
|
|
+ * @param newUserEmail
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateUserEmail", method = RequestMethod.POST)
|
|
|
+ public ResponseEntity<String> updateUserEmail(final HttpSession session, final String userEmail, final String newUserEmail,final String checkCode) {
|
|
|
+ if (userEmail!=null && userEmail.equals(newUserEmail)) {
|
|
|
+ throw new IllegalOperatorException("新邮箱地址与旧邮箱地址相同");
|
|
|
+ }
|
|
|
+ //正则校验邮箱地址
|
|
|
+ if(!newUserEmail.matches("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+")){
|
|
|
+ throw new IllegalOperatorException("新邮箱地址格式不正确");
|
|
|
+ }
|
|
|
+ String _checkCode = (String) session.getAttribute("checkCode");
|
|
|
+ if(!_checkCode.equals(checkCode)){
|
|
|
+ throw new IllegalOperatorException("验证码错误");
|
|
|
+ }
|
|
|
+ String _newUserEmail = (String) session.getAttribute("newUserEmail");
|
|
|
+ if(!_newUserEmail.equals(newUserEmail)){
|
|
|
+ throw new IllegalOperatorException("邮箱地址错误");
|
|
|
+ }
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(newUserEmail)) {
|
|
|
+ if (!userService.isEmailUseable(newUserEmail)) {
|
|
|
+ throw new IllegalOperatorException("邮箱已被注册...");
|
|
|
+ }
|
|
|
+ if(userEmail!=null && !userEmail.equals(user.getUserEmail())){
|
|
|
+ throw new IllegalOperatorException("旧邮箱地址校验错误");
|
|
|
+ }
|
|
|
+ user.setUserEmail(newUserEmail);
|
|
|
+ user = userService.save(user);
|
|
|
+ if(sysUser.getEnterprise()!=null){
|
|
|
+ user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
|
|
|
+ }
|
|
|
+ session.setAttribute("user", user);
|
|
|
+ SystemSession.setUser(user);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "修改用户邮箱地址,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ } else
|
|
|
+ throw new IllegalOperatorException("新邮箱地址不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证原手机号输入是否正确
|
|
|
+ * @param userTel
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/checkUserTel", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<String> checkUserTel(final String userTel) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(userTel)) {
|
|
|
+ boolean result = user.getUserTel().equals(userTel);
|
|
|
+ if (result) {
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "验证用户手机,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送手机验证码
|
|
|
+ * @param newUserTel 用户输入新手机号
|
|
|
+ * @param session
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/sendTelCheckCode", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<String> sendTelCheckCode(final String newUserTel, final HttpSession session) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(newUserTel)) {
|
|
|
+ //页面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));
|
|
|
+ try {
|
|
|
+ smsService.send("1eba04ae-f3d9-4105-ad32-0196309fabb3", newUserTel, new Object[] {checkCode});
|
|
|
+ session.setAttribute("telCheckCode", checkCode);
|
|
|
+ session.setAttribute("telCheckTime", new Date().getTime());
|
|
|
+ session.setAttribute("newUserTel", newUserTel);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "发送手机验证码,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验手机验证码
|
|
|
+ * @param telCheckCode
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/validTelCheckCode", method = RequestMethod.GET)
|
|
|
+ public Map<String, Object> validTelCheckCode(final String telCheckCode, final String newUserTel,final HttpSession session) {
|
|
|
+ Map<String, Object> result = new HashMap<String, Object>();
|
|
|
+ if (!StringUtils.isEmpty(telCheckCode) && !StringUtils.isEmpty(newUserTel)) {
|
|
|
+ Long checkTime = (Long) session.getAttribute("telCheckTime");
|
|
|
+ Long nowTime = new Date().getTime();
|
|
|
+ String _checkCode = (String) session.getAttribute("telCheckCode");
|
|
|
+ String _newUserTel = (String) session.getAttribute("newUserTel");
|
|
|
+ //验证码失效
|
|
|
+ if ((nowTime - checkTime) > 10 * 60 * 1000 || _checkCode == null) {
|
|
|
+ result.put("status", 2);
|
|
|
+ result.put("message", "验证码失效");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //验证码错误
|
|
|
+ if (!_checkCode.equals(telCheckCode) || !_newUserTel.equals(newUserTel)) {
|
|
|
+ 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(final HttpSession session, final String userTel, final String newUserTel,final String telCheckCode) {
|
|
|
+ if (userTel.equals(newUserTel)) {
|
|
|
+ throw new IllegalOperatorException("新手机号与旧手机号相同");
|
|
|
+ }
|
|
|
+ //手机号码正则表达式校验
|
|
|
+ if(!newUserTel.matches("^[0-9]{8,11}$")){
|
|
|
+ throw new IllegalOperatorException("新手机号格式不正确...");
|
|
|
+ }
|
|
|
+ //防止用户非法操作
|
|
|
+ String _checkCode = (String) session.getAttribute("telCheckCode");
|
|
|
+ if(!_checkCode.equals(telCheckCode)){
|
|
|
+ throw new IllegalOperatorException("验证码错误");
|
|
|
+ }
|
|
|
+ String _newUserTel = (String) session.getAttribute("newUserTel");
|
|
|
+ if(!_newUserTel.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);
|
|
|
+ if(sysUser.getEnterprise()!=null){
|
|
|
+ user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
|
|
|
+ }
|
|
|
+ session.setAttribute("user", user);
|
|
|
+ SystemSession.setUser(user);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "修改用户手机号,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ } else
|
|
|
+ throw new IllegalOperatorException("新手机号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证是否设置支付密码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/checkHaveUserPay", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<Boolean> checkHaveUserPay() {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.add("Content-Type", "application/text; charset=utf-8");
|
|
|
+ if (!StringUtils.isEmpty(user.getUserPay())) {
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "是否设置支付密码,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(true, headers, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(false, headers, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证用户支付密码
|
|
|
+ * @param userPay 用户输入的支付密码
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/checkUserPay", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<String> checkUserPay(final String userPay) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(userPay)) {
|
|
|
+ boolean result = user.getUserPay().equals(Md5Utils.encode(userPay, user.getUserUU()));
|
|
|
+ if (result) {
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "验证用户支付密码,UU:" + user.getUserUU());
|
|
|
+ }
|
|
|
+ return new ResponseEntity<>(HttpStatus.EXPECTATION_FAILED);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户支付密码
|
|
|
+ * @param session
|
|
|
+ * @param userPay
|
|
|
+ * @param newUserPay
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateUserPay", method = RequestMethod.POST)
|
|
|
+ public ResponseEntity<String> updateUserPay(final HttpSession session, final String userPay, final String newUserPay) {
|
|
|
+ if (userPay != null && userPay.equals(newUserPay)) {
|
|
|
+ throw new IllegalOperatorException("新密码与旧密码相同");
|
|
|
+ }
|
|
|
+ //新密码正则校验
|
|
|
+ if(!newUserPay.matches("^\\d{6}$")){
|
|
|
+ throw new IllegalOperatorException("新密码格式不正确...");
|
|
|
+ }
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserPwdByUserUU(sysUser.getUserUU());
|
|
|
+ if (!StringUtils.isEmpty(newUserPay)) {
|
|
|
+ user = userService.updateUserPay(user, userPay, newUserPay);
|
|
|
+ if(sysUser.getEnterprise()!=null){
|
|
|
+ user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
|
|
|
+ }
|
|
|
+ session.setAttribute("user", user);
|
|
|
+ SystemSession.setUser(user);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "修改用户支付密码,UU:" + user.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ } else
|
|
|
+ throw new IllegalOperatorException("新密码不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询当前用户的密保问题
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getUserQuestion", method = RequestMethod.GET)
|
|
|
+ public List<UserQuestion> getUserQuestion() {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.add("Content-Type", "application/json; charset=utf-8");
|
|
|
+ List<UserQuestion> questions = uqService.findUserQuestionByUserUUOrderBySortAsc(sysUser.getUserUU());
|
|
|
+ Map<String, List<UserQuestion>> result = new HashMap<String, List<UserQuestion>>();
|
|
|
+ result.put("questions", questions);
|
|
|
+ return questions;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置密保问题
|
|
|
+ * @param userQuestions
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateUserQuestion", method = RequestMethod.POST)
|
|
|
+ public ResponseEntity<String> updateUserQuestion(@RequestBody final List<UserQuestion> userQuestions) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ for (UserQuestion uq : userQuestions) {
|
|
|
+ uq.setUser(sysUser);
|
|
|
+ uq.setUserUU(sysUser.getUserUU());
|
|
|
+ if(uq.getAnswer()==null && uq.getQuestion()==null && uq.getAnswer().length()>30){
|
|
|
+ throw new IllegalOperatorException("请按照要求输入信息...");
|
|
|
+ }
|
|
|
+ uqService.save(uq);
|
|
|
+ }
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "设置密保问题,UU:" + sysUser.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实名认证
|
|
|
+ * @param userName
|
|
|
+ * @param userIdcode
|
|
|
+ * @param idImgUrl
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateRealAuth", method = RequestMethod.POST)
|
|
|
+ public ResponseEntity<String> updateRealAuth(final String userName, final String userIdcode, final String idImgUrl,HttpServletRequest request) {
|
|
|
+ User sysUser = SystemSession.getUser();
|
|
|
+ User user = userService.findUserByUserUU(sysUser.getUserUU());
|
|
|
+ if(user!=null){
|
|
|
+ user.setUserName(userName);
|
|
|
+ user.setUserIccode(userIdcode);
|
|
|
+ user.setIdImgUrl(idImgUrl);
|
|
|
+ user.setIdEnable((short)2);
|
|
|
+ user.setIdDate(new Date());
|
|
|
+ user = userService.saveRealAuth(user);
|
|
|
+ if(sysUser.getEnterprise()!=null){
|
|
|
+ user.setCurrentEnterprise(sysUser.getEnterprise().getUu());
|
|
|
+ }
|
|
|
+ request.getSession().setAttribute("user", user);
|
|
|
+ SystemSession.setUser(user);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", "提交实名认证信息,UU:" + sysUser.getUserUU());
|
|
|
+ return new ResponseEntity<>(HttpStatus.OK);
|
|
|
+ }else{
|
|
|
+ throw new IllegalOperatorException("找不到用户...");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据UU获取该企业所有人员信息
|
|
|
* @param enuu 企业uu号
|
|
|
* @return 完整的企业人员信息
|
|
|
*/
|
|
|
@RequestMapping(value = "/enterprise/info",method = RequestMethod.GET)
|
|
|
- public Page<User> getEnterpriseAllUsersInfo(PageParams params, Long enuu){
|
|
|
+ public Page<User> getEnterpriseAllUsersInfo(final PageParams params,Long enuu){
|
|
|
PageInfo pageInfo = new PageInfo(params);
|
|
|
return userService.findUsersPageByEnUU(pageInfo,enuu);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 通过关键词获取该企业所有人员信息
|
|
|
* @param enuu 企业uu号
|
|
|
@@ -155,6 +588,7 @@ public class UserController {
|
|
|
}
|
|
|
return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 删除用户
|
|
|
*
|
|
|
@@ -190,7 +624,7 @@ public class UserController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/searchUser", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public UserInfo getUser(String keyWord) {
|
|
|
+ public UserInfo getUser(final String keyWord) {
|
|
|
return userService.findUserByKeyWord(keyWord);
|
|
|
}
|
|
|
|
|
|
@@ -203,7 +637,7 @@ public class UserController {
|
|
|
*/
|
|
|
@RequestMapping(value = "/bindUser", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
- public ResponseEntity<String> bindUser(Long userUU) {
|
|
|
+ public ResponseEntity<String> bindUser(final Long userUU) {
|
|
|
userService.bindUserToMyEnterprise(userUU);
|
|
|
return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
}
|
|
|
@@ -214,7 +648,7 @@ public class UserController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/telEnable", method = RequestMethod.GET)
|
|
|
- public ResponseEntity<Boolean> telEnable(String tel) {
|
|
|
+ public ResponseEntity<Boolean> telEnable(final String tel) {
|
|
|
if (tel == null) {
|
|
|
throw new IllegalOperatorException("手机号不能为空!");
|
|
|
} else {
|
|
|
@@ -232,7 +666,7 @@ public class UserController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/emailEnable", method = RequestMethod.GET)
|
|
|
- public ResponseEntity<Boolean> emailEnable(String email) {
|
|
|
+ public ResponseEntity<Boolean> emailEnable(final String email) {
|
|
|
if (email == null) {
|
|
|
throw new IllegalOperatorException("邮箱不能为空");
|
|
|
} else {
|
|
|
@@ -242,4 +676,82 @@ public class UserController {
|
|
|
HttpStatus.OK);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置注册企业的缓存信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/userCacheEnterprise", method = RequestMethod.POST)
|
|
|
+ public ResponseEntity<Boolean> newUserCacheEnterprise(@RequestBody UserCacheEnterprise userCacheEnterprise) {
|
|
|
+ UserCacheEnterprise userCacheEnterprise1 = userService.saveUserCacheEnterprise(SystemSession.getUser(),userCacheEnterprise);
|
|
|
+ if (userCacheEnterprise1 == null) {
|
|
|
+ throw new IllegalOperatorException("保存失败");
|
|
|
+ } else {
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.add("Content-Type", "application/text; charset=utf-8");
|
|
|
+ return new ResponseEntity<Boolean>(true, headers,
|
|
|
+ HttpStatus.OK);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取注册企业的缓存信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/userCacheEnterprise", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public UserCacheEnterprise getUserCacheEnterprise() {
|
|
|
+ return userService.getUserCacheEnterprise(SystemSession.getUser());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除注册企业的缓存信息
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/userCacheEnterprise", method = RequestMethod.DELETE)
|
|
|
+ @ResponseBody
|
|
|
+ public void deleteUserCacheEnterprise() {
|
|
|
+ userService.deleteUserCacheEnterprise(SystemSession.getUser());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取页面token,防止恶意发送手机验证码
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getPageToken", method = RequestMethod.GET)
|
|
|
+ public ResponseEntity<String> getPageToken(final HttpServletRequest request) {
|
|
|
+ String pageToken = StringUtil.uuid();
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ session.setAttribute("pageToken", pageToken);
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页获取实名认证
|
|
|
+ * @param pageInfo
|
|
|
+ * @param status
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getPageStatusRealAuth", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "分页获取实名认证", httpMethod = "GET")
|
|
|
+ public Page<User> getPageStatusRealAuth(@ApiParam(required = true, value = "分页参数") PageParams pageInfo, @ApiParam(required = true, value = "用户状态") Short status) {
|
|
|
+ return userService.getPageStatusRealAuth(pageInfo, status);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核实名认证
|
|
|
+ * @param user
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateIdEnable", method = RequestMethod.POST)
|
|
|
+ public ResponseEntity<String> updateIdEnable(final User user,HttpServletRequest request) {
|
|
|
+ User newUser = userService.saveRealAuth(user);
|
|
|
+ assert logger != null;
|
|
|
+ logger.log("用户信息", SystemSession.getUser().getUserUU()+"后台审核实名认证,UU:" + newUser.getUserUU());
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
}
|