diff --git a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java index 8c76b4785..44fe80668 100644 --- a/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java +++ b/pqs-common/common-core/src/main/java/com/njcn/common/pojo/enums/response/CommonResponseEnum.java @@ -103,12 +103,18 @@ public enum CommonResponseEnum { ADVANCE_RESPONSE_ENUM("A00105", "终端响应枚举类型"), + DYNAMIC_RESPONSE_ENUM("A00002", "动态枚举内容"), + ; private final String code; - private final String message; + private String message; + + public void setMessage(String message) { + this.message = message; + } CommonResponseEnum(String code, String message) { this.code = code; diff --git a/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java b/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java index 6a9071d7f..12c977798 100644 --- a/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java +++ b/pqs-common/common-web/src/main/java/com/njcn/web/config/FeignConfig.java @@ -51,7 +51,13 @@ public class FeignConfig { //对结果进行转换 HttpResult 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) { case SUCCESS: return result; diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/UserServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/UserServiceImpl.java index 7efbcb029..0e2d1d247 100644 --- a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/UserServiceImpl.java +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/UserServiceImpl.java @@ -117,61 +117,64 @@ public class UserServiceImpl extends ServiceImpl implements IU @Override public void judgeUserStatus(String loginName) { User user = getUserByLoginName(loginName); - if (Objects.isNull(user)) { - throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD); - } - //超级管理员则不做任何逻辑判断 - if (user.getType() == 0) { - //更新用户登录时间,以及错误登录记录的信息归零。 - user.setState(UserState.ENABLE); - user.setLoginErrorTimes(0); - user.setLoginTime(LocalDateTime.now()); - user.setFirstErrorTime(null); - user.setLockTime(null); - this.baseMapper.updateById(user); - return; - } - //根据用户类型获取对应用户策略 - UserStrategy userStrategy = userStrategyService.lambdaQuery() - .eq(UserStrategy::getType, user.getCasualUser()) - .eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode()) - .one(); - switch (user.getState()) { - case UserState.LOCKED: - LocalDateTime lockTime = user.getLockTime(); - lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime()); - LocalDateTime nowTime = LocalDateTime.now(); - //判断是否满足锁定时间 - if (nowTime.isBefore(lockTime)) { - throw new BusinessException(UserResponseEnum.LOGIN_USER_LOCKED); - } - break; - case UserState.DELETE: - //用户已注销 - throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE); - case UserState.UNCHECK: - //用户未审核 - throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED); - case UserState.SLEEP: - //用户已休眠 - throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP); - case UserState.OVERDUE: - //用户密码已过期 - throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED); - default: - if (user.getPwdState() == 1) { - throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD); - } - //用户状态正常,判断其他细节 - judgeFirstLogin(user, userStrategy); - } - //所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。 - user.setState(UserState.ENABLE); - user.setLoginErrorTimes(0); - user.setLoginTime(LocalDateTime.now()); - user.setFirstErrorTime(null); - user.setLockTime(null); - this.baseMapper.updateById(user); + CommonResponseEnum testEnum = CommonResponseEnum.DYNAMIC_RESPONSE_ENUM; + testEnum.setMessage("测试自定义等于失败"); + throw new BusinessException(testEnum); +// if (Objects.isNull(user)) { +// throw new BusinessException(UserResponseEnum.LOGIN_WRONG_PWD); +// } +// //超级管理员则不做任何逻辑判断 +// if (user.getType() == 0) { +// //更新用户登录时间,以及错误登录记录的信息归零。 +// user.setState(UserState.ENABLE); +// user.setLoginErrorTimes(0); +// user.setLoginTime(LocalDateTime.now()); +// user.setFirstErrorTime(null); +// user.setLockTime(null); +// this.baseMapper.updateById(user); +// return; +// } +// //根据用户类型获取对应用户策略 +// UserStrategy userStrategy = userStrategyService.lambdaQuery() +// .eq(UserStrategy::getType, user.getCasualUser()) +// .eq(UserStrategy::getState, DataStateEnum.ENABLE.getCode()) +// .one(); +// switch (user.getState()) { +// case UserState.LOCKED: +// LocalDateTime lockTime = user.getLockTime(); +// lockTime = lockTime.plusMinutes(userStrategy.getLockPwdTime()); +// LocalDateTime nowTime = LocalDateTime.now(); +// //判断是否满足锁定时间 +// if (nowTime.isBefore(lockTime)) { +// throw new BusinessException(UserResponseEnum.LOGIN_USER_LOCKED); +// } +// break; +// case UserState.DELETE: +// //用户已注销 +// throw new BusinessException(UserResponseEnum.LOGIN_USER_DELETE); +// case UserState.UNCHECK: +// //用户未审核 +// throw new BusinessException(UserResponseEnum.LOGIN_USER_UNAUDITED); +// case UserState.SLEEP: +// //用户已休眠 +// throw new BusinessException(UserResponseEnum.LOGIN_USER_SLEEP); +// case UserState.OVERDUE: +// //用户密码已过期 +// throw new BusinessException(UserResponseEnum.LOGIN_USER_PASSWORD_EXPIRED); +// default: +// if (user.getPwdState() == 1) { +// throw new BusinessException(UserResponseEnum.NEED_MODIFY_PWD); +// } +// //用户状态正常,判断其他细节 +// judgeFirstLogin(user, userStrategy); +// } +// //所有验证通过后,更新用户登录时间,以及错误登录记录的信息归零。 +// user.setState(UserState.ENABLE); +// user.setLoginErrorTimes(0); +// user.setLoginTime(LocalDateTime.now()); +// user.setFirstErrorTime(null); +// user.setLockTime(null); +// this.baseMapper.updateById(user); } @Override