密码规则配置功能
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
package com.njcn.user.pojo.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2024/7/11 18:04【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel
|
||||||
|
public class PassWordRuleParam {
|
||||||
|
@ApiModelProperty(name = "errorsCount",value = "安码输入错误次数")
|
||||||
|
@NotNull(message = "安码输入错误次数不可为空")
|
||||||
|
private Integer errorsCount;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "releaseTime",value = "自动解锁(分钟):")
|
||||||
|
@NotNull(message = "自动解锁(分钟)不可为空")
|
||||||
|
private Integer releaseTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "sessionTime",value = "*会话超时时间(分钟)")
|
||||||
|
@NotNull(message = "会话超时时间(分钟)不可为空")
|
||||||
|
private Integer sessionTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "minPasswordLength",value = "密码最小长度")
|
||||||
|
@NotNull(message = "密码最小长度不可为空")
|
||||||
|
private Integer minPasswordLength;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "passwordExpirationDays",value = "密码超期天数")
|
||||||
|
@NotNull(message = "密码超期天数不可为空")
|
||||||
|
private Integer passwordExpirationDays;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "mixedCheckFlag",value = "密码符号混合校验(0:否1:是)")
|
||||||
|
@NotNull(message = "密码符号混合校验不可为空")
|
||||||
|
private Integer mixedCheckFlag;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "doubleCheckFlag",value = "密码重复校验(0:否1:是)")
|
||||||
|
@NotNull(message = "密码重复校验不可为空")
|
||||||
|
private Integer doubleCheckFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "mixedCheckFlag",value = "密码大小写混合校验(0:否1:是)" )
|
||||||
|
@NotNull(message = "密码大小写混合校验不可为空")
|
||||||
|
private Integer mixedCaseCheckFlag;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.njcn.user.controller;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.user.pojo.param.PassWordRuleParam;
|
||||||
|
import com.njcn.user.service.PassWordRuleService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
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.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2024/7/11 18:01【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@Api(tags = "密码规则管理")
|
||||||
|
@RequestMapping("/password")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PassWordRuleController extends BaseController {
|
||||||
|
private final PassWordRuleService passWordRuleService;
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("密码规则修改")
|
||||||
|
@RequestMapping(value = "/ruleUpdate", method = RequestMethod.POST)
|
||||||
|
public HttpResult<Boolean> ruleUpdate(@RequestBody @Validated PassWordRuleParam passWordRuleParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("ruleUpdate");
|
||||||
|
Boolean flag = passWordRuleService.ruleUpdate(passWordRuleParam);
|
||||||
|
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("获取密码规则")
|
||||||
|
@RequestMapping(value = "/getRule", method = RequestMethod.POST)
|
||||||
|
public HttpResult<PassWordRuleParam> getRule() {
|
||||||
|
String methodDescribe = getMethodDescribe("getRule");
|
||||||
|
PassWordRuleParam passWordRuleParam = passWordRuleService.getRule();
|
||||||
|
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, passWordRuleParam, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@ApiOperation("解锁超级管理员")
|
||||||
|
@RequestMapping(value = "/unlockRoot", method = RequestMethod.POST)
|
||||||
|
public HttpResult<Boolean> unlockRoot() {
|
||||||
|
String methodDescribe = getMethodDescribe("unlockRoot");
|
||||||
|
Boolean flag = passWordRuleService.unlockRoot();
|
||||||
|
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.user.service;
|
||||||
|
|
||||||
|
import com.njcn.user.pojo.param.PassWordRuleParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2024/7/11 18:06【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
public interface PassWordRuleService {
|
||||||
|
Boolean ruleUpdate(PassWordRuleParam passWordRuleParam);
|
||||||
|
|
||||||
|
PassWordRuleParam getRule();
|
||||||
|
|
||||||
|
Boolean unlockRoot();
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.njcn.user.service.impl;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
|
import com.njcn.user.pojo.param.PassWordRuleParam;
|
||||||
|
import com.njcn.user.pojo.po.User;
|
||||||
|
import com.njcn.user.pojo.po.UserStrategy;
|
||||||
|
import com.njcn.user.service.IUserService;
|
||||||
|
import com.njcn.user.service.IUserStrategyService;
|
||||||
|
import com.njcn.user.service.PassWordRuleService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description:
|
||||||
|
* Date: 2024/7/11 18:06【需求编号】
|
||||||
|
*
|
||||||
|
* @author clam
|
||||||
|
* @version V1.0.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PassWordRuleServiceImpl implements PassWordRuleService {
|
||||||
|
|
||||||
|
private final IUserStrategyService iUserStrategyService;
|
||||||
|
private final RedisUtil redisUtil;
|
||||||
|
|
||||||
|
private final IUserService userService;
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
public Boolean ruleUpdate(PassWordRuleParam passWordRuleParam) {
|
||||||
|
|
||||||
|
iUserStrategyService.lambdaUpdate().eq(UserStrategy::getType,"1")
|
||||||
|
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||||
|
.set(UserStrategy::getLimitPwdTimes,passWordRuleParam.getErrorsCount())
|
||||||
|
.set(UserStrategy::getLimitPwdDate,passWordRuleParam.getPasswordExpirationDays())
|
||||||
|
.set(UserStrategy::getLockPwdCheck,passWordRuleParam.getReleaseTime())
|
||||||
|
.set(UserStrategy::getLockPwdTime,passWordRuleParam.getSessionTime()).update();
|
||||||
|
|
||||||
|
redisUtil.saveByKey("mixedCheckFlag",passWordRuleParam.getMixedCheckFlag());
|
||||||
|
redisUtil.saveByKey("doubleCheckFlag",passWordRuleParam.getDoubleCheckFlag());
|
||||||
|
redisUtil.saveByKey("mixedCaseCheckFlag",passWordRuleParam.getMixedCaseCheckFlag());
|
||||||
|
redisUtil.saveByKey("minPasswordLength",passWordRuleParam.getMinPasswordLength());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PassWordRuleParam getRule() {
|
||||||
|
PassWordRuleParam passWordRuleParam = new PassWordRuleParam();
|
||||||
|
UserStrategy userStrategy = iUserStrategyService.getUserStrategy(1);
|
||||||
|
|
||||||
|
passWordRuleParam.setErrorsCount(userStrategy.getLimitPwdTimes());
|
||||||
|
passWordRuleParam.setReleaseTime(userStrategy.getLockPwdCheck());
|
||||||
|
passWordRuleParam.setSessionTime(userStrategy.getLockPwdTime());
|
||||||
|
passWordRuleParam.setMinPasswordLength((Integer)(redisUtil.getObjectByKey("minPasswordLength")));
|
||||||
|
passWordRuleParam.setPasswordExpirationDays(userStrategy.getLimitPwdDate());
|
||||||
|
passWordRuleParam.setMixedCheckFlag((Integer)(redisUtil.getObjectByKey("mixedCheckFlag")));
|
||||||
|
passWordRuleParam.setDoubleCheckFlag((Integer)(redisUtil.getObjectByKey("doubleCheckFlag")));
|
||||||
|
passWordRuleParam.setMixedCaseCheckFlag((Integer)(redisUtil.getObjectByKey("mixedCaseCheckFlag")));
|
||||||
|
|
||||||
|
|
||||||
|
return passWordRuleParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean unlockRoot() {
|
||||||
|
userService.lambdaUpdate().eq(User::getLoginName,"root").set(User::getState,DataStateEnum.ENABLE.getCode()).update();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user