增加 auth 认证拦截器
This commit is contained in:
@@ -4,6 +4,7 @@ import cn.iocoder.common.framework.exception.ServiceException;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -100,6 +101,11 @@ public class ServiceExceptionUtil {
|
||||
return new ServiceException(code, message);
|
||||
}
|
||||
|
||||
public static ServiceException exception(CommonResult result) {
|
||||
Assert.isTrue(result.isError(), "结果必须是错误的");
|
||||
return new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将错误编号对应的消息使用 params 进行格式化。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user