|
@ -1,10 +1,10 @@
|
|
|
package com.yihu.wlyy.controller.manager.user;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.wlyy.controller.BaseController;
|
|
|
import com.yihu.wlyy.entity.User;
|
|
|
import com.yihu.wlyy.service.manager.user.UserService;
|
|
|
import com.yihu.wlyy.util.Envelop;
|
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -16,8 +16,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* Created by yww on 2016/12/6.
|
|
@ -142,6 +143,11 @@ public class UserController extends BaseController {
|
|
|
@ResponseBody
|
|
|
public String updateUser(String jsonData){
|
|
|
try{
|
|
|
|
|
|
JSONObject data = JSONObject.parseObject(jsonData);
|
|
|
|
|
|
String oldpsw = data.getString("oldpsw");
|
|
|
|
|
|
User user = objectMapper.readValue(jsonData, User.class);
|
|
|
String mobile = user.getMobile();
|
|
|
if(mobile == null){
|
|
@ -154,14 +160,54 @@ public class UserController extends BaseController {
|
|
|
userNew.setMobile(user.getMobile());
|
|
|
userNew.setOrganizationId(user.getOrganizationId());
|
|
|
userNew.setRoles(user.getRoles());
|
|
|
//修改手机号对应初始化密码(因暂未提供修改密码操作)-手机号后六位
|
|
|
if(userNew.getMobile() != user.getMobile()){
|
|
|
String password=mobile.substring(5);
|
|
|
|
|
|
String password=user.getPassword();
|
|
|
|
|
|
//如果新密码不为空,则进入修改密码的分支
|
|
|
if(StringUtils.isNotBlank(password)){
|
|
|
|
|
|
if(StringUtils.isBlank(oldpsw)){
|
|
|
return error(-1,"旧密码不能为空");
|
|
|
}
|
|
|
|
|
|
oldpsw = MD5.GetMD5Code(oldpsw+userNew.getSalt());
|
|
|
|
|
|
if(!oldpsw.equals(userNew.getPassword())){
|
|
|
return error(-1,"旧密码错误,无法修改");
|
|
|
}
|
|
|
|
|
|
//
|
|
|
// 复杂(同时包含数字,字母,特殊符号)
|
|
|
// "^^(?![a-zA-z]+$)(?!\\d+$)(?![!@#$%^&*_-]+$)(?![a-zA-z\\d]+$)(?![a-zA-z!@#$%^&*_-]+$)(?![\\d!@#$%^&*_-]+$)[a-zA-Z\\d!@#$%^&*_-]+$"
|
|
|
|
|
|
// 中级(包含字母和数字)
|
|
|
String regStr = "^(?![a-zA-z]+$)(?!\\d+$)(?![!@#$%^&*]+$)[a-zA-Z\\d!@#$%^&*]+$";
|
|
|
Pattern pattern = Pattern.compile(regStr);
|
|
|
Matcher matcher = pattern.matcher(password);
|
|
|
boolean rs = matcher.find();
|
|
|
if(!rs){
|
|
|
return error(-1,"新密码必须包含字母和数字!");
|
|
|
}
|
|
|
|
|
|
String salt= UUID.randomUUID().toString().replace("-", "");
|
|
|
password = MD5.GetMD5Code(password+salt);
|
|
|
userNew.setPassword(password);
|
|
|
userNew.setSalt(salt);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //修改手机号对应初始化密码(因暂未提供修改密码操作)-手机号后六位
|
|
|
// if(userNew.getMobile() != user.getMobile()){
|
|
|
// String password=mobile.substring(5);
|
|
|
// String salt= UUID.randomUUID().toString().replace("-", "");
|
|
|
// password = MD5.GetMD5Code(password+salt);
|
|
|
// userNew.setPassword(password);
|
|
|
// userNew.setSalt(salt);
|
|
|
// }
|
|
|
userNew = userService.save(userNew);
|
|
|
return write(200,"操作成功!");
|
|
|
}catch (Exception ex){
|