From d784b113af5363c33aba1294538f50efe74d76b0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 10 Oct 2021 18:49:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20login=5Flog=E3=80=81error=5Flog=20?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0=20yudao-core-service=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/InfConfigController.java | 2 +- .../controller/file/InfFileController.java | 2 +- .../logger/InfApiAccessLogController.java | 2 +- .../logger/InfApiErrorLogController.java | 2 +- .../convert/config/InfConfigConvert.java | 2 +- .../infra/convert/file/InfFileConvert.java | 2 +- .../logger/InfApiAccessLogConvert.java | 4 +- .../convert/logger/InfApiErrorLogConvert.java | 5 +- .../dal/dataobject/config/InfConfigDO.java | 65 -------- .../dataobject/logger/InfApiErrorLogDO.java | 153 ------------------ .../dal/mysql/config/InfConfigMapper.java | 2 +- .../infra/dal/mysql/file/InfFileMapper.java | 2 +- .../mysql/logger/InfApiAccessLogMapper.java | 6 +- .../mysql/logger/InfApiErrorLogMapper.java | 2 +- .../service/config/InfConfigService.java | 2 +- .../config/impl/InfConfigServiceImpl.java | 2 +- .../infra/service/file/InfFileService.java | 2 +- .../service/file/impl/InfFileServiceImpl.java | 2 +- .../logger/InfApiAccessLogService.java | 7 +- .../service/logger/InfApiErrorLogService.java | 7 +- .../impl/InfApiAccessLogServiceImpl.java | 17 +- .../impl/InfApiErrorLogServiceImpl.java | 20 +-- .../user/SysUserProfileController.java | 3 - .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- .../service/config/InfConfigServiceTest.java | 2 +- .../service/file/InfFileServiceTest.java | 2 +- .../InfApiAccessLogServiceImplTest.java | 22 +-- .../logger/InfApiErrorLogServiceImplTest.java | 25 +-- yudao-core-service/pom.xml | 6 + .../logger/InfApiAccessLogCoreConvert.java | 15 ++ .../logger/InfApiErrorLogCoreConvert.java | 15 ++ .../modules/infra/convert/package-info.java | 2 +- ...道 Spring Boot 对象转换 MapStruct 入门》.md | 0 .../dal/dataobject/config/InfConfigDO.java | 2 +- .../infra/dal/dataobject/file/InfFileDO.java | 2 +- .../dataobject/logger/InfApiAccessLogDO.java | 2 +- .../dataobject/logger/InfApiErrorLogDO.java | 4 +- .../mysql/config/InfConfigCoreDAOImpl.java | 8 +- .../dal/mysql/file/InfFileCoreMapper.java | 10 ++ .../logger/InfApiAccessLogCoreMapper.java | 14 ++ .../logger/InfApiErrorLogCoreMapper.java | 9 ++ .../InfApiErrorLogProcessStatusEnum.java | 2 +- .../modules/infra/enums/package-info.java | 4 + .../logger/InfApiAccessLogCoreService.java | 4 +- .../logger/InfApiErrorLogCoreService.java | 4 +- .../impl/InfApiAccessLogCoreServiceImpl.java | 37 +++++ .../impl/InfApiErrorLogCoreServiceImpl.java | 39 +++++ .../InfApiAccessLogCoreServiceTest.java | 46 ++++++ .../logger/InfApiErrorLogCoreServiceTest.java | 45 ++++++ .../modules/infra/service/package-info.java | 1 + .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 55 +++++++ .../core/util/SecurityFrameworkUtils.java | 1 + .../core/filter/ApiAccessLogFilter.java | 2 +- .../service/ApiAccessLogFrameworkService.java | 3 +- .../service/ApiErrorLogFrameworkService.java | 3 +- .../core/handler/GlobalExceptionHandler.java | 2 +- .../web/core/util/WebFrameworkUtils.java | 22 ++- .../security/SecurityConfiguration.java | 2 +- .../infra/controller/HelloController.java | 28 ---- .../logger/InfApiAccessLogConvert.java | 20 --- .../convert/logger/InfApiErrorLogConvert.java | 20 --- .../infra/dal/dataobject/file/InfFileDO.java | 43 ----- .../dataobject/logger/InfApiAccessLogDO.java | 107 ------------ .../dal/mysql/config/InfConfigDAOImpl.java | 39 ----- .../infra/dal/mysql/file/InfFileMapper.java | 10 -- .../mysql/logger/InfApiAccessLogMapper.java | 16 -- .../mysql/logger/InfApiErrorLogMapper.java | 14 -- .../modules/infra/enums/package-info.java | 4 - .../modules/infra/package-info.java | 7 - .../impl/InfApiAccessLogServiceImpl.java | 36 ----- .../impl/InfApiErrorLogServiceImpl.java | 38 ----- .../modules/infra/service/package-info.java | 1 - .../member/controller/package-info.java | 1 + .../user/SysUserProfileController.http | 3 + .../user/SysUserProfileController.java | 27 ++++ .../member/service/user/MbrUserService.java | 8 + .../service/user/impl/MbrUserServiceImpl.java | 5 + ...brAuthConvert.java => SysAuthConvert.java} | 4 +- .../service/auth/impl/SysAuthServiceImpl.java | 14 +- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- 83 files changed, 432 insertions(+), 748 deletions(-) delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/config/InfConfigDO.java delete mode 100644 yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiAccessLogCoreConvert.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiErrorLogCoreConvert.java rename {yudao-user-server/src/main/java/cn/iocoder/yudao/userserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/convert/package-info.java (56%) rename {yudao-user-server/src/main/java/cn/iocoder/yudao/userserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md (100%) rename {yudao-user-server/src/main/java/cn/iocoder/yudao/userserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/dal/dataobject/config/InfConfigDO.java (94%) rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/dal/dataobject/file/InfFileDO.java (93%) rename {yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java (97%) rename {yudao-user-server/src/main/java/cn/iocoder/yudao/userserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java (95%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/config/InfConfigCoreDAOImpl.java (81%) create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiAccessLogCoreMapper.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiErrorLogCoreMapper.java rename {yudao-user-server/src/main/java/cn/iocoder/yudao/userserver => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice}/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java (86%) create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/package-info.java rename yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreService.java (51%) rename yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java => yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreService.java (51%) create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiAccessLogCoreServiceImpl.java create mode 100644 yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiErrorLogCoreServiceImpl.java create mode 100644 yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreServiceTest.java create mode 100644 yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreServiceTest.java create mode 100644 yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/package-info.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiAccessLogConvert.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiErrorLogConvert.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/package-info.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java delete mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/package-info.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/package-info.java create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http create mode 100644 yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java rename yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/{MbrAuthConvert.java => SysAuthConvert.java} (87%) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/config/InfConfigController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/config/InfConfigController.java index b0ff2ca9a..3167a09d1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/config/InfConfigController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/config/InfConfigController.java @@ -1,12 +1,12 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.config; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.*; import cn.iocoder.yudao.adminserver.modules.infra.convert.config.InfConfigConvert; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.adminserver.modules.infra.service.config.InfConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java index b59593859..6b2c743ca 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java @@ -1,12 +1,12 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.file; import cn.hutool.core.io.IoUtil; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFileRespVO; import cn.iocoder.yudao.adminserver.modules.infra.convert.file.InfFileConvert; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import io.swagger.annotations.Api; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiAccessLogController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiAccessLogController.java index 434fb1f75..3aec60d4f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiAccessLogController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiAccessLogController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.logger; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -9,7 +10,6 @@ import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccess import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO; import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiAccessLogConvert; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiAccessLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiErrorLogController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiErrorLogController.java index abc227fae..7b83022ca 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiErrorLogController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiErrorLogController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.infra.controller.logger; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -9,7 +10,6 @@ import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorl import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogRespVO; import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiErrorLogConvert; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiErrorLogService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/config/InfConfigConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/config/InfConfigConvert.java index 0b076b6e0..4a5eaf2f7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/config/InfConfigConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/config/InfConfigConvert.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.infra.convert.config; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExcelVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigRespVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/file/InfFileConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/file/InfFileConvert.java index 9d3e95ca9..d39452ffe 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/file/InfFileConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/file/InfFileConvert.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.adminserver.modules.infra.convert.file; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFileRespVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiAccessLogConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiAccessLogConvert.java index 71b319cb4..ba21d33ce 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiAccessLogConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiAccessLogConvert.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.adminserver.modules.infra.convert.logger; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExcelVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -20,8 +20,6 @@ public interface InfApiAccessLogConvert { InfApiAccessLogConvert INSTANCE = Mappers.getMapper(InfApiAccessLogConvert.class); - InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean); - InfApiAccessLogRespVO convert(InfApiAccessLogDO bean); List convertList(List list); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiErrorLogConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiErrorLogConvert.java index 359ffafc0..de10d48fc 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiErrorLogConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiErrorLogConvert.java @@ -1,10 +1,9 @@ package cn.iocoder.yudao.adminserver.modules.infra.convert.logger; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExcelVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogRespVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -20,8 +19,6 @@ public interface InfApiErrorLogConvert { InfApiErrorLogConvert INSTANCE = Mappers.getMapper(InfApiErrorLogConvert.class); - InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean); - InfApiErrorLogRespVO convert(InfApiErrorLogDO bean); PageResult convertPage(PageResult page); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/config/InfConfigDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/config/InfConfigDO.java deleted file mode 100644 index 119d069d9..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/config/InfConfigDO.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.adminserver.modules.infra.enums.config.InfConfigTypeEnum; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -/** - * 参数配置表 - * - * @author ruoyi - */ -@TableName("inf_config") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class InfConfigDO extends BaseDO { - - /** - * 参数主键 - */ - @TableId - private Long id; - /** - * 参数分组 - */ - @TableField("`group`") - private String group; - /** - * 参数名称 - */ - private String name; - /** - * 参数键名 - */ - @TableField("`key`") - private String key; - /** - * 参数键值 - */ - private String value; - /** - * 参数类型 - * - * 枚举 {@link InfConfigTypeEnum} - */ - @TableField("`type`") - private Integer type; - /** - * 是否敏感 - * - * 对于敏感配置,需要管理权限才能查看 - */ - @TableField("`sensitive`") - private Boolean sensitive; - /** - * 备注 - */ - private String remark; - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java deleted file mode 100644 index 7f19defca..000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.adminserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.Date; - -/** - * API 异常数据 - * - * @author 芋道源码 - */ -@TableName("inf_api_error_log") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfApiErrorLogDO extends BaseDO { - - /** - * 编号 - */ - private Long id; - /** - * 用户编号 - */ - private Long userId; - /** - * 链路追踪编号 - * - * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。 - */ - private String traceId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - /** - * 应用名 - * - * 目前读取 spring.application.name - */ - private String applicationName; - - // ========== 请求相关字段 ========== - - /** - * 请求方法名 - */ - private String requestMethod; - /** - * 访问地址 - */ - private String requestUrl; - /** - * 请求参数 - * - * query: Query String - * body: Quest Body - */ - private String requestParams; - /** - * 用户 IP - */ - private String userIp; - /** - * 浏览器 UA - */ - private String userAgent; - - // ========== 异常相关字段 ========== - - /** - * 异常发生时间 - */ - private Date exceptionTime; - /** - * 异常名 - * - * {@link Throwable#getClass()} 的类全名 - */ - private String exceptionName; - /** - * 异常导致的消息 - * - * {@link cn.hutool.core.exceptions.ExceptionUtil#getMessage(Throwable)} - */ - private String exceptionMessage; - /** - * 异常导致的根消息 - * - * {@link cn.hutool.core.exceptions.ExceptionUtil#getRootCauseMessage(Throwable)} - */ - private String exceptionRootCauseMessage; - /** - * 异常的栈轨迹 - * - * {@link org.apache.commons.lang3.exception.ExceptionUtils#getStackTrace(Throwable)} - */ - private String exceptionStackTrace; - /** - * 异常发生的类全名 - * - * {@link StackTraceElement#getClassName()} - */ - private String exceptionClassName; - /** - * 异常发生的类文件 - * - * {@link StackTraceElement#getFileName()} - */ - private String exceptionFileName; - /** - * 异常发生的方法名 - * - * {@link StackTraceElement#getMethodName()} - */ - private String exceptionMethodName; - /** - * 异常发生的方法所在行 - * - * {@link StackTraceElement#getLineNumber()} - */ - private Integer exceptionLineNumber; - - // ========== 处理相关字段 ========== - - /** - * 处理状态 - * - * 枚举 {@link InfApiErrorLogProcessStatusEnum} - */ - private Integer processStatus; - /** - * 处理时间 - */ - private Date processTime; - /** - * 处理用户编号 - * - * 关联 {@link SysUserDO#getId()} - */ - private Long processUserId; - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigMapper.java index 546ef843a..e7960eaef 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigMapper.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java index 0a487e025..022f90acb 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; import org.apache.ibatis.annotations.Mapper; @Mapper diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java index 85d04a3b5..4552762fc 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger; +import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; +import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import org.apache.ibatis.annotations.Mapper; import java.util.List; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java index 4e7481d11..d96e5fc3b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import org.apache.ibatis.annotations.Mapper; import java.util.List; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigService.java index 2430c329b..166ebdbd1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigService.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.config; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigPageReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; import javax.validation.Valid; import java.util.List; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/impl/InfConfigServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/impl/InfConfigServiceImpl.java index 13bc2aafc..65839e20e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/impl/InfConfigServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/impl/InfConfigServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.config.impl; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; @@ -8,7 +9,6 @@ import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfig import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; import cn.iocoder.yudao.adminserver.modules.infra.convert.config.InfConfigConvert; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigMapper; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.adminserver.modules.infra.enums.config.InfConfigTypeEnum; import cn.iocoder.yudao.adminserver.modules.infra.mq.producer.config.InfConfigProducer; import cn.iocoder.yudao.adminserver.modules.infra.service.config.InfConfigService; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java index 0a1193365..e19e3ecab 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; /** * 文件 Service 接口 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java index a574147f0..0436b804f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file.impl; import cn.hutool.core.io.FileTypeUtil; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.framework.file.config.FileProperties; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file.InfFileMapper; import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; import org.springframework.stereotype.Service; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogService.java index f4eb6bd43..347372bb4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogService.java @@ -1,10 +1,9 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.logger; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import java.util.List; @@ -13,7 +12,7 @@ import java.util.List; * * @author 芋道源码 */ -public interface InfApiAccessLogService extends ApiAccessLogFrameworkService { +public interface InfApiAccessLogService { /** * 获得 API 访问日志分页 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogService.java index f5e41a57b..c778eee31 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogService.java @@ -1,10 +1,9 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.logger; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import java.util.List; @@ -13,7 +12,7 @@ import java.util.List; * * @author 芋道源码 */ -public interface InfApiErrorLogService extends ApiErrorLogFrameworkService { +public interface InfApiErrorLogService { /** * 获得 API 错误日志分页 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java index aba6382d2..207b3d152 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java @@ -1,21 +1,16 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiAccessLogConvert; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper; import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiAccessLogService; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.AsyncResult; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.List; -import java.util.concurrent.Future; /** * API 访问日志 Service 实现类 @@ -29,14 +24,6 @@ public class InfApiAccessLogServiceImpl implements InfApiAccessLogService { @Resource private InfApiAccessLogMapper apiAccessLogMapper; - @Override - @Async - public Future createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { - InfApiAccessLogDO apiAccessLog = InfApiAccessLogConvert.INSTANCE.convert(createDTO); - int insert = apiAccessLogMapper.insert(apiAccessLog); - return new AsyncResult<>(insert > 1); - } - @Override public PageResult getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO) { return apiAccessLogMapper.selectPage(pageReqVO); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java index aa0fe1fed..6918aec06 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java @@ -1,27 +1,22 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiErrorLogConvert; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper; import cn.iocoder.yudao.adminserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiErrorLogService; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.AsyncResult; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Date; import java.util.List; -import java.util.concurrent.Future; -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants.API_ERROR_LOG_NOT_FOUND; import static cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants.API_ERROR_LOG_PROCESSED; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** * API 错误日志 Service 实现类 @@ -35,15 +30,6 @@ public class InfApiErrorLogServiceImpl implements InfApiErrorLogService { @Resource private InfApiErrorLogMapper apiErrorLogMapper; - @Override - @Async - public Future createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { - InfApiErrorLogDO apiErrorLog = InfApiErrorLogConvert.INSTANCE.convert(createDTO); - apiErrorLog.setProcessStatus(InfApiErrorLogProcessStatusEnum.INIT.getStatus()); - int insert = apiErrorLogMapper.insert(apiErrorLog); - return new AsyncResult<>(insert == 1); - } - @Override public PageResult getApiErrorLogPage(InfApiErrorLogPageReqVO pageReqVO) { return apiErrorLogMapper.selectPage(pageReqVO); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java index b00720ce2..6d4596d76 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/user/SysUserProfileController.java @@ -34,9 +34,6 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY; -/** - * @author niudehua - */ @Api(tags = "用户个人中心") @RestController @RequestMapping("/system/user/profile") diff --git a/yudao-admin-server/src/main/resources/application-dev.yaml b/yudao-admin-server/src/main/resources/application-dev.yaml index 3cbdefcf3..94d9cf9db 100644 --- a/yudao-admin-server/src/main/resources/application-dev.yaml +++ b/yudao-admin-server/src/main/resources/application-dev.yaml @@ -99,7 +99,7 @@ apollo: eagerLoad: enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 - dao: cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigDAOImpl + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl url: ${spring.datasource.dynamic.datasource.master.url} username: ${spring.datasource.dynamic.datasource.master.username} password: ${spring.datasource.dynamic.datasource.master.password} diff --git a/yudao-admin-server/src/main/resources/application-local.yaml b/yudao-admin-server/src/main/resources/application-local.yaml index a0ffb67ec..2d36b7157 100644 --- a/yudao-admin-server/src/main/resources/application-local.yaml +++ b/yudao-admin-server/src/main/resources/application-local.yaml @@ -99,7 +99,7 @@ apollo: eagerLoad: enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 - dao: cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigDAOImpl + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl url: ${spring.datasource.dynamic.datasource.master.url} username: ${spring.datasource.dynamic.datasource.master.username} password: ${spring.datasource.dynamic.datasource.master.password} diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigServiceTest.java index 4ef105df3..311792215 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigServiceTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigServiceTest.java @@ -1,12 +1,12 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.config; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigPageReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigMapper; import cn.iocoder.yudao.adminserver.modules.infra.enums.config.InfConfigTypeEnum; import cn.iocoder.yudao.adminserver.modules.infra.mq.producer.config.InfConfigProducer; diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java index 7643b856c..4849d49cd 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileServiceTest.java @@ -2,10 +2,10 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.file; import cn.hutool.core.io.resource.ResourceUtil; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.adminserver.modules.infra.framework.file.config.FileProperties; import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file.InfFileMapper; import cn.iocoder.yudao.adminserver.modules.infra.service.file.impl.InfFileServiceImpl; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogServiceImplTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogServiceImplTest.java index 689b88ec2..9a1edf3cf 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogServiceImplTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogServiceImplTest.java @@ -2,13 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.logger; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper; import cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl.InfApiAccessLogServiceImpl; import cn.iocoder.yudao.framework.test.core.util.RandomUtils; @@ -38,26 +38,6 @@ public class InfApiAccessLogServiceImplTest extends BaseDbUnitTest { @Resource private InfApiAccessLogMapper infApiAccessLogMapper; - @Test - public void testCreateApiAccessLogAsync() throws Exception { - ApiAccessLogCreateDTO createDTO = RandomUtils.randomPojo( - ApiAccessLogCreateDTO.class, - dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()) - ); - - // 执行service方法 - Future future = infApiAccessLogServiceImpl.createApiAccessLogAsync(createDTO); - - // 等异步执行完 - future.get(); - - InfApiAccessLogDO infApiAccessLogDO = infApiAccessLogMapper.selectOne(null); - // 断言 - assertNotNull(infApiAccessLogDO); - // 断言,忽略基本字段 - assertPojoEquals(createDTO, infApiAccessLogDO); - } - @Test public void testGetApiAccessLogPage() { // 构造测试数据 diff --git a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogServiceImplTest.java b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogServiceImplTest.java index 0a0c26c8a..97ce8c661 100644 --- a/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogServiceImplTest.java +++ b/yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogServiceImplTest.java @@ -2,12 +2,12 @@ package cn.iocoder.yudao.adminserver.modules.infra.service.logger; import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper; import cn.iocoder.yudao.adminserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; import cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl.InfApiErrorLogServiceImpl; @@ -41,28 +41,6 @@ public class InfApiErrorLogServiceImplTest extends BaseDbUnitTest { @Resource private InfApiErrorLogMapper infApiErrorLogMapper; - - @Test - public void testCreateApiErrorLogAsync() throws Exception { - ApiErrorLogCreateDTO createDTO = RandomUtils.randomPojo( - ApiErrorLogCreateDTO.class, - dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()) - ); - - // 执行service方法 - Future future = infApiErrorLogServiceImpl.createApiErrorLogAsync(createDTO); - - // 等异步执行完 - future.get(); - - InfApiErrorLogDO infApiErrorLogDO = infApiErrorLogMapper.selectOne(null); - // 断言 - assertNotNull(infApiErrorLogDO); - // 断言,忽略基本字段 - assertPojoEquals(createDTO, infApiErrorLogDO); - } - - @Test public void testGetApiErrorLogPage() { // 构造测试数据 @@ -204,4 +182,5 @@ public class InfApiErrorLogServiceImplTest extends BaseDbUnitTest { // 验证 progressUserId 是否修改成功 assertEquals(processUserId, secondSelect.getProcessUserId()); } + } diff --git a/yudao-core-service/pom.xml b/yudao-core-service/pom.xml index 7af450cd6..14e92bff9 100644 --- a/yudao-core-service/pom.xml +++ b/yudao-core-service/pom.xml @@ -61,6 +61,12 @@ yudao-spring-boot-starter-redis + + + cn.iocoder.boot + yudao-spring-boot-starter-config + + cn.iocoder.boot diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiAccessLogCoreConvert.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiAccessLogCoreConvert.java new file mode 100644 index 000000000..4bfb4941c --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiAccessLogCoreConvert.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.coreservice.modules.infra.convert.logger; + +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface InfApiAccessLogCoreConvert { + + InfApiAccessLogCoreConvert INSTANCE = Mappers.getMapper(InfApiAccessLogCoreConvert.class); + + InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean); + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiErrorLogCoreConvert.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiErrorLogCoreConvert.java new file mode 100644 index 000000000..8979013d5 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiErrorLogCoreConvert.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.coreservice.modules.infra.convert.logger; + +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface InfApiErrorLogCoreConvert { + + InfApiErrorLogCoreConvert INSTANCE = Mappers.getMapper(InfApiErrorLogCoreConvert.class); + + InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean); + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/package-info.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/package-info.java similarity index 56% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/package-info.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/package-info.java index d1aa5643a..bdb8ce7a3 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/package-info.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/package-info.java @@ -3,4 +3,4 @@ * * 目前使用 MapStruct 框架 */ -package cn.iocoder.yudao.userserver.modules.infra.convert; +package cn.iocoder.yudao.coreservice.modules.infra.convert; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md similarity index 100% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java similarity index 94% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java index a9ab432d6..5955fe18c 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.config; +package cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.TableField; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/file/InfFileDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/file/InfFileDO.java similarity index 93% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/file/InfFileDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/file/InfFileDO.java index 594ae4541..1b4a73328 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/file/InfFileDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/file/InfFileDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file; +package cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.IdType; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java similarity index 97% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java index 229219e04..bd7554405 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger; +package cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java similarity index 95% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java index 6ed2b3150..114ebf23a 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger; +package cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.userserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; +import cn.iocoder.yudao.coreservice.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/config/InfConfigCoreDAOImpl.java similarity index 81% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/config/InfConfigCoreDAOImpl.java index a2e7b6f8a..f3d32513b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/config/InfConfigCoreDAOImpl.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config; +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config; import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO; import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO; @@ -12,15 +12,15 @@ import java.util.Date; import java.util.List; /** - * ConfigFrameworkDAO 实现类 + * ConfigFrameworkDAO Core 实现类 * * @author 芋道源码 */ -public class InfConfigDAOImpl implements ConfigFrameworkDAO { +public class InfConfigCoreDAOImpl implements ConfigFrameworkDAO { private final JdbcTemplate jdbcTemplate; - public InfConfigDAOImpl(String jdbcUrl, String username, String password) { + public InfConfigCoreDAOImpl(String jdbcUrl, String username, String password) { DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password); this.jdbcTemplate = new JdbcTemplate(dataSource); } diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java new file mode 100644 index 000000000..180dc2d79 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface InfFileCoreMapper extends BaseMapperX { + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiAccessLogCoreMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiAccessLogCoreMapper.java new file mode 100644 index 000000000..a18925489 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiAccessLogCoreMapper.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * API 访问日志 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface InfApiAccessLogCoreMapper extends BaseMapperX { +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiErrorLogCoreMapper.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiErrorLogCoreMapper.java new file mode 100644 index 000000000..1776c7887 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiErrorLogCoreMapper.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface InfApiErrorLogCoreMapper extends BaseMapperX { +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java similarity index 86% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java index 618d5d9be..cba1d02dd 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.userserver.modules.infra.enums.logger; +package cn.iocoder.yudao.coreservice.modules.infra.enums.logger; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/package-info.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/package-info.java new file mode 100644 index 000000000..6231dae91 --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位类,可以无视 + */ +package cn.iocoder.yudao.coreservice.modules.infra.enums; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreService.java similarity index 51% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreService.java index bcc4f3a97..f5480572d 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreService.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.userserver.modules.infra.service.logger; +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; @@ -7,6 +7,6 @@ import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServi * * @author 芋道源码 */ -public interface InfApiAccessLogService extends ApiAccessLogFrameworkService { +public interface InfApiAccessLogCoreService extends ApiAccessLogFrameworkService { } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreService.java similarity index 51% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java rename to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreService.java index 2c221604e..6c8d69201 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreService.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.userserver.modules.infra.service.logger; +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; @@ -7,6 +7,6 @@ import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServic * * @author 芋道源码 */ -public interface InfApiErrorLogService extends ApiErrorLogFrameworkService { +public interface InfApiErrorLogCoreService extends ApiErrorLogFrameworkService { } diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiAccessLogCoreServiceImpl.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiAccessLogCoreServiceImpl.java new file mode 100644 index 000000000..6ef022b5a --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiAccessLogCoreServiceImpl.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl; + +import cn.iocoder.yudao.coreservice.modules.infra.convert.logger.InfApiAccessLogCoreConvert; +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper; +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.InfApiAccessLogCoreService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.AsyncResult; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.concurrent.Future; + +/** + * API 访问日志 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +@Slf4j +public class InfApiAccessLogCoreServiceImpl implements InfApiAccessLogCoreService { + + @Resource + private InfApiAccessLogCoreMapper apiAccessLogMapper; + + @Override + @Async + public void createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { + InfApiAccessLogDO apiAccessLog = InfApiAccessLogCoreConvert.INSTANCE.convert(createDTO); + apiAccessLogMapper.insert(apiAccessLog); + } + +} diff --git a/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiErrorLogCoreServiceImpl.java b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiErrorLogCoreServiceImpl.java new file mode 100644 index 000000000..a11552bcb --- /dev/null +++ b/yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiErrorLogCoreServiceImpl.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl; + +import cn.iocoder.yudao.coreservice.modules.infra.convert.logger.InfApiErrorLogCoreConvert; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper; +import cn.iocoder.yudao.coreservice.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.InfApiErrorLogCoreService; +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.AsyncResult; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.concurrent.Future; + +/** + * API 错误日志 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +@Slf4j +public class InfApiErrorLogCoreServiceImpl implements InfApiErrorLogCoreService { + + @Resource + private InfApiErrorLogCoreMapper apiErrorLogMapper; + + @Override + @Async + public void createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { + InfApiErrorLogDO apiErrorLog = InfApiErrorLogCoreConvert.INSTANCE.convert(createDTO); + apiErrorLog.setProcessStatus(InfApiErrorLogProcessStatusEnum.INIT.getStatus()); + apiErrorLogMapper.insert(apiErrorLog); + } + +} diff --git a/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreServiceTest.java b/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreServiceTest.java new file mode 100644 index 000000000..b634cc3c2 --- /dev/null +++ b/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreServiceTest.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; + +import cn.hutool.core.util.RandomUtil; +import cn.iocoder.yudao.coreservice.BaseDbUnitTest; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper; +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiAccessLogCoreServiceImpl; +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.concurrent.Future; + +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * {@link InfApiAccessLogCoreServiceImpl} 单元测试 + */ +@Import(InfApiAccessLogCoreServiceImpl.class) +public class InfApiAccessLogCoreServiceTest extends BaseDbUnitTest { + + @Resource + private InfApiAccessLogCoreService apiAccessLogCoreService; + + @Resource + private InfApiAccessLogCoreMapper apiAccessLogCoreMapper; + + @Test + public void testCreateApiAccessLogAsync() { + // 准备参数 + ApiAccessLogCreateDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateDTO.class, + dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); + + // 调用 + apiAccessLogCoreService.createApiAccessLogAsync(createDTO); + // 断言 + InfApiAccessLogDO infApiAccessLogDO = apiAccessLogCoreMapper.selectOne(null); + assertNotNull(infApiAccessLogDO); + assertPojoEquals(createDTO, infApiAccessLogDO); + } + +} diff --git a/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreServiceTest.java b/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreServiceTest.java new file mode 100644 index 000000000..5ca6449a1 --- /dev/null +++ b/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreServiceTest.java @@ -0,0 +1,45 @@ +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; + +import cn.hutool.core.util.RandomUtil; +import cn.iocoder.yudao.coreservice.BaseDbUnitTest; +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper; +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiErrorLogCoreServiceImpl; +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * {@link InfApiErrorLogCoreServiceImpl} 单元测试 + */ +@Import(InfApiErrorLogCoreServiceImpl.class) +public class InfApiErrorLogCoreServiceTest extends BaseDbUnitTest { + + @Resource + private InfApiErrorLogCoreService apiErrorLogCoreService; + + @Resource + private InfApiErrorLogCoreMapper infApiErrorLogCoreMapper; + + @Test + public void testCreateApiErrorLogAsync() { + // 准备参数 + ApiErrorLogCreateDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateDTO.class, + dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); + + // 调用 + apiErrorLogCoreService.createApiErrorLogAsync(createDTO); + // 断言 + InfApiErrorLogDO infApiErrorLogDO = infApiErrorLogCoreMapper.selectOne(null); + assertNotNull(infApiErrorLogDO); + assertPojoEquals(createDTO, infApiErrorLogDO); + } + +} diff --git a/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/package-info.java b/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/package-info.java new file mode 100644 index 000000000..c3da3526c --- /dev/null +++ b/yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.coreservice.modules.infra.service; diff --git a/yudao-core-service/src/test/resources/sql/clean.sql b/yudao-core-service/src/test/resources/sql/clean.sql index 1fed32f92..7f80fb6c2 100644 --- a/yudao-core-service/src/test/resources/sql/clean.sql +++ b/yudao-core-service/src/test/resources/sql/clean.sql @@ -1,4 +1,6 @@ -- inf 开头的 DB +DELETE FROM "inf_api_access_log"; +DELETE FROM "inf_api_error_log"; -- sys 开头的 DB DELETE FROM "sys_user_session"; diff --git a/yudao-core-service/src/test/resources/sql/create_tables.sql b/yudao-core-service/src/test/resources/sql/create_tables.sql index f81c3f2c9..423903fb9 100644 --- a/yudao-core-service/src/test/resources/sql/create_tables.sql +++ b/yudao-core-service/src/test/resources/sql/create_tables.sql @@ -33,3 +33,58 @@ CREATE TABLE IF NOT EXISTS "sys_dict_data" ( "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") ) COMMENT '字典数据表'; + +CREATE TABLE IF NOT EXISTS "inf_api_access_log" ( + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, + "trace_id" varchar(64) not null default '', + "user_id" bigint not null default '0', + "user_type" tinyint not null default '0', + "application_name" varchar(50) not null, + "request_method" varchar(16) not null default '', + "request_url" varchar(255) not null default '', + "request_params" varchar(8000) not null default '', + "user_ip" varchar(50) not null, + "user_agent" varchar(512) not null, + "begin_time" timestamp not null, + "end_time" timestamp not null, + "duration" integer not null, + "result_code" integer not null default '0', + "result_msg" varchar(512) default '', + "creator" varchar(64) default '', + "create_time" timestamp not null default current_timestamp, + "updater" varchar(64) default '', + "update_time" timestamp not null default current_timestamp, + "deleted" bit not null default false, + primary key ("id") + ) COMMENT 'API 访问日志表'; + +CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( + "id" integer not null GENERATED BY DEFAULT AS IDENTITY, + "trace_id" varchar(64) not null, + "user_id" bigint not null default '0', + "user_type" tinyint not null default '0', + "application_name" varchar(50) not null, + "request_method" varchar(16) not null, + "request_url" varchar(255) not null, + "request_params" varchar(8000) not null, + "user_ip" varchar(50) not null, + "user_agent" varchar(512) not null, + "exception_time" timestamp not null, + "exception_name" varchar(128) not null default '', + "exception_message" clob not null, + "exception_root_cause_message" clob not null, + "exception_stack_trace" clob not null, + "exception_class_name" varchar(512) not null, + "exception_file_name" varchar(512) not null, + "exception_method_name" varchar(512) not null, + "exception_line_number" integer not null, + "process_status" tinyint not null, + "process_time" timestamp default null, + "process_user_id" bigint default '0', + "creator" varchar(64) default '', + "create_time" timestamp not null default current_timestamp, + "updater" varchar(64) default '', + "update_time" timestamp not null default current_timestamp, + "deleted" bit not null default false, + primary key ("id") + ) COMMENT '系统异常日志'; diff --git a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java index f9b0bb0a5..eb5f4935c 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-security/src/main/java/cn/iocoder/yudao/framework/security/core/util/SecurityFrameworkUtils.java @@ -97,6 +97,7 @@ public class SecurityFrameworkUtils { // 额外设置到 request 中,用于 ApiAccessLogFilter 可以获取到用户编号; // 原因是,Spring Security 的 Filter 在 ApiAccessLogFilter 后面,在它记录访问日志时,线上上下文已经没有用户编号等信息 WebFrameworkUtils.setLoginUserId(request, loginUser.getId()); + WebFrameworkUtils.setLoginUserType(request, loginUser.getUserType()); } } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java index 49f54fe25..008d6ca6a 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/filter/ApiAccessLogFilter.java @@ -81,7 +81,7 @@ public class ApiAccessLogFilter extends OncePerRequestFilter { Map queryString, String requestBody, Exception ex) { // 处理用户信息 accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); - accessLog.setUserType(WebFrameworkUtils.getUserType(request)); + accessLog.setUserType(WebFrameworkUtils.getLoginUserType(request)); // 设置访问结果 CommonResult result = WebFrameworkUtils.getCommonResult(request); if (result != null) { diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java index fd7c22ed8..a999e8339 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLogFrameworkService.java @@ -16,8 +16,7 @@ public interface ApiAccessLogFrameworkService { * 创建 API 访问日志 * * @param createDTO 创建信息 - * @return 是否创建成功 */ - Future createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO); + void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO); } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java index 1c55adb4f..55733e95f 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLogFrameworkService.java @@ -16,8 +16,7 @@ public interface ApiErrorLogFrameworkService { * 创建 API 错误日志 * * @param createDTO 创建信息 - * @return 是否创建成功 */ - Future createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO); + void createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO); } diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java index a27d87a82..cb0aefd8d 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java @@ -245,7 +245,7 @@ public class GlobalExceptionHandler { private void initExceptionLog(ApiErrorLogCreateDTO errorLog, HttpServletRequest request, Throwable e) { // 处理用户信息 errorLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); - errorLog.setUserType(WebFrameworkUtils.getUserType(request)); + errorLog.setUserType(WebFrameworkUtils.getLoginUserType(request)); // 设置异常字段 errorLog.setExceptionName(e.getClass().getName()); errorLog.setExceptionMessage(ExceptionUtil.getMessage(e)); diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java index 2bf5c2ff8..acbfb9c2b 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/util/WebFrameworkUtils.java @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; public class WebFrameworkUtils { private static final String REQUEST_ATTRIBUTE_LOGIN_USER_ID = "login_user_id"; + private static final String REQUEST_ATTRIBUTE_LOGIN_USER_TYPE = "login_user_type"; private static final String REQUEST_ATTRIBUTE_COMMON_RESULT = "common_result"; @@ -24,6 +25,10 @@ public class WebFrameworkUtils { request.setAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_ID, userId); } + public static void setLoginUserType(ServletRequest request, Integer userType) { + request.setAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_TYPE, userType); + } + /** * 获得当前用户的编号,从请求中 * @@ -37,15 +42,24 @@ public class WebFrameworkUtils { return (Long) request.getAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_ID); } + /** + * 获得当前用户的类型,从请求中 + * + * @param request 请求 + * @return 用户编号 + */ + public static Integer getLoginUserType(HttpServletRequest request) { + if (request == null) { + return null; + } + return (Integer) request.getAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_TYPE); + } + public static Long getLoginUserId() { HttpServletRequest request = getRequest(); return getLoginUserId(request); } - public static Integer getUserType(HttpServletRequest request) { - return UserTypeEnum.ADMIN.getValue(); // TODO 芋艿:等后续优化 - } - public static void setCommonResult(ServletRequest request, CommonResult result) { request.setAttribute(REQUEST_ATTRIBUTE_COMMON_RESULT, result); } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/security/SecurityConfiguration.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/security/SecurityConfiguration.java index e43f5e3e6..66a0ae718 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/security/SecurityConfiguration.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/security/SecurityConfiguration.java @@ -18,7 +18,7 @@ public class SecurityConfiguration { @Bean public Customizer.ExpressionInterceptUrlRegistry> authorizeRequestsCustomizer() { return registry -> { - registry.antMatchers(api("/**")).anonymous(); // 默认 API 都是用户可访问 + registry.antMatchers(api("/**")).permitAll(); // 默认 API 都是用户可访问 }; } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java deleted file mode 100644 index 6a3270fc2..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.controller; - -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.annotation.Secured; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author weir - */ -@Slf4j -@RestController -public class HelloController { - - @RequestMapping("/user/hello") - public String hello(String hello) { - return "echo + " + hello; - } - - @RequestMapping("/user/info") - @PreAuthenticated - public String xx() { - return "none"; - } - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiAccessLogConvert.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiAccessLogConvert.java deleted file mode 100644 index 3ddbbf65b..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiAccessLogConvert.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.convert.logger; - -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * API 访问日志 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface InfApiAccessLogConvert { - - InfApiAccessLogConvert INSTANCE = Mappers.getMapper(InfApiAccessLogConvert.class); - - InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean); - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiErrorLogConvert.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiErrorLogConvert.java deleted file mode 100644 index 51c6c3eef..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiErrorLogConvert.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.convert.logger; - -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -/** - * API 错误日志 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface InfApiErrorLogConvert { - - InfApiErrorLogConvert INSTANCE = Mappers.getMapper(InfApiErrorLogConvert.class); - - InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean); - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java deleted file mode 100644 index 604a888c2..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.io.InputStream; - -/** - * 文件表 - * - * @author 芋道源码 - */ -@Data -@TableName("inf_file") -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfFileDO extends BaseDO { - - /** - * 文件路径 - */ - @TableId(type = IdType.INPUT) - private String id; - /** - * 文件类型 - * - * 通过 {@link cn.hutool.core.io.FileTypeUtil#getType(InputStream)} 获取 - */ - @TableField(value = "`type`") - private String type; - /** - * 文件内容 - */ - private byte[] content; - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java deleted file mode 100644 index 2548ec469..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger; - -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; - -import java.util.Date; - -/** - * API 访问日志 - * - * @author 芋道源码 - */ -@TableName("inf_api_access_log") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class InfApiAccessLogDO extends BaseDO { - - /** - * 编号 - */ - @TableId - private Integer id; - /** - * 链路追踪编号 - * - * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。 - */ - private String traceId; - /** - * 用户编号 - */ - private Long userId; - /** - * 用户类型 - * - * 枚举 {@link UserTypeEnum} - */ - private Integer userType; - /** - * 应用名 - * - * 目前读取 `spring.application.name` 配置项 - */ - private String applicationName; - - // ========== 请求相关字段 ========== - - /** - * 请求方法名 - */ - private String requestMethod; - /** - * 访问地址 - */ - private String requestUrl; - /** - * 请求参数 - * - * query: Query String - * body: Quest Body - */ - private String requestParams; - /** - * 用户 IP - */ - private String userIp; - /** - * 浏览器 UA - */ - private String userAgent; - - // ========== 执行相关字段 ========== - - /** - * 开始请求时间 - */ - private Date beginTime; - /** - * 结束请求时间 - */ - private Date endTime; - /** - * 执行时长,单位:毫秒 - */ - private Integer duration; - /** - * 结果码 - * - * 目前使用的 {@link CommonResult#getCode()} 属性 - */ - private Integer resultCode; - /** - * 结果提示 - * - * 目前使用的 {@link CommonResult#getMsg()} 属性 - */ - private String resultMsg; - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java deleted file mode 100644 index 5453c05a2..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config; - -import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO; -import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO; -import org.springframework.jdbc.core.BeanPropertyRowMapper; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DriverManagerDataSource; - -import javax.sql.DataSource; -import java.sql.ResultSet; -import java.util.Date; -import java.util.List; - -/** - * ConfigFrameworkDAO 实现类 - * - * @author 芋道源码 - */ -public class InfConfigDAOImpl implements ConfigFrameworkDAO { - - private final JdbcTemplate jdbcTemplate; - - public InfConfigDAOImpl(String jdbcUrl, String username, String password) { - DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password); - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - @Override - public boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) { - return jdbcTemplate.query("SELECT id FROM inf_config WHERE update_time > ? LIMIT 1", - ResultSet::next, maxUpdateTime); - } - - @Override - public List selectList() { - return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(ConfigRespDTO.class)); - } - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java deleted file mode 100644 index 1db7d311b..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.file; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file.InfFileDO; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface InfFileMapper extends BaseMapperX { - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java deleted file mode 100644 index cf7f6e92c..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * API 访问日志 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfApiAccessLogMapper extends BaseMapperX { -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java deleted file mode 100644 index 9e9124267..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; -import org.apache.ibatis.annotations.Mapper; - -/** - * API 错误日志 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface InfApiErrorLogMapper extends BaseMapperX { -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/package-info.java deleted file mode 100644 index 3a03078cb..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 占位类,可以无视 - */ -package cn.iocoder.yudao.userserver.modules.infra.enums; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java deleted file mode 100644 index fdf89894e..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * infra 包下,我们放基础设施的运维与管理,支撑上层的通用与核心业务。 - * 例如说:定时任务的管理、服务器的信息等等 - * - * 缩写:inf - */ -package cn.iocoder.yudao.userserver.modules.infra; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java deleted file mode 100644 index 1b0f2611c..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; - -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; -import cn.iocoder.yudao.userserver.modules.infra.convert.logger.InfApiAccessLogConvert; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; -import cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper; -import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiAccessLogService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.AsyncResult; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.concurrent.Future; - -/** - * API 访问日志 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class InfApiAccessLogServiceImpl implements InfApiAccessLogService { - - @Resource - private InfApiAccessLogMapper apiAccessLogMapper; - - @Override - public Future createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { - InfApiAccessLogDO apiAccessLog = InfApiAccessLogConvert.INSTANCE.convert(createDTO); - int insert = apiAccessLogMapper.insert(apiAccessLog); - return new AsyncResult<>(insert > 1); - } - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java deleted file mode 100644 index 05bddb7d9..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; - -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; -import cn.iocoder.yudao.userserver.modules.infra.convert.logger.InfApiErrorLogConvert; -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; -import cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper; -import cn.iocoder.yudao.userserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; -import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiErrorLogService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.AsyncResult; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import javax.annotation.Resource; -import java.util.concurrent.Future; - -/** - * API 错误日志 Service 实现类 - * - * @author 芋道源码 - */ -@Service -@Validated -@Slf4j -public class InfApiErrorLogServiceImpl implements InfApiErrorLogService { - - @Resource - private InfApiErrorLogMapper apiErrorLogMapper; - - @Override - public Future createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { - InfApiErrorLogDO apiErrorLog = InfApiErrorLogConvert.INSTANCE.convert(createDTO); - apiErrorLog.setProcessStatus(InfApiErrorLogProcessStatusEnum.INIT.getStatus()); - int insert = apiErrorLogMapper.insert(apiErrorLog); - return new AsyncResult<>(insert == 1); - } - -} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/package-info.java deleted file mode 100644 index 217acf96f..000000000 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.userserver.modules.infra.service; \ No newline at end of file diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/package-info.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/package-info.java new file mode 100644 index 000000000..148c73cf3 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.userserver.modules.member.controller; diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http new file mode 100644 index 000000000..72cf861b8 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http @@ -0,0 +1,3 @@ +### 请求 /system/user/profile/get 接口 => 没有权限 +GET {{userServerUrl}}/system/user/profile/get +Authorization: Bearer test245 diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java new file mode 100644 index 000000000..4b66b4e18 --- /dev/null +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.userserver.modules.member.controller.user; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Api(tags = "用户个人中心") +@RestController +@RequestMapping("/system/user/profile") +@Validated +@Slf4j +public class SysUserProfileController { + + @GetMapping("/get") + @ApiOperation("获得登录用户信息") + @PreAuthenticated + public CommonResult profile() { + return null; + } + +} diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java index a716b3649..9a53d429a 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java @@ -25,4 +25,12 @@ public interface MbrUserService { */ void updateUserLogin(Long id, String loginIp); + /** + * 通过用户 ID 查询用户 + * + * @param id 用户ID + * @return 用户对象信息 + */ + MbrUserDO getUser(Long id); + } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java index 2270ac9d1..ea15c4156 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/impl/MbrUserServiceImpl.java @@ -33,4 +33,9 @@ public class MbrUserServiceImpl implements MbrUserService { userMapper.updateById(new MbrUserDO().setId(id).setLoginIp(loginIp).setLoginDate(new Date())); } + @Override + public MbrUserDO getUser(Long id) { + return userMapper.selectById(id); + } + } diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/MbrAuthConvert.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/SysAuthConvert.java similarity index 87% rename from yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/MbrAuthConvert.java rename to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/SysAuthConvert.java index 00edbfd5f..474b3368c 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/MbrAuthConvert.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/SysAuthConvert.java @@ -8,9 +8,9 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @Mapper -public interface MbrAuthConvert { +public interface SysAuthConvert { - MbrAuthConvert INSTANCE = Mappers.getMapper(MbrAuthConvert.class); + SysAuthConvert INSTANCE = Mappers.getMapper(SysAuthConvert.class); @Mapping(source = "mobile", target = "username") LoginUser convert0(MbrUserDO bean); diff --git a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java index 4a2c32fd5..0c84cfcea 100644 --- a/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java +++ b/yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java @@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.SysAuthLoginReqVO; -import cn.iocoder.yudao.userserver.modules.system.convert.auth.MbrAuthConvert; +import cn.iocoder.yudao.userserver.modules.system.convert.auth.SysAuthConvert; import cn.iocoder.yudao.userserver.modules.member.dal.dataobject.user.MbrUserDO; import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService; import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService; @@ -60,7 +60,7 @@ public class SysAuthServiceImpl implements SysAuthService { throw new UsernameNotFoundException(mobile); } // 创建 LoginUser 对象 - return MbrAuthConvert.INSTANCE.convert(user); + return SysAuthConvert.INSTANCE.convert(user); } @Override @@ -125,7 +125,15 @@ public class SysAuthServiceImpl implements SysAuthService { @Override public LoginUser mockLogin(Long userId) { - return null; + // 获取用户编号对应的 MbrUserDO + MbrUserDO user = userService.getUser(userId); + if (user == null) { + throw new UsernameNotFoundException(String.valueOf(userId)); + } + this.createLoginLog(user.getMobile(), SysLoginLogTypeEnum.LOGIN_MOCK, SysLoginResultEnum.SUCCESS); + + // 创建 LoginUser 对象 + return SysAuthConvert.INSTANCE.convert(user); } @Override diff --git a/yudao-user-server/src/main/resources/application-dev.yaml b/yudao-user-server/src/main/resources/application-dev.yaml index b85826169..b6bfbd1dd 100644 --- a/yudao-user-server/src/main/resources/application-dev.yaml +++ b/yudao-user-server/src/main/resources/application-dev.yaml @@ -72,7 +72,7 @@ apollo: eagerLoad: enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 - dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl url: ${spring.datasource.dynamic.datasource.master.url} username: ${spring.datasource.dynamic.datasource.master.username} password: ${spring.datasource.dynamic.datasource.master.password} diff --git a/yudao-user-server/src/main/resources/application-local.yaml b/yudao-user-server/src/main/resources/application-local.yaml index 927c17e17..506ee19f6 100644 --- a/yudao-user-server/src/main/resources/application-local.yaml +++ b/yudao-user-server/src/main/resources/application-local.yaml @@ -72,7 +72,7 @@ apollo: eagerLoad: enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 - dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl url: ${spring.datasource.dynamic.datasource.master.url} username: ${spring.datasource.dynamic.datasource.master.username} password: ${spring.datasource.dynamic.datasource.master.password}