动态枚举内容功能增加
This commit is contained in:
@@ -103,12 +103,18 @@ public enum CommonResponseEnum {
|
|||||||
|
|
||||||
ADVANCE_RESPONSE_ENUM("A00105", "终端响应枚举类型"),
|
ADVANCE_RESPONSE_ENUM("A00105", "终端响应枚举类型"),
|
||||||
|
|
||||||
|
DYNAMIC_RESPONSE_ENUM("A00002", "动态枚举内容"),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
private final String message;
|
private String message;
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
CommonResponseEnum(String code, String message) {
|
CommonResponseEnum(String code, String message) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|||||||
@@ -51,7 +51,13 @@ public class FeignConfig {
|
|||||||
//对结果进行转换
|
//对结果进行转换
|
||||||
HttpResult<Object> result = PubUtils.json2obj(bodyStr, type);
|
HttpResult<Object> result = PubUtils.json2obj(bodyStr, type);
|
||||||
//如果返回错误,且为内部错误,则直接抛出异常
|
//如果返回错误,且为内部错误,则直接抛出异常
|
||||||
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
CommonResponseEnum commonResponseEnum;
|
||||||
|
if(result.getCode().equals(CommonResponseEnum.DYNAMIC_RESPONSE_ENUM.getCode())){
|
||||||
|
commonResponseEnum = CommonResponseEnum.DEVICE_RESPONSE_ENUM;
|
||||||
|
commonResponseEnum.setMessage(result.getMessage());
|
||||||
|
}else{
|
||||||
|
commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
|
||||||
|
}
|
||||||
switch (commonResponseEnum) {
|
switch (commonResponseEnum) {
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -117,61 +117,64 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|||||||
@Override
|
@Override
|
||||||
public void judgeUserStatus(String loginName) {
|
public void judgeUserStatus(String loginName) {
|
||||||
User user = getUserByLoginName(loginName);
|
User user = getUserByLoginName(loginName);
|
||||||
if (Objects.isNull(user)) {
|
CommonResponseEnum testEnum = CommonResponseEnum.DYNAMIC_RESPONSE_ENUM;
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD);
|
testEnum.setMessage("测试自定义等于失败");
|
||||||
}
|
throw new BusinessException(testEnum);
|
||||||
//超级管理员则不做任何逻辑判断
|
// if (Objects.isNull(user)) {
|
||||||
if (user.getType() == 0) {
|
// throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD);
|
||||||
//更新用户登录时间,以及错误登录记录的信息归零。
|
// }
|
||||||
user.setState(UserState.ENABLE);
|
// //超级管理员则不做任何逻辑判断
|
||||||
user.setLoginErrorTimes(0);
|
// if (user.getType() == 0) {
|
||||||
user.setLoginTime(LocalDateTime.now());
|
// //更新用户登录时间,以及错误登录记录的信息归零。
|
||||||
user.setFirstErrorTime(null);
|
// user.setState(UserState.ENABLE);
|
||||||
user.setLockTime(null);
|
// user.setLoginErrorTimes(0);
|
||||||
this.baseMapper.updateById(user);
|
// user.setLoginTime(LocalDateTime.now());
|
||||||
return;
|
// user.setFirstErrorTime(null);
|
||||||
}
|
// user.setLockTime(null);
|
||||||
//根据用户类型获取对应用户策略
|
// this.baseMapper.updateById(user);
|
||||||
UserStrategy userStrategy = userStrategyService.lambdaQuery()
|
// return;
|
||||||
.eq(UserStrategy::getType, user.getCasualUser())
|
// }
|
||||||
.eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
// //根据用户类型获取对应用户策略
|
||||||
.one();
|
// UserStrategy userStrategy = userStrategyService.lambdaQuery()
|
||||||
switch (user.getState()) {
|
// .eq(UserStrategy::getType, user.getCasualUser())
|
||||||
case UserState.LOCKED:
|
// .eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode())
|
||||||
LocalDateTime lockTime = user.getLockTime();
|
// .one();
|
||||||
lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime());
|
// switch (user.getState()) {
|
||||||
LocalDateTime nowTime = LocalDateTime.now();
|
// case UserState.LOCKED:
|
||||||
//判断是否满足锁定时间
|
// LocalDateTime lockTime = user.getLockTime();
|
||||||
if (nowTime.isBefore(lockTime)) {
|
// lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime());
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_LOCKED);
|
// LocalDateTime nowTime = LocalDateTime.now();
|
||||||
}
|
// //判断是否满足锁定时间
|
||||||
break;
|
// if (nowTime.isBefore(lockTime)) {
|
||||||
case UserState.DELETE:
|
// throw new BusinessException(UserResponseEnum.LOGIN_USER_LOCKED);
|
||||||
//用户已注销
|
// }
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE);
|
// break;
|
||||||
case UserState.UNCHECK:
|
// case UserState.DELETE:
|
||||||
//用户未审核
|
// //用户已注销
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED);
|
// throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE);
|
||||||
case UserState.SLEEP:
|
// case UserState.UNCHECK:
|
||||||
//用户已休眠
|
// //用户未审核
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP);
|
// throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED);
|
||||||
case UserState.OVERDUE:
|
// case UserState.SLEEP:
|
||||||
//用户密码已过期
|
// //用户已休眠
|
||||||
throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED);
|
// throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP);
|
||||||
default:
|
// case UserState.OVERDUE:
|
||||||
if (user.getPwdState() == 1) {
|
// //用户密码已过期
|
||||||
throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD);
|
// throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED);
|
||||||
}
|
// default:
|
||||||
//用户状态正常,判断其他细节
|
// if (user.getPwdState() == 1) {
|
||||||
judgeFirstLogin(user, userStrategy);
|
// throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD);
|
||||||
}
|
// }
|
||||||
//所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。
|
// //用户状态正常,判断其他细节
|
||||||
user.setState(UserState.ENABLE);
|
// judgeFirstLogin(user, userStrategy);
|
||||||
user.setLoginErrorTimes(0);
|
// }
|
||||||
user.setLoginTime(LocalDateTime.now());
|
// //所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。
|
||||||
user.setFirstErrorTime(null);
|
// user.setState(UserState.ENABLE);
|
||||||
user.setLockTime(null);
|
// user.setLoginErrorTimes(0);
|
||||||
this.baseMapper.updateById(user);
|
// user.setLoginTime(LocalDateTime.now());
|
||||||
|
// user.setFirstErrorTime(null);
|
||||||
|
// user.setLockTime(null);
|
||||||
|
// this.baseMapper.updateById(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user