增加 auth 认证拦截器
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.convert;
|
||||
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.rpc.request.system.AccessLogAddRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemLogConvert {
|
||||
|
||||
SystemLogConvert INSTANCE = Mappers.getMapper(SystemLogConvert.class);
|
||||
|
||||
AccessLogAddDTO convert(AccessLogAddRequest accessLogAddRequest);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.system.rpc.convert.oauth2;
|
||||
|
||||
import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AccessTokenBO;
|
||||
import cn.iocoder.mall.system.biz.dto.oatuh2.OAuth2AccessTokenAuthenticateDTO;
|
||||
import cn.iocoder.mall.system.rpc.request.oauth2.OAuth2AccessTokenAuthenticateRequest;
|
||||
import cn.iocoder.mall.system.rpc.response.oauth2.OAuth2AccessTokenResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface OAuth2Convert {
|
||||
|
||||
OAuth2Convert INSTANCE = Mappers.getMapper(OAuth2Convert.class);
|
||||
|
||||
OAuth2AccessTokenAuthenticateDTO convert(OAuth2AccessTokenAuthenticateRequest authenticateRequest);
|
||||
|
||||
OAuth2AccessTokenResponse convert(OAuth2AccessTokenBO accessTokenBO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.system.rpc.convert.systemlog;
|
||||
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.AccessLogAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemLogConvert {
|
||||
|
||||
SystemLogConvert INSTANCE = Mappers.getMapper(SystemLogConvert.class);
|
||||
|
||||
AccessLogAddDTO convert(AccessLogAddRequest accessLogAddRequest);
|
||||
|
||||
ExceptionLogAddDTO convert(ExceptionLogAddRequest exceptionLogAddRequest);
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package cn.iocoder.mall.system.rpc.rpc;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.service.system.SystemLogService;
|
||||
import cn.iocoder.mall.system.rpc.api.SystemLogRPC;
|
||||
import cn.iocoder.mall.system.rpc.convert.SystemLogConvert;
|
||||
import cn.iocoder.mall.system.rpc.request.system.AccessLogAddRequest;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Service(version = "${dubbo.provider.SystemLogRPC.version}", validation = "true")
|
||||
public class SystemLogRPCImpl implements SystemLogRPC {
|
||||
|
||||
@Autowired
|
||||
private SystemLogService systemLogService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addAccessLog(AccessLogAddRequest accessLogAddRequest) {
|
||||
AccessLogAddDTO accessLogAddDTO = SystemLogConvert.INSTANCE.convert(accessLogAddRequest);
|
||||
systemLogService.addAccessLog(accessLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.mall.system.rpc.rpc.oauth2;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AccessTokenBO;
|
||||
import cn.iocoder.mall.system.biz.dto.oatuh2.OAuth2AccessTokenAuthenticateDTO;
|
||||
import cn.iocoder.mall.system.biz.service.oauth2.OAuth2Service;
|
||||
import cn.iocoder.mall.system.rpc.api.oauth2.OAuth2RPC;
|
||||
import cn.iocoder.mall.system.rpc.convert.oauth2.OAuth2Convert;
|
||||
import cn.iocoder.mall.system.rpc.request.oauth2.OAuth2AccessTokenAuthenticateRequest;
|
||||
import cn.iocoder.mall.system.rpc.response.oauth2.OAuth2AccessTokenResponse;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Service(version = "${dubbo.provider.OAuth2RPC.version}", validation = "true")
|
||||
public class OAuth2RPCImpl implements OAuth2RPC {
|
||||
|
||||
@Autowired
|
||||
private OAuth2Service oauth2Service;
|
||||
|
||||
@Override
|
||||
public CommonResult<OAuth2AccessTokenResponse> authenticate(OAuth2AccessTokenAuthenticateRequest authenticateRequest) {
|
||||
// 执行认证
|
||||
OAuth2AccessTokenAuthenticateDTO authenticateDTO = OAuth2Convert.INSTANCE.convert(authenticateRequest);
|
||||
OAuth2AccessTokenBO accessTokenBO = oauth2Service.authenticate(authenticateDTO);
|
||||
// 返回结果
|
||||
OAuth2AccessTokenResponse accessTokenResponse = OAuth2Convert.INSTANCE.convert(accessTokenBO);
|
||||
return CommonResult.success(accessTokenResponse);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.system.rpc.rpc.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.service.systemlog.SystemLogService;
|
||||
import cn.iocoder.mall.system.rpc.api.systemlog.SystemLogRPC;
|
||||
import cn.iocoder.mall.system.rpc.convert.systemlog.SystemLogConvert;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.AccessLogAddRequest;
|
||||
import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Service(version = "${dubbo.provider.SystemLogRPC.version}", validation = "true")
|
||||
public class SystemLogRPCImpl implements SystemLogRPC {
|
||||
|
||||
@Autowired
|
||||
private SystemLogService systemLogService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addAccessLog(AccessLogAddRequest accessLogAddRequest) {
|
||||
AccessLogAddDTO accessLogAddDTO = SystemLogConvert.INSTANCE.convert(accessLogAddRequest);
|
||||
systemLogService.addAccessLog(accessLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addExceptionLog(ExceptionLogAddRequest exceptionLogAddRequest) {
|
||||
ExceptionLogAddDTO exceptionLogAddDTO = SystemLogConvert.INSTANCE.convert(exceptionLogAddRequest);
|
||||
systemLogService.addExceptionLog(exceptionLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,8 @@ dubbo:
|
||||
filter: -exception
|
||||
SystemLogRPC:
|
||||
version: 1.0.0
|
||||
OAuth2RPC:
|
||||
version: 1.0.0
|
||||
# Dubbo 服务消费者的配置
|
||||
consumer:
|
||||
SystemLogRPC: # 用于 AccessLogInterceptor 等拦截器,记录 HTTP API 请求的访问日志
|
||||
|
||||
Reference in New Issue
Block a user