Commit 747a2c29 by guojuxing

新增/编辑管理员添加标志位,用来操作密码

parent ffdbd151
......@@ -29,9 +29,15 @@ public class UserController {
@RequestMapping("/save-or-update-user")
public RestResponse editUser(@Validated({ UserDTO.UserQoValid.class }) UserDTO userDTO) {
Integer operationPassword = userDTO.getOperPasswordType();
userDTO.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword(), userDTO.getOperPasswordType());
userDTO.setPassword(UserPasswordUtils.getEncryptPassword(password));
if (operationPassword != null && operationPassword.intValue() == 1) {
//如果是1,则不用验证密码
} else {
String password = UserPasswordUtils.validPassword(userDTO.getPasswordType(), userDTO.getPassword());
userDTO.setPassword(UserPasswordUtils.getEncryptPassword(password));
}
ServiceResponse userResult;
//普通用户
userDTO.setSuperAdmin(0);
......
......@@ -3,9 +3,9 @@ package com.gic.auth.web.utils;
import org.apache.commons.lang3.StringUtils;
import com.gic.auth.constant.UserConstants;
import com.gic.auth.exception.AuthException;
import com.gic.commons.util.Md5Util;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.exception.CommonException;
import com.gic.enterprise.utils.CreateRandomUtils;
/**
* 用户密码生成
......@@ -45,25 +45,17 @@ public class UserPasswordUtils {
* @param password
* @return
*/
public static String validPassword(int passwordType, String password, Integer operPasswordType) {
public static String validPassword(int passwordType, String password) {
//加密
if (UserConstants.CREATE_AUTO == passwordType) {
//自动随机生成
return createPasswordAuto(8);
} else {
if (operPasswordType == null) {
operPasswordType = 2;
if (StringUtils.isNotBlank(password)) {
return password;
} else {
throw new AuthException(ErrorCode.PARAMETER_ERROR.getCode(), "密码不能为空");
}
if (operPasswordType.intValue() != 1) {
//如果不等于1,则需要验证密码
if (StringUtils.isNotBlank(password)) {
return password;
} else {
throw new CommonException(ErrorCode.PARAMETER_ERROR.getCode(), "密码不能为空");
}
}
//如果是1,则不需要密码
return null;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment