密码规则配置功能
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.njcn.user.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.user.api.fallback.PassWordRuleClientFallbackFactory;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/7/12 15:59【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.USER,
|
||||
// url = "http://127.0.0.1:10201",
|
||||
path = "/password", fallbackFactory = PassWordRuleClientFallbackFactory.class,
|
||||
contextId = "password"
|
||||
)
|
||||
public interface PassWordRuleFeugnClient {
|
||||
@PostMapping(value = "/getUserStrategy")
|
||||
public HttpResult<UserStrategy> getUserStrategy() ;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.user.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.user.api.PassWordRuleFeugnClient;
|
||||
import com.njcn.user.pojo.po.UserStrategy;
|
||||
import com.njcn.user.utils.UserEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年08月24日 10:21
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PassWordRuleClientFallbackFactory implements FallbackFactory<PassWordRuleFeugnClient> {
|
||||
|
||||
|
||||
/**
|
||||
* 输出远程请求接口异常日志
|
||||
* @param cause RPC请求异常
|
||||
*/
|
||||
@Override
|
||||
public PassWordRuleFeugnClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = UserEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new PassWordRuleFeugnClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<UserStrategy> getUserStrategy() {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询密码规则",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,8 @@ public enum UserResponseEnum {
|
||||
CODE_TYPE_ERROR("A0101","验证码类型非法"),
|
||||
SEND_CODE_FAIL("A0101","验证码发送失败"),
|
||||
LOGIN_USER_DELETE("A0101", "账号已被注销"),
|
||||
LOGIN_USER_LOCKED("A0101", "账号已被锁定"),
|
||||
LOGIN_USER_OVERLIMIT("A0101", "登陆用户数不能大于配置用户并发量"),
|
||||
LOGIN_USER_LOCKED("A0102", "账号已被锁定"),
|
||||
LOGIN_USER_UNAUDITED("A0101", "账号未审核"),
|
||||
NEED_MODIFY_PASSWORD("A0101", "密码需修改"),
|
||||
LOGIN_USER_SLEEP("A0101", "账号已休眠"),
|
||||
|
||||
Reference in New Issue
Block a user