开始重构 system 模块的代码,先修改认证逻辑
This commit is contained in:
@@ -26,6 +26,15 @@ public class ServiceExceptionUtil {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceExceptionUtil.class);
|
||||
|
||||
/**
|
||||
* 错误枚举的接口
|
||||
*/
|
||||
public interface Enumerable {
|
||||
|
||||
int getCode();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误码提示模板
|
||||
*/
|
||||
@@ -39,16 +48,31 @@ public class ServiceExceptionUtil {
|
||||
ServiceExceptionUtil.messages.put(code, message);
|
||||
}
|
||||
|
||||
// TODO 芋艿,可能不是目前最优解,目前暂时这样 枚举实现接口
|
||||
public static <T> CommonResult<T> error(Enumerable enumerable) {
|
||||
return error(enumerable.getCode());
|
||||
}
|
||||
|
||||
public static <T> CommonResult<T> error(Enumerable enumerable, Object... params) {
|
||||
return error(enumerable.getCode(), params);
|
||||
}
|
||||
|
||||
public static <T> CommonResult<T> error(Integer code) {
|
||||
return CommonResult.error(code, messages.get(code));
|
||||
}
|
||||
|
||||
public static CommonResult error(Integer code, Object... params) {
|
||||
public static <T> CommonResult<T> error(Integer code, Object... params) {
|
||||
String message = doFormat(code, messages.get(code), params);
|
||||
return CommonResult.error(code, message);
|
||||
}
|
||||
|
||||
public static ServiceException exception(Enumerable enumerable) {
|
||||
return exception(enumerable.getCode());
|
||||
}
|
||||
|
||||
public static ServiceException exception(Enumerable enumerable, Object... params) {
|
||||
return exception(enumerable.getCode(), params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建指定编号的 ServiceException 的异常
|
||||
*
|
||||
|
||||
@@ -2,9 +2,9 @@ package cn.iocoder.mall.spring.boot.web;
|
||||
|
||||
import cn.iocoder.common.framework.constant.MallConstants;
|
||||
import cn.iocoder.common.framework.servlet.CorsFilter;
|
||||
import cn.iocoder.mall.admin.sdk.interceptor.AdminDemoInterceptor;
|
||||
import cn.iocoder.mall.system.sdk.interceptor.AdminDemoInterceptor;
|
||||
import cn.iocoder.mall.spring.boot.web.interceptor.AccessLogInterceptor;
|
||||
import cn.iocoder.mall.admin.sdk.interceptor.AdminSecurityInterceptor;
|
||||
import cn.iocoder.mall.system.sdk.interceptor.AdminSecurityInterceptor;
|
||||
import cn.iocoder.mall.spring.boot.web.handler.GlobalExceptionHandler;
|
||||
import cn.iocoder.mall.spring.boot.web.handler.GlobalResponseBodyHandler;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
||||
@@ -6,9 +6,9 @@ import cn.iocoder.common.framework.util.ExceptionUtil;
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.util.MallUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.SystemLogService;
|
||||
import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.admin.api.dto.systemlog.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.system.api.SystemLogService;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.ExceptionLogAddDTO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.micrometer.core.instrument.Counter;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
|
||||
@@ -3,8 +3,8 @@ package cn.iocoder.mall.spring.boot.web.interceptor;
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.util.MallUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.admin.api.SystemLogService;
|
||||
import cn.iocoder.mall.admin.api.dto.systemlog.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.api.SystemLogService;
|
||||
import cn.iocoder.mall.system.api.dto.systemlog.AccessLogAddDTO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
|
||||
Reference in New Issue
Block a user