|
|
|
@ -34,6 +34,7 @@ import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.apache.commons.lang.text.StrBuilder;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -100,6 +101,9 @@ public class SysUserController extends CoreBaseController {
|
|
|
|
|
@Resource(name = CommonConstWords.IMPP_REDIS_RES)
|
|
|
|
|
private ImppRedis redisRes;
|
|
|
|
|
|
|
|
|
|
@Resource(name = CommonConstWords.IMPP_REDIS_CORE)
|
|
|
|
|
protected ImppRedis redisCore;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增系统用户
|
|
|
|
|
*
|
|
|
|
@ -277,7 +281,10 @@ public class SysUserController extends CoreBaseController {
|
|
|
|
|
ValidatorBean.checkNotZero(status, "功能状态不能为空");
|
|
|
|
|
|
|
|
|
|
sysUserService.updateBatchSysUserStatus(StringTool.getArrayLong(ids), status, AuthUtil.getSessionUser());
|
|
|
|
|
|
|
|
|
|
//当解除锁定状态 重置当天登录错误次数上限
|
|
|
|
|
if (CommonEnumUtil.USER_STATUS.ENABLE.getValue() == status) {
|
|
|
|
|
deleteRedisLoginErrorKeys(ids);
|
|
|
|
|
}
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
@ -287,6 +294,22 @@ public class SysUserController extends CoreBaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除登录错误的次数
|
|
|
|
|
*
|
|
|
|
|
* @param ids
|
|
|
|
|
*/
|
|
|
|
|
private void deleteRedisLoginErrorKeys(String[] ids) {
|
|
|
|
|
String[] keys = new String[ids.length];
|
|
|
|
|
StringBuilder redisKey = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < ids.length; i++) {
|
|
|
|
|
redisKey.append(CommonConstWords.USER_LOGIN_ERROR).append(":").append(TimeTool.getToday()).append(":").append(ids[i]);
|
|
|
|
|
keys[i] = redisKey.toString();
|
|
|
|
|
redisKey.setLength(0);
|
|
|
|
|
}
|
|
|
|
|
redisCore.deleteKey(keys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据登录的用户名批量修改账号状态
|
|
|
|
|
*
|
|
|
|
|
* @param userLoginNames 用户名数组
|
|
|
|
@ -297,12 +320,12 @@ public class SysUserController extends CoreBaseController {
|
|
|
|
|
@ApiOperation(value = "根据用户名批量修改账号状态", notes = "根据用户名批量修改账号状态")
|
|
|
|
|
public ResultBean updateBatchStatusByUserLoginNames(String[] userLoginNames, Integer status) {
|
|
|
|
|
try {
|
|
|
|
|
if(ObjectUtils.isEmpty(userLoginNames)){
|
|
|
|
|
if (ObjectUtils.isEmpty(userLoginNames)) {
|
|
|
|
|
return ResultBean.success("操作失败").setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode()).setErrorMsg("用户名不能为空");
|
|
|
|
|
}
|
|
|
|
|
ValidatorBean.checkNotZero(status, "账号状态不能为空");
|
|
|
|
|
List<String> userLoginNameList = Stream.of(userLoginNames).collect(Collectors.toList());
|
|
|
|
|
sysUserService.updateBatchSysUserStatusByUserLoginNames(userLoginNameList,status);
|
|
|
|
|
sysUserService.updateBatchSysUserStatusByUserLoginNames(userLoginNameList, status);
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
@ -569,7 +592,7 @@ public class SysUserController extends CoreBaseController {
|
|
|
|
|
String password = SysUserPasswordUtil.generateRandomPassword();
|
|
|
|
|
userPasswordService.updatePasswordResetLastModifyTime(user.getId(), password, false);
|
|
|
|
|
//重置成随机密码会让用户首次登录修改密码
|
|
|
|
|
sysUserService.updateUserLoginNum(user.getId(),0);
|
|
|
|
|
sysUserService.updateUserLoginNum(user.getId(), 0);
|
|
|
|
|
String content = "系统提示:\n" +
|
|
|
|
|
"\t" + getSessionUser().getUserName() + "使用密码重置功能帮您重置了【" + user.getUserLoginName() + "】账号的密码," +
|
|
|
|
|
"新密码是:" + password + "";
|
|
|
|
|