Commit d784b113af5363c33aba1294538f50efe74d76b0
1 parent
028c99aa
将 login_log、error_log 迁移到 yudao-core-service 项目中
Showing
78 changed files
with
360 additions
and
676 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/config/InfConfigController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.controller.config; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | 7 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.*; |
| 8 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.convert.config.InfConfigConvert; |
| 9 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 10 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.service.config.InfConfigService; |
| 11 | 11 | import io.swagger.annotations.Api; |
| 12 | 12 | import io.swagger.annotations.ApiImplicitParam; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/file/InfFileController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.controller.file; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.IoUtil; |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFileRespVO; |
| 8 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.convert.file.InfFileConvert; |
| 9 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 10 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; |
| 11 | 11 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 12 | 12 | import io.swagger.annotations.Api; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiAccessLogController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.controller.logger; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| ... | ... | @@ -9,7 +10,6 @@ import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccess |
| 9 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; |
| 10 | 11 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO; |
| 11 | 12 | import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiAccessLogConvert; |
| 12 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 13 | 13 | import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiAccessLogService; |
| 14 | 14 | import io.swagger.annotations.Api; |
| 15 | 15 | import io.swagger.annotations.ApiOperation; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/controller/logger/InfApiErrorLogController.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.controller.logger; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| ... | ... | @@ -9,7 +10,6 @@ import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorl |
| 9 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; |
| 10 | 11 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogRespVO; |
| 11 | 12 | import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiErrorLogConvert; |
| 12 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 13 | 13 | import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiErrorLogService; |
| 14 | 14 | import io.swagger.annotations.Api; |
| 15 | 15 | import io.swagger.annotations.ApiImplicitParam; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/config/InfConfigConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.convert.config; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExcelVO; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigRespVO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 9 | 9 | import org.mapstruct.Mapper; |
| 10 | 10 | import org.mapstruct.factory.Mappers; |
| 11 | 11 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/file/InfFileConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.convert.file; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFileRespVO; |
| 5 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 6 | 6 | import org.mapstruct.Mapper; |
| 7 | 7 | import org.mapstruct.factory.Mappers; |
| 8 | 8 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiAccessLogConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.convert.logger; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExcelVO; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogRespVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 8 | 8 | import org.mapstruct.Mapper; |
| 9 | 9 | import org.mapstruct.factory.Mappers; |
| 10 | 10 | |
| ... | ... | @@ -20,8 +20,6 @@ public interface InfApiAccessLogConvert { |
| 20 | 20 | |
| 21 | 21 | InfApiAccessLogConvert INSTANCE = Mappers.getMapper(InfApiAccessLogConvert.class); |
| 22 | 22 | |
| 23 | - InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean); | |
| 24 | - | |
| 25 | 23 | InfApiAccessLogRespVO convert(InfApiAccessLogDO bean); |
| 26 | 24 | |
| 27 | 25 | List<InfApiAccessLogRespVO> convertList(List<InfApiAccessLogDO> list); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/convert/logger/InfApiErrorLogConvert.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.convert.logger; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; | |
| 5 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExcelVO; |
| 6 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogRespVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 8 | 7 | import org.mapstruct.Mapper; |
| 9 | 8 | import org.mapstruct.factory.Mappers; |
| 10 | 9 | |
| ... | ... | @@ -20,8 +19,6 @@ public interface InfApiErrorLogConvert { |
| 20 | 19 | |
| 21 | 20 | InfApiErrorLogConvert INSTANCE = Mappers.getMapper(InfApiErrorLogConvert.class); |
| 22 | 21 | |
| 23 | - InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean); | |
| 24 | - | |
| 25 | 22 | InfApiErrorLogRespVO convert(InfApiErrorLogDO bean); |
| 26 | 23 | |
| 27 | 24 | PageResult<InfApiErrorLogRespVO> convertPage(PageResult<InfApiErrorLogDO> page); | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/config/InfConfigDO.java deleted
| 1 | -package cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | -import cn.iocoder.yudao.adminserver.modules.infra.enums.config.InfConfigTypeEnum; | |
| 5 | -import com.baomidou.mybatisplus.annotation.TableField; | |
| 6 | -import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | -import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | -import lombok.Data; | |
| 9 | -import lombok.EqualsAndHashCode; | |
| 10 | -import lombok.ToString; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 参数配置表 | |
| 14 | - * | |
| 15 | - * @author ruoyi | |
| 16 | - */ | |
| 17 | -@TableName("inf_config") | |
| 18 | -@Data | |
| 19 | -@EqualsAndHashCode(callSuper = true) | |
| 20 | -@ToString(callSuper = true) | |
| 21 | -public class InfConfigDO extends BaseDO { | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * 参数主键 | |
| 25 | - */ | |
| 26 | - @TableId | |
| 27 | - private Long id; | |
| 28 | - /** | |
| 29 | - * 参数分组 | |
| 30 | - */ | |
| 31 | - @TableField("`group`") | |
| 32 | - private String group; | |
| 33 | - /** | |
| 34 | - * 参数名称 | |
| 35 | - */ | |
| 36 | - private String name; | |
| 37 | - /** | |
| 38 | - * 参数键名 | |
| 39 | - */ | |
| 40 | - @TableField("`key`") | |
| 41 | - private String key; | |
| 42 | - /** | |
| 43 | - * 参数键值 | |
| 44 | - */ | |
| 45 | - private String value; | |
| 46 | - /** | |
| 47 | - * 参数类型 | |
| 48 | - * | |
| 49 | - * 枚举 {@link InfConfigTypeEnum} | |
| 50 | - */ | |
| 51 | - @TableField("`type`") | |
| 52 | - private Integer type; | |
| 53 | - /** | |
| 54 | - * 是否敏感 | |
| 55 | - * | |
| 56 | - * 对于敏感配置,需要管理权限才能查看 | |
| 57 | - */ | |
| 58 | - @TableField("`sensitive`") | |
| 59 | - private Boolean sensitive; | |
| 60 | - /** | |
| 61 | - * 备注 | |
| 62 | - */ | |
| 63 | - private String remark; | |
| 64 | - | |
| 65 | -} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java deleted
| 1 | -package cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 5 | -import cn.iocoder.yudao.adminserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; | |
| 6 | -import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.user.SysUserDO; | |
| 7 | -import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | -import lombok.*; | |
| 9 | - | |
| 10 | -import java.util.Date; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * API 异常数据 | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@TableName("inf_api_error_log") | |
| 18 | -@Data | |
| 19 | -@EqualsAndHashCode(callSuper = true) | |
| 20 | -@ToString(callSuper = true) | |
| 21 | -@Builder | |
| 22 | -@NoArgsConstructor | |
| 23 | -@AllArgsConstructor | |
| 24 | -public class InfApiErrorLogDO extends BaseDO { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 编号 | |
| 28 | - */ | |
| 29 | - private Long id; | |
| 30 | - /** | |
| 31 | - * 用户编号 | |
| 32 | - */ | |
| 33 | - private Long userId; | |
| 34 | - /** | |
| 35 | - * 链路追踪编号 | |
| 36 | - * | |
| 37 | - * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。 | |
| 38 | - */ | |
| 39 | - private String traceId; | |
| 40 | - /** | |
| 41 | - * 用户类型 | |
| 42 | - * | |
| 43 | - * 枚举 {@link UserTypeEnum} | |
| 44 | - */ | |
| 45 | - private Integer userType; | |
| 46 | - /** | |
| 47 | - * 应用名 | |
| 48 | - * | |
| 49 | - * 目前读取 spring.application.name | |
| 50 | - */ | |
| 51 | - private String applicationName; | |
| 52 | - | |
| 53 | - // ========== 请求相关字段 ========== | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * 请求方法名 | |
| 57 | - */ | |
| 58 | - private String requestMethod; | |
| 59 | - /** | |
| 60 | - * 访问地址 | |
| 61 | - */ | |
| 62 | - private String requestUrl; | |
| 63 | - /** | |
| 64 | - * 请求参数 | |
| 65 | - * | |
| 66 | - * query: Query String | |
| 67 | - * body: Quest Body | |
| 68 | - */ | |
| 69 | - private String requestParams; | |
| 70 | - /** | |
| 71 | - * 用户 IP | |
| 72 | - */ | |
| 73 | - private String userIp; | |
| 74 | - /** | |
| 75 | - * 浏览器 UA | |
| 76 | - */ | |
| 77 | - private String userAgent; | |
| 78 | - | |
| 79 | - // ========== 异常相关字段 ========== | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * 异常发生时间 | |
| 83 | - */ | |
| 84 | - private Date exceptionTime; | |
| 85 | - /** | |
| 86 | - * 异常名 | |
| 87 | - * | |
| 88 | - * {@link Throwable#getClass()} 的类全名 | |
| 89 | - */ | |
| 90 | - private String exceptionName; | |
| 91 | - /** | |
| 92 | - * 异常导致的消息 | |
| 93 | - * | |
| 94 | - * {@link cn.hutool.core.exceptions.ExceptionUtil#getMessage(Throwable)} | |
| 95 | - */ | |
| 96 | - private String exceptionMessage; | |
| 97 | - /** | |
| 98 | - * 异常导致的根消息 | |
| 99 | - * | |
| 100 | - * {@link cn.hutool.core.exceptions.ExceptionUtil#getRootCauseMessage(Throwable)} | |
| 101 | - */ | |
| 102 | - private String exceptionRootCauseMessage; | |
| 103 | - /** | |
| 104 | - * 异常的栈轨迹 | |
| 105 | - * | |
| 106 | - * {@link org.apache.commons.lang3.exception.ExceptionUtils#getStackTrace(Throwable)} | |
| 107 | - */ | |
| 108 | - private String exceptionStackTrace; | |
| 109 | - /** | |
| 110 | - * 异常发生的类全名 | |
| 111 | - * | |
| 112 | - * {@link StackTraceElement#getClassName()} | |
| 113 | - */ | |
| 114 | - private String exceptionClassName; | |
| 115 | - /** | |
| 116 | - * 异常发生的类文件 | |
| 117 | - * | |
| 118 | - * {@link StackTraceElement#getFileName()} | |
| 119 | - */ | |
| 120 | - private String exceptionFileName; | |
| 121 | - /** | |
| 122 | - * 异常发生的方法名 | |
| 123 | - * | |
| 124 | - * {@link StackTraceElement#getMethodName()} | |
| 125 | - */ | |
| 126 | - private String exceptionMethodName; | |
| 127 | - /** | |
| 128 | - * 异常发生的方法所在行 | |
| 129 | - * | |
| 130 | - * {@link StackTraceElement#getLineNumber()} | |
| 131 | - */ | |
| 132 | - private Integer exceptionLineNumber; | |
| 133 | - | |
| 134 | - // ========== 处理相关字段 ========== | |
| 135 | - | |
| 136 | - /** | |
| 137 | - * 处理状态 | |
| 138 | - * | |
| 139 | - * 枚举 {@link InfApiErrorLogProcessStatusEnum} | |
| 140 | - */ | |
| 141 | - private Integer processStatus; | |
| 142 | - /** | |
| 143 | - * 处理时间 | |
| 144 | - */ | |
| 145 | - private Date processTime; | |
| 146 | - /** | |
| 147 | - * 处理用户编号 | |
| 148 | - * | |
| 149 | - * 关联 {@link SysUserDO#getId()} | |
| 150 | - */ | |
| 151 | - private Long processUserId; | |
| 152 | - | |
| 153 | -} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigMapper.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExportReqVO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigPageReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 9 | 9 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 10 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 11 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/file/InfFileMapper.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 8 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | |
| 10 | 10 | @Mapper | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; | |
| 4 | +import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 3 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 8 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | -import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; | |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; | |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 10 | |
| 11 | 11 | import java.util.List; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 10 | |
| 11 | 11 | import java.util.List; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigService.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.config; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExportReqVO; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigPageReqVO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 9 | 9 | |
| 10 | 10 | import javax.validation.Valid; |
| 11 | 11 | import java.util.List; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/impl/InfConfigServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.config.impl; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | 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 |
| 8 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; |
| 9 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.convert.config.InfConfigConvert; |
| 10 | 11 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigMapper; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 12 | 12 | import cn.iocoder.yudao.adminserver.modules.infra.enums.config.InfConfigTypeEnum; |
| 13 | 13 | import cn.iocoder.yudao.adminserver.modules.infra.mq.producer.config.InfConfigProducer; |
| 14 | 14 | import cn.iocoder.yudao.adminserver.modules.infra.service.config.InfConfigService; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/InfFileService.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.file; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; |
| 5 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * 文件 Service 接口 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/file/impl/InfFileServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.file.impl; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.FileTypeUtil; |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.framework.file.config.FileProperties; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 8 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file.InfFileMapper; |
| 9 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.service.file.InfFileService; |
| 10 | 10 | import org.springframework.stereotype.Service; | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiAccessLogService.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.logger; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; | |
| 5 | 3 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; |
| 6 | 4 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | 7 | |
| 9 | 8 | import java.util.List; |
| 10 | 9 | |
| ... | ... | @@ -13,7 +12,7 @@ import java.util.List; |
| 13 | 12 | * |
| 14 | 13 | * @author 芋道源码 |
| 15 | 14 | */ |
| 16 | -public interface InfApiAccessLogService extends ApiAccessLogFrameworkService { | |
| 15 | +public interface InfApiAccessLogService { | |
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * 获得 API 访问日志分页 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/InfApiErrorLogService.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.logger; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; | |
| 5 | 3 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; |
| 6 | 4 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | 7 | |
| 9 | 8 | import java.util.List; |
| 10 | 9 | |
| ... | ... | @@ -13,7 +12,7 @@ import java.util.List; |
| 13 | 12 | * |
| 14 | 13 | * @author 芋道源码 |
| 15 | 14 | */ |
| 16 | -public interface InfApiErrorLogService extends ApiErrorLogFrameworkService { | |
| 15 | +public interface InfApiErrorLogService { | |
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * 获得 API 错误日志分页 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; | |
| 5 | 3 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; |
| 6 | 4 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiAccessLogConvert; | |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 9 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper; |
| 10 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiAccessLogService; |
| 11 | -import org.springframework.scheduling.annotation.Async; | |
| 12 | -import org.springframework.scheduling.annotation.AsyncResult; | |
| 7 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 8 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 13 | 9 | import org.springframework.stereotype.Service; |
| 14 | 10 | import org.springframework.validation.annotation.Validated; |
| 15 | 11 | |
| 16 | 12 | import javax.annotation.Resource; |
| 17 | 13 | import java.util.List; |
| 18 | -import java.util.concurrent.Future; | |
| 19 | 14 | |
| 20 | 15 | /** |
| 21 | 16 | * API 访问日志 Service 实现类 |
| ... | ... | @@ -30,14 +25,6 @@ public class InfApiAccessLogServiceImpl implements InfApiAccessLogService { |
| 30 | 25 | private InfApiAccessLogMapper apiAccessLogMapper; |
| 31 | 26 | |
| 32 | 27 | @Override |
| 33 | - @Async | |
| 34 | - public Future<Boolean> createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { | |
| 35 | - InfApiAccessLogDO apiAccessLog = InfApiAccessLogConvert.INSTANCE.convert(createDTO); | |
| 36 | - int insert = apiAccessLogMapper.insert(apiAccessLog); | |
| 37 | - return new AsyncResult<>(insert > 1); | |
| 38 | - } | |
| 39 | - | |
| 40 | - @Override | |
| 41 | 28 | public PageResult<InfApiAccessLogDO> getApiAccessLogPage(InfApiAccessLogPageReqVO pageReqVO) { |
| 42 | 29 | return apiAccessLogMapper.selectPage(pageReqVO); |
| 43 | 30 | } | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; | |
| 5 | 3 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; |
| 6 | 4 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; |
| 7 | -import cn.iocoder.yudao.adminserver.modules.infra.convert.logger.InfApiErrorLogConvert; | |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 9 | 5 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper; |
| 10 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; |
| 11 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.service.logger.InfApiErrorLogService; |
| 12 | -import org.springframework.scheduling.annotation.Async; | |
| 13 | -import org.springframework.scheduling.annotation.AsyncResult; | |
| 8 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 9 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 14 | 10 | import org.springframework.stereotype.Service; |
| 15 | 11 | import org.springframework.validation.annotation.Validated; |
| 16 | 12 | |
| 17 | 13 | import javax.annotation.Resource; |
| 18 | 14 | import java.util.Date; |
| 19 | 15 | import java.util.List; |
| 20 | -import java.util.concurrent.Future; | |
| 21 | 16 | |
| 22 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 23 | 17 | import static cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants.API_ERROR_LOG_NOT_FOUND; |
| 24 | 18 | import static cn.iocoder.yudao.adminserver.modules.infra.enums.InfErrorCodeConstants.API_ERROR_LOG_PROCESSED; |
| 19 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 25 | 20 | |
| 26 | 21 | /** |
| 27 | 22 | * API 错误日志 Service 实现类 |
| ... | ... | @@ -36,15 +31,6 @@ public class InfApiErrorLogServiceImpl implements InfApiErrorLogService { |
| 36 | 31 | private InfApiErrorLogMapper apiErrorLogMapper; |
| 37 | 32 | |
| 38 | 33 | @Override |
| 39 | - @Async | |
| 40 | - public Future<Boolean> createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { | |
| 41 | - InfApiErrorLogDO apiErrorLog = InfApiErrorLogConvert.INSTANCE.convert(createDTO); | |
| 42 | - apiErrorLog.setProcessStatus(InfApiErrorLogProcessStatusEnum.INIT.getStatus()); | |
| 43 | - int insert = apiErrorLogMapper.insert(apiErrorLog); | |
| 44 | - return new AsyncResult<>(insert == 1); | |
| 45 | - } | |
| 46 | - | |
| 47 | - @Override | |
| 48 | 34 | public PageResult<InfApiErrorLogDO> getApiErrorLogPage(InfApiErrorLogPageReqVO pageReqVO) { |
| 49 | 35 | return apiErrorLogMapper.selectPage(pageReqVO); |
| 50 | 36 | } | ... | ... |
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; |
| 34 | 34 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 35 | 35 | import static cn.iocoder.yudao.adminserver.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY; |
| 36 | 36 | |
| 37 | -/** | |
| 38 | - * @author niudehua | |
| 39 | - */ | |
| 40 | 37 | @Api(tags = "用户个人中心") |
| 41 | 38 | @RestController |
| 42 | 39 | @RequestMapping("/system/user/profile") | ... | ... |
yudao-admin-server/src/main/resources/application-dev.yaml
| ... | ... | @@ -99,7 +99,7 @@ apollo: |
| 99 | 99 | eagerLoad: |
| 100 | 100 | enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 |
| 101 | 101 | jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 |
| 102 | - dao: cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigDAOImpl | |
| 102 | + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl | |
| 103 | 103 | url: ${spring.datasource.dynamic.datasource.master.url} |
| 104 | 104 | username: ${spring.datasource.dynamic.datasource.master.username} |
| 105 | 105 | password: ${spring.datasource.dynamic.datasource.master.password} | ... | ... |
yudao-admin-server/src/main/resources/application-local.yaml
| ... | ... | @@ -99,7 +99,7 @@ apollo: |
| 99 | 99 | eagerLoad: |
| 100 | 100 | enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 |
| 101 | 101 | jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 |
| 102 | - dao: cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigDAOImpl | |
| 102 | + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl | |
| 103 | 103 | url: ${spring.datasource.dynamic.datasource.master.url} |
| 104 | 104 | username: ${spring.datasource.dynamic.datasource.master.username} |
| 105 | 105 | password: ${spring.datasource.dynamic.datasource.master.password} | ... | ... |
yudao-admin-server/src/test/java/cn/iocoder/yudao/adminserver/modules/infra/service/config/InfConfigServiceTest.java
| 1 | 1 | package cn.iocoder.yudao.adminserver.modules.infra.service.config; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigCreateReqVO; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigExportReqVO; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigPageReqVO; |
| 8 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.controller.config.vo.InfConfigUpdateReqVO; |
| 9 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.config.InfConfigDO; | |
| 10 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config.InfConfigMapper; |
| 11 | 11 | import cn.iocoder.yudao.adminserver.modules.infra.enums.config.InfConfigTypeEnum; |
| 12 | 12 | import cn.iocoder.yudao.adminserver.modules.infra.mq.producer.config.InfConfigProducer; | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.io.resource.ResourceUtil; |
| 4 | 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 7 | import cn.iocoder.yudao.adminserver.modules.infra.framework.file.config.FileProperties; |
| 7 | 8 | import cn.iocoder.yudao.adminserver.modules.infra.controller.file.vo.InfFilePageReqVO; |
| 8 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 9 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.file.InfFileMapper; |
| 10 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.service.file.impl.InfFileServiceImpl; |
| 11 | 11 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.RandomUtil; |
| 4 | 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 9 | import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; |
| 9 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogExportReqVO; |
| 10 | 11 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apiaccesslog.InfApiAccessLogPageReqVO; |
| 11 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 12 | 12 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper; |
| 13 | 13 | import cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl.InfApiAccessLogServiceImpl; |
| 14 | 14 | import cn.iocoder.yudao.framework.test.core.util.RandomUtils; |
| ... | ... | @@ -39,26 +39,6 @@ public class InfApiAccessLogServiceImplTest extends BaseDbUnitTest { |
| 39 | 39 | private InfApiAccessLogMapper infApiAccessLogMapper; |
| 40 | 40 | |
| 41 | 41 | @Test |
| 42 | - public void testCreateApiAccessLogAsync() throws Exception { | |
| 43 | - ApiAccessLogCreateDTO createDTO = RandomUtils.randomPojo( | |
| 44 | - ApiAccessLogCreateDTO.class, | |
| 45 | - dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()) | |
| 46 | - ); | |
| 47 | - | |
| 48 | - // 执行service方法 | |
| 49 | - Future<Boolean> future = infApiAccessLogServiceImpl.createApiAccessLogAsync(createDTO); | |
| 50 | - | |
| 51 | - // 等异步执行完 | |
| 52 | - future.get(); | |
| 53 | - | |
| 54 | - InfApiAccessLogDO infApiAccessLogDO = infApiAccessLogMapper.selectOne(null); | |
| 55 | - // 断言 | |
| 56 | - assertNotNull(infApiAccessLogDO); | |
| 57 | - // 断言,忽略基本字段 | |
| 58 | - assertPojoEquals(createDTO, infApiAccessLogDO); | |
| 59 | - } | |
| 60 | - | |
| 61 | - @Test | |
| 62 | 42 | public void testGetApiAccessLogPage() { |
| 63 | 43 | // 构造测试数据 |
| 64 | 44 | long userId = 2233L; | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.RandomUtil; |
| 4 | 4 | import cn.iocoder.yudao.adminserver.BaseDbUnitTest; |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 8 | import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; |
| 8 | 9 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogExportReqVO; |
| 9 | 10 | import cn.iocoder.yudao.adminserver.modules.infra.controller.logger.vo.apierrorlog.InfApiErrorLogPageReqVO; |
| 10 | -import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 11 | 11 | import cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper; |
| 12 | 12 | import cn.iocoder.yudao.adminserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; |
| 13 | 13 | import cn.iocoder.yudao.adminserver.modules.infra.service.logger.impl.InfApiErrorLogServiceImpl; |
| ... | ... | @@ -41,28 +41,6 @@ public class InfApiErrorLogServiceImplTest extends BaseDbUnitTest { |
| 41 | 41 | @Resource |
| 42 | 42 | private InfApiErrorLogMapper infApiErrorLogMapper; |
| 43 | 43 | |
| 44 | - | |
| 45 | - @Test | |
| 46 | - public void testCreateApiErrorLogAsync() throws Exception { | |
| 47 | - ApiErrorLogCreateDTO createDTO = RandomUtils.randomPojo( | |
| 48 | - ApiErrorLogCreateDTO.class, | |
| 49 | - dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()) | |
| 50 | - ); | |
| 51 | - | |
| 52 | - // 执行service方法 | |
| 53 | - Future<Boolean> future = infApiErrorLogServiceImpl.createApiErrorLogAsync(createDTO); | |
| 54 | - | |
| 55 | - // 等异步执行完 | |
| 56 | - future.get(); | |
| 57 | - | |
| 58 | - InfApiErrorLogDO infApiErrorLogDO = infApiErrorLogMapper.selectOne(null); | |
| 59 | - // 断言 | |
| 60 | - assertNotNull(infApiErrorLogDO); | |
| 61 | - // 断言,忽略基本字段 | |
| 62 | - assertPojoEquals(createDTO, infApiErrorLogDO); | |
| 63 | - } | |
| 64 | - | |
| 65 | - | |
| 66 | 44 | @Test |
| 67 | 45 | public void testGetApiErrorLogPage() { |
| 68 | 46 | // 构造测试数据 |
| ... | ... | @@ -204,4 +182,5 @@ public class InfApiErrorLogServiceImplTest extends BaseDbUnitTest { |
| 204 | 182 | // 验证 progressUserId 是否修改成功 |
| 205 | 183 | assertEquals(processUserId, secondSelect.getProcessUserId()); |
| 206 | 184 | } |
| 185 | + | |
| 207 | 186 | } | ... | ... |
yudao-core-service/pom.xml
| ... | ... | @@ -61,6 +61,12 @@ |
| 61 | 61 | <artifactId>yudao-spring-boot-starter-redis</artifactId> |
| 62 | 62 | </dependency> |
| 63 | 63 | |
| 64 | + <!-- Config 配置中心相关 --> | |
| 65 | + <dependency> | |
| 66 | + <groupId>cn.iocoder.boot</groupId> | |
| 67 | + <artifactId>yudao-spring-boot-starter-config</artifactId> | |
| 68 | + </dependency> | |
| 69 | + | |
| 64 | 70 | <!-- Test 测试相关 --> |
| 65 | 71 | <dependency> |
| 66 | 72 | <groupId>cn.iocoder.boot</groupId> | ... | ... |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiAccessLogCoreConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.convert.logger; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 5 | +import org.mapstruct.Mapper; | |
| 6 | +import org.mapstruct.factory.Mappers; | |
| 7 | + | |
| 8 | +@Mapper | |
| 9 | +public interface InfApiAccessLogCoreConvert { | |
| 10 | + | |
| 11 | + InfApiAccessLogCoreConvert INSTANCE = Mappers.getMapper(InfApiAccessLogCoreConvert.class); | |
| 12 | + | |
| 13 | + InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean); | |
| 14 | + | |
| 15 | +} | ... | ... |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/logger/InfApiErrorLogCoreConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.convert.logger; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | +import org.mapstruct.Mapper; | |
| 6 | +import org.mapstruct.factory.Mappers; | |
| 7 | + | |
| 8 | +@Mapper | |
| 9 | +public interface InfApiErrorLogCoreConvert { | |
| 10 | + | |
| 11 | + InfApiErrorLogCoreConvert INSTANCE = Mappers.getMapper(InfApiErrorLogCoreConvert.class); | |
| 12 | + | |
| 13 | + InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean); | |
| 14 | + | |
| 15 | +} | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/package-info.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/package-info.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/config/InfConfigDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/config/InfConfigDO.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/file/InfFileDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/file/InfFileDO.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/dataobject/logger/InfApiErrorLogDO.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | -import cn.iocoder.yudao.userserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; | |
| 6 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 7 | 7 | import lombok.*; |
| 8 | 8 | ... | ... |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/config/InfConfigCoreDAOImpl.java
| 1 | -package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.config; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO; |
| 4 | 4 | import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO; |
| ... | ... | @@ -12,15 +12,15 @@ import java.util.Date; |
| 12 | 12 | import java.util.List; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * ConfigFrameworkDAO 实现类 | |
| 15 | + * ConfigFrameworkDAO Core 实现类 | |
| 16 | 16 | * |
| 17 | 17 | * @author 芋道源码 |
| 18 | 18 | */ |
| 19 | -public class InfConfigDAOImpl implements ConfigFrameworkDAO { | |
| 19 | +public class InfConfigCoreDAOImpl implements ConfigFrameworkDAO { | |
| 20 | 20 | |
| 21 | 21 | private final JdbcTemplate jdbcTemplate; |
| 22 | 22 | |
| 23 | - public InfConfigDAOImpl(String jdbcUrl, String username, String password) { | |
| 23 | + public InfConfigCoreDAOImpl(String jdbcUrl, String username, String password) { | |
| 24 | 24 | DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password); |
| 25 | 25 | this.jdbcTemplate = new JdbcTemplate(dataSource); |
| 26 | 26 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/file/InfFileMapper.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/file/InfFileCoreMapper.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.file; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.file; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file.InfFileDO; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.file.InfFileDO; | |
| 5 | 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 6 | |
| 7 | 7 | @Mapper |
| 8 | -public interface InfFileMapper extends BaseMapperX<InfFileDO> { | |
| 8 | +public interface InfFileCoreMapper extends BaseMapperX<InfFileDO> { | |
| 9 | 9 | |
| 10 | 10 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiAccessLogMapper.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiAccessLogCoreMapper.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 5 | 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | 6 | |
| 7 | -import java.util.List; | |
| 8 | - | |
| 9 | 7 | /** |
| 10 | 8 | * API 访问日志 Mapper |
| 11 | 9 | * |
| 12 | 10 | * @author 芋道源码 |
| 13 | 11 | */ |
| 14 | 12 | @Mapper |
| 15 | -public interface InfApiAccessLogMapper extends BaseMapperX<InfApiAccessLogDO> { | |
| 13 | +public interface InfApiAccessLogCoreMapper extends BaseMapperX<InfApiAccessLogDO> { | |
| 16 | 14 | } | ... | ... |
yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/dal/mysql/logger/InfApiErrorLogCoreMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | +import org.apache.ibatis.annotations.Mapper; | |
| 6 | + | |
| 7 | +@Mapper | |
| 8 | +public interface InfApiErrorLogCoreMapper extends BaseMapperX<InfApiErrorLogDO> { | |
| 9 | +} | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/logger/InfApiErrorLogProcessStatusEnum.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/enums/package-info.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/enums/package-info.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiAccessLogService.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreService.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.service.logger; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkService; |
| 4 | 4 | |
| ... | ... | @@ -7,6 +7,6 @@ import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServi |
| 7 | 7 | * |
| 8 | 8 | * @author 芋道源码 |
| 9 | 9 | */ |
| 10 | -public interface InfApiAccessLogService extends ApiAccessLogFrameworkService { | |
| 10 | +public interface InfApiAccessLogCoreService extends ApiAccessLogFrameworkService { | |
| 11 | 11 | |
| 12 | 12 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/InfApiErrorLogService.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreService.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.service.logger; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; |
| 4 | 4 | |
| ... | ... | @@ -7,6 +7,6 @@ import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServic |
| 7 | 7 | * |
| 8 | 8 | * @author 芋道源码 |
| 9 | 9 | */ |
| 10 | -public interface InfApiErrorLogService extends ApiErrorLogFrameworkService { | |
| 10 | +public interface InfApiErrorLogCoreService extends ApiErrorLogFrameworkService { | |
| 11 | 11 | |
| 12 | 12 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiAccessLogServiceImpl.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiAccessLogCoreServiceImpl.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl; | |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.convert.logger.InfApiAccessLogCoreConvert; | |
| 3 | 4 | import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.convert.logger.InfApiAccessLogConvert; | |
| 5 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 6 | -import cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger.InfApiAccessLogMapper; | |
| 7 | -import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiAccessLogService; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 6 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper; | |
| 7 | +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.InfApiAccessLogCoreService; | |
| 8 | 8 | import lombok.extern.slf4j.Slf4j; |
| 9 | +import org.springframework.scheduling.annotation.Async; | |
| 9 | 10 | import org.springframework.scheduling.annotation.AsyncResult; |
| 10 | 11 | import org.springframework.stereotype.Service; |
| 11 | 12 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -21,16 +22,16 @@ import java.util.concurrent.Future; |
| 21 | 22 | @Service |
| 22 | 23 | @Validated |
| 23 | 24 | @Slf4j |
| 24 | -public class InfApiAccessLogServiceImpl implements InfApiAccessLogService { | |
| 25 | +public class InfApiAccessLogCoreServiceImpl implements InfApiAccessLogCoreService { | |
| 25 | 26 | |
| 26 | 27 | @Resource |
| 27 | - private InfApiAccessLogMapper apiAccessLogMapper; | |
| 28 | + private InfApiAccessLogCoreMapper apiAccessLogMapper; | |
| 28 | 29 | |
| 29 | 30 | @Override |
| 30 | - public Future<Boolean> createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { | |
| 31 | - InfApiAccessLogDO apiAccessLog = InfApiAccessLogConvert.INSTANCE.convert(createDTO); | |
| 32 | - int insert = apiAccessLogMapper.insert(apiAccessLog); | |
| 33 | - return new AsyncResult<>(insert > 1); | |
| 31 | + @Async | |
| 32 | + public void createApiAccessLogAsync(ApiAccessLogCreateDTO createDTO) { | |
| 33 | + InfApiAccessLogDO apiAccessLog = InfApiAccessLogCoreConvert.INSTANCE.convert(createDTO); | |
| 34 | + apiAccessLogMapper.insert(apiAccessLog); | |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/logger/impl/InfApiErrorLogServiceImpl.java renamed to yudao-core-service/src/main/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/impl/InfApiErrorLogCoreServiceImpl.java
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.service.logger.impl; | |
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl; | |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.coreservice.modules.infra.convert.logger.InfApiErrorLogCoreConvert; | |
| 4 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper; | |
| 6 | +import cn.iocoder.yudao.coreservice.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; | |
| 7 | +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.InfApiErrorLogCoreService; | |
| 3 | 8 | import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.convert.logger.InfApiErrorLogConvert; | |
| 5 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 6 | -import cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger.InfApiErrorLogMapper; | |
| 7 | -import cn.iocoder.yudao.userserver.modules.infra.enums.logger.InfApiErrorLogProcessStatusEnum; | |
| 8 | -import cn.iocoder.yudao.userserver.modules.infra.service.logger.InfApiErrorLogService; | |
| 9 | 9 | import lombok.extern.slf4j.Slf4j; |
| 10 | +import org.springframework.scheduling.annotation.Async; | |
| 10 | 11 | import org.springframework.scheduling.annotation.AsyncResult; |
| 11 | 12 | import org.springframework.stereotype.Service; |
| 12 | 13 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -22,17 +23,17 @@ import java.util.concurrent.Future; |
| 22 | 23 | @Service |
| 23 | 24 | @Validated |
| 24 | 25 | @Slf4j |
| 25 | -public class InfApiErrorLogServiceImpl implements InfApiErrorLogService { | |
| 26 | +public class InfApiErrorLogCoreServiceImpl implements InfApiErrorLogCoreService { | |
| 26 | 27 | |
| 27 | 28 | @Resource |
| 28 | - private InfApiErrorLogMapper apiErrorLogMapper; | |
| 29 | + private InfApiErrorLogCoreMapper apiErrorLogMapper; | |
| 29 | 30 | |
| 30 | 31 | @Override |
| 31 | - public Future<Boolean> createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { | |
| 32 | - InfApiErrorLogDO apiErrorLog = InfApiErrorLogConvert.INSTANCE.convert(createDTO); | |
| 32 | + @Async | |
| 33 | + public void createApiErrorLogAsync(ApiErrorLogCreateDTO createDTO) { | |
| 34 | + InfApiErrorLogDO apiErrorLog = InfApiErrorLogCoreConvert.INSTANCE.convert(createDTO); | |
| 33 | 35 | apiErrorLog.setProcessStatus(InfApiErrorLogProcessStatusEnum.INIT.getStatus()); |
| 34 | - int insert = apiErrorLogMapper.insert(apiErrorLog); | |
| 35 | - return new AsyncResult<>(insert == 1); | |
| 36 | + apiErrorLogMapper.insert(apiErrorLog); | |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | } | ... | ... |
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiAccessLogCoreServiceTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.RandomUtil; | |
| 4 | +import cn.iocoder.yudao.coreservice.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 6 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiAccessLogCoreMapper; | |
| 7 | +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiAccessLogCoreServiceImpl; | |
| 8 | +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; | |
| 9 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 10 | +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 12 | +import org.springframework.context.annotation.Import; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | +import java.util.concurrent.Future; | |
| 16 | + | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | +import static org.junit.jupiter.api.Assertions.assertNotNull; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * {@link InfApiAccessLogCoreServiceImpl} 单元测试 | |
| 22 | + */ | |
| 23 | +@Import(InfApiAccessLogCoreServiceImpl.class) | |
| 24 | +public class InfApiAccessLogCoreServiceTest extends BaseDbUnitTest { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private InfApiAccessLogCoreService apiAccessLogCoreService; | |
| 28 | + | |
| 29 | + @Resource | |
| 30 | + private InfApiAccessLogCoreMapper apiAccessLogCoreMapper; | |
| 31 | + | |
| 32 | + @Test | |
| 33 | + public void testCreateApiAccessLogAsync() { | |
| 34 | + // 准备参数 | |
| 35 | + ApiAccessLogCreateDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateDTO.class, | |
| 36 | + dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); | |
| 37 | + | |
| 38 | + // 调用 | |
| 39 | + apiAccessLogCoreService.createApiAccessLogAsync(createDTO); | |
| 40 | + // 断言 | |
| 41 | + InfApiAccessLogDO infApiAccessLogDO = apiAccessLogCoreMapper.selectOne(null); | |
| 42 | + assertNotNull(infApiAccessLogDO); | |
| 43 | + assertPojoEquals(createDTO, infApiAccessLogDO); | |
| 44 | + } | |
| 45 | + | |
| 46 | +} | ... | ... |
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/logger/InfApiErrorLogCoreServiceTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service.logger; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.RandomUtil; | |
| 4 | +import cn.iocoder.yudao.coreservice.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 6 | +import cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.logger.InfApiErrorLogCoreMapper; | |
| 7 | +import cn.iocoder.yudao.coreservice.modules.infra.service.logger.impl.InfApiErrorLogCoreServiceImpl; | |
| 8 | +import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; | |
| 9 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 10 | +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 12 | +import org.springframework.context.annotation.Import; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | +import static org.junit.jupiter.api.Assertions.assertNotNull; | |
| 18 | + | |
| 19 | +/** | |
| 20 | + * {@link InfApiErrorLogCoreServiceImpl} 单元测试 | |
| 21 | + */ | |
| 22 | +@Import(InfApiErrorLogCoreServiceImpl.class) | |
| 23 | +public class InfApiErrorLogCoreServiceTest extends BaseDbUnitTest { | |
| 24 | + | |
| 25 | + @Resource | |
| 26 | + private InfApiErrorLogCoreService apiErrorLogCoreService; | |
| 27 | + | |
| 28 | + @Resource | |
| 29 | + private InfApiErrorLogCoreMapper infApiErrorLogCoreMapper; | |
| 30 | + | |
| 31 | + @Test | |
| 32 | + public void testCreateApiErrorLogAsync() { | |
| 33 | + // 准备参数 | |
| 34 | + ApiErrorLogCreateDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateDTO.class, | |
| 35 | + dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue())); | |
| 36 | + | |
| 37 | + // 调用 | |
| 38 | + apiErrorLogCoreService.createApiErrorLogAsync(createDTO); | |
| 39 | + // 断言 | |
| 40 | + InfApiErrorLogDO infApiErrorLogDO = infApiErrorLogCoreMapper.selectOne(null); | |
| 41 | + assertNotNull(infApiErrorLogDO); | |
| 42 | + assertPojoEquals(createDTO, infApiErrorLogDO); | |
| 43 | + } | |
| 44 | + | |
| 45 | +} | ... | ... |
yudao-core-service/src/test/java/cn/iocoder/yudao/coreservice/modules/infra/service/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.coreservice.modules.infra.service; | ... | ... |
yudao-core-service/src/test/resources/sql/clean.sql
yudao-core-service/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -33,3 +33,58 @@ CREATE TABLE IF NOT EXISTS "sys_dict_data" ( |
| 33 | 33 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 34 | 34 | PRIMARY KEY ("id") |
| 35 | 35 | ) COMMENT '字典数据表'; |
| 36 | + | |
| 37 | +CREATE TABLE IF NOT EXISTS "inf_api_access_log" ( | |
| 38 | + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, | |
| 39 | + "trace_id" varchar(64) not null default '', | |
| 40 | + "user_id" bigint not null default '0', | |
| 41 | + "user_type" tinyint not null default '0', | |
| 42 | + "application_name" varchar(50) not null, | |
| 43 | + "request_method" varchar(16) not null default '', | |
| 44 | + "request_url" varchar(255) not null default '', | |
| 45 | + "request_params" varchar(8000) not null default '', | |
| 46 | + "user_ip" varchar(50) not null, | |
| 47 | + "user_agent" varchar(512) not null, | |
| 48 | + "begin_time" timestamp not null, | |
| 49 | + "end_time" timestamp not null, | |
| 50 | + "duration" integer not null, | |
| 51 | + "result_code" integer not null default '0', | |
| 52 | + "result_msg" varchar(512) default '', | |
| 53 | + "creator" varchar(64) default '', | |
| 54 | + "create_time" timestamp not null default current_timestamp, | |
| 55 | + "updater" varchar(64) default '', | |
| 56 | + "update_time" timestamp not null default current_timestamp, | |
| 57 | + "deleted" bit not null default false, | |
| 58 | + primary key ("id") | |
| 59 | + ) COMMENT 'API 访问日志表'; | |
| 60 | + | |
| 61 | +CREATE TABLE IF NOT EXISTS "inf_api_error_log" ( | |
| 62 | + "id" integer not null GENERATED BY DEFAULT AS IDENTITY, | |
| 63 | + "trace_id" varchar(64) not null, | |
| 64 | + "user_id" bigint not null default '0', | |
| 65 | + "user_type" tinyint not null default '0', | |
| 66 | + "application_name" varchar(50) not null, | |
| 67 | + "request_method" varchar(16) not null, | |
| 68 | + "request_url" varchar(255) not null, | |
| 69 | + "request_params" varchar(8000) not null, | |
| 70 | + "user_ip" varchar(50) not null, | |
| 71 | + "user_agent" varchar(512) not null, | |
| 72 | + "exception_time" timestamp not null, | |
| 73 | + "exception_name" varchar(128) not null default '', | |
| 74 | + "exception_message" clob not null, | |
| 75 | + "exception_root_cause_message" clob not null, | |
| 76 | + "exception_stack_trace" clob not null, | |
| 77 | + "exception_class_name" varchar(512) not null, | |
| 78 | + "exception_file_name" varchar(512) not null, | |
| 79 | + "exception_method_name" varchar(512) not null, | |
| 80 | + "exception_line_number" integer not null, | |
| 81 | + "process_status" tinyint not null, | |
| 82 | + "process_time" timestamp default null, | |
| 83 | + "process_user_id" bigint default '0', | |
| 84 | + "creator" varchar(64) default '', | |
| 85 | + "create_time" timestamp not null default current_timestamp, | |
| 86 | + "updater" varchar(64) default '', | |
| 87 | + "update_time" timestamp not null default current_timestamp, | |
| 88 | + "deleted" bit not null default false, | |
| 89 | + primary key ("id") | |
| 90 | + ) COMMENT '系统异常日志'; | ... | ... |
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 { |
| 97 | 97 | // 额外设置到 request 中,用于 ApiAccessLogFilter 可以获取到用户编号; |
| 98 | 98 | // 原因是,Spring Security 的 Filter 在 ApiAccessLogFilter 后面,在它记录访问日志时,线上上下文已经没有用户编号等信息 |
| 99 | 99 | WebFrameworkUtils.setLoginUserId(request, loginUser.getId()); |
| 100 | + WebFrameworkUtils.setLoginUserType(request, loginUser.getUserType()); | |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | } | ... | ... |
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 { |
| 81 | 81 | Map<String, String> queryString, String requestBody, Exception ex) { |
| 82 | 82 | // 处理用户信息 |
| 83 | 83 | accessLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); |
| 84 | - accessLog.setUserType(WebFrameworkUtils.getUserType(request)); | |
| 84 | + accessLog.setUserType(WebFrameworkUtils.getLoginUserType(request)); | |
| 85 | 85 | // 设置访问结果 |
| 86 | 86 | CommonResult<?> result = WebFrameworkUtils.getCommonResult(request); |
| 87 | 87 | if (result != null) { | ... | ... |
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 { |
| 16 | 16 | * 创建 API 访问日志 |
| 17 | 17 | * |
| 18 | 18 | * @param createDTO 创建信息 |
| 19 | - * @return 是否创建成功 | |
| 20 | 19 | */ |
| 21 | - Future<Boolean> createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO); | |
| 20 | + void createApiAccessLogAsync(@Valid ApiAccessLogCreateDTO createDTO); | |
| 22 | 21 | |
| 23 | 22 | } | ... | ... |
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 { |
| 16 | 16 | * 创建 API 错误日志 |
| 17 | 17 | * |
| 18 | 18 | * @param createDTO 创建信息 |
| 19 | - * @return 是否创建成功 | |
| 20 | 19 | */ |
| 21 | - Future<Boolean> createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO); | |
| 20 | + void createApiErrorLogAsync(@Valid ApiErrorLogCreateDTO createDTO); | |
| 22 | 21 | |
| 23 | 22 | } | ... | ... |
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 { |
| 245 | 245 | private void initExceptionLog(ApiErrorLogCreateDTO errorLog, HttpServletRequest request, Throwable e) { |
| 246 | 246 | // 处理用户信息 |
| 247 | 247 | errorLog.setUserId(WebFrameworkUtils.getLoginUserId(request)); |
| 248 | - errorLog.setUserType(WebFrameworkUtils.getUserType(request)); | |
| 248 | + errorLog.setUserType(WebFrameworkUtils.getLoginUserType(request)); | |
| 249 | 249 | // 设置异常字段 |
| 250 | 250 | errorLog.setExceptionName(e.getClass().getName()); |
| 251 | 251 | errorLog.setExceptionMessage(ExceptionUtil.getMessage(e)); | ... | ... |
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; |
| 17 | 17 | public class WebFrameworkUtils { |
| 18 | 18 | |
| 19 | 19 | private static final String REQUEST_ATTRIBUTE_LOGIN_USER_ID = "login_user_id"; |
| 20 | + private static final String REQUEST_ATTRIBUTE_LOGIN_USER_TYPE = "login_user_type"; | |
| 20 | 21 | |
| 21 | 22 | private static final String REQUEST_ATTRIBUTE_COMMON_RESULT = "common_result"; |
| 22 | 23 | |
| ... | ... | @@ -24,6 +25,10 @@ public class WebFrameworkUtils { |
| 24 | 25 | request.setAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_ID, userId); |
| 25 | 26 | } |
| 26 | 27 | |
| 28 | + public static void setLoginUserType(ServletRequest request, Integer userType) { | |
| 29 | + request.setAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_TYPE, userType); | |
| 30 | + } | |
| 31 | + | |
| 27 | 32 | /** |
| 28 | 33 | * 获得当前用户的编号,从请求中 |
| 29 | 34 | * |
| ... | ... | @@ -37,15 +42,24 @@ public class WebFrameworkUtils { |
| 37 | 42 | return (Long) request.getAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_ID); |
| 38 | 43 | } |
| 39 | 44 | |
| 45 | + /** | |
| 46 | + * 获得当前用户的类型,从请求中 | |
| 47 | + * | |
| 48 | + * @param request 请求 | |
| 49 | + * @return 用户编号 | |
| 50 | + */ | |
| 51 | + public static Integer getLoginUserType(HttpServletRequest request) { | |
| 52 | + if (request == null) { | |
| 53 | + return null; | |
| 54 | + } | |
| 55 | + return (Integer) request.getAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_TYPE); | |
| 56 | + } | |
| 57 | + | |
| 40 | 58 | public static Long getLoginUserId() { |
| 41 | 59 | HttpServletRequest request = getRequest(); |
| 42 | 60 | return getLoginUserId(request); |
| 43 | 61 | } |
| 44 | 62 | |
| 45 | - public static Integer getUserType(HttpServletRequest request) { | |
| 46 | - return UserTypeEnum.ADMIN.getValue(); // TODO 芋艿:等后续优化 | |
| 47 | - } | |
| 48 | - | |
| 49 | 63 | public static void setCommonResult(ServletRequest request, CommonResult<?> result) { |
| 50 | 64 | request.setAttribute(REQUEST_ATTRIBUTE_COMMON_RESULT, result); |
| 51 | 65 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/framework/security/SecurityConfiguration.java
| ... | ... | @@ -18,7 +18,7 @@ public class SecurityConfiguration { |
| 18 | 18 | @Bean |
| 19 | 19 | public Customizer<ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry> authorizeRequestsCustomizer() { |
| 20 | 20 | return registry -> { |
| 21 | - registry.antMatchers(api("/**")).anonymous(); // 默认 API 都是用户可访问 | |
| 21 | + registry.antMatchers(api("/**")).permitAll(); // 默认 API 都是用户可访问 | |
| 22 | 22 | }; |
| 23 | 23 | } |
| 24 | 24 | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/controller/HelloController.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.controller; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; | |
| 4 | -import lombok.extern.slf4j.Slf4j; | |
| 5 | -import org.springframework.security.access.annotation.Secured; | |
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 8 | -import org.springframework.web.bind.annotation.RestController; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * @author weir | |
| 12 | - */ | |
| 13 | -@Slf4j | |
| 14 | -@RestController | |
| 15 | -public class HelloController { | |
| 16 | - | |
| 17 | - @RequestMapping("/user/hello") | |
| 18 | - public String hello(String hello) { | |
| 19 | - return "echo + " + hello; | |
| 20 | - } | |
| 21 | - | |
| 22 | - @RequestMapping("/user/info") | |
| 23 | - @PreAuthenticated | |
| 24 | - public String xx() { | |
| 25 | - return "none"; | |
| 26 | - } | |
| 27 | - | |
| 28 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiAccessLogConvert.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.convert.logger; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiAccessLogCreateDTO; | |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiAccessLogDO; | |
| 5 | -import org.mapstruct.Mapper; | |
| 6 | -import org.mapstruct.factory.Mappers; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * API 访问日志 Convert | |
| 10 | - * | |
| 11 | - * @author 芋道源码 | |
| 12 | - */ | |
| 13 | -@Mapper | |
| 14 | -public interface InfApiAccessLogConvert { | |
| 15 | - | |
| 16 | - InfApiAccessLogConvert INSTANCE = Mappers.getMapper(InfApiAccessLogConvert.class); | |
| 17 | - | |
| 18 | - InfApiAccessLogDO convert(ApiAccessLogCreateDTO bean); | |
| 19 | - | |
| 20 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/convert/logger/InfApiErrorLogConvert.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.convert.logger; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.apilog.core.service.dto.ApiErrorLogCreateDTO; | |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | -import org.mapstruct.Mapper; | |
| 6 | -import org.mapstruct.factory.Mappers; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * API 错误日志 Convert | |
| 10 | - * | |
| 11 | - * @author 芋道源码 | |
| 12 | - */ | |
| 13 | -@Mapper | |
| 14 | -public interface InfApiErrorLogConvert { | |
| 15 | - | |
| 16 | - InfApiErrorLogConvert INSTANCE = Mappers.getMapper(InfApiErrorLogConvert.class); | |
| 17 | - | |
| 18 | - InfApiErrorLogDO convert(ApiErrorLogCreateDTO bean); | |
| 19 | - | |
| 20 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/file/InfFileDO.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.file; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | -import com.baomidou.mybatisplus.annotation.IdType; | |
| 5 | -import com.baomidou.mybatisplus.annotation.TableField; | |
| 6 | -import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | -import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | -import lombok.*; | |
| 9 | - | |
| 10 | -import java.io.InputStream; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 文件表 | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@Data | |
| 18 | -@TableName("inf_file") | |
| 19 | -@EqualsAndHashCode(callSuper = true) | |
| 20 | -@ToString(callSuper = true) | |
| 21 | -@Builder | |
| 22 | -@NoArgsConstructor | |
| 23 | -@AllArgsConstructor | |
| 24 | -public class InfFileDO extends BaseDO { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 文件路径 | |
| 28 | - */ | |
| 29 | - @TableId(type = IdType.INPUT) | |
| 30 | - private String id; | |
| 31 | - /** | |
| 32 | - * 文件类型 | |
| 33 | - * | |
| 34 | - * 通过 {@link cn.hutool.core.io.FileTypeUtil#getType(InputStream)} 获取 | |
| 35 | - */ | |
| 36 | - @TableField(value = "`type`") | |
| 37 | - private String type; | |
| 38 | - /** | |
| 39 | - * 文件内容 | |
| 40 | - */ | |
| 41 | - private byte[] content; | |
| 42 | - | |
| 43 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/dataobject/logger/InfApiAccessLogDO.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 6 | -import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | -import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | -import lombok.*; | |
| 9 | - | |
| 10 | -import java.util.Date; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * API 访问日志 | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@TableName("inf_api_access_log") | |
| 18 | -@Data | |
| 19 | -@EqualsAndHashCode(callSuper = true) | |
| 20 | -@ToString(callSuper = true) | |
| 21 | -@Builder | |
| 22 | -@NoArgsConstructor | |
| 23 | -@AllArgsConstructor | |
| 24 | -public class InfApiAccessLogDO extends BaseDO { | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 编号 | |
| 28 | - */ | |
| 29 | - @TableId | |
| 30 | - private Integer id; | |
| 31 | - /** | |
| 32 | - * 链路追踪编号 | |
| 33 | - * | |
| 34 | - * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。 | |
| 35 | - */ | |
| 36 | - private String traceId; | |
| 37 | - /** | |
| 38 | - * 用户编号 | |
| 39 | - */ | |
| 40 | - private Long userId; | |
| 41 | - /** | |
| 42 | - * 用户类型 | |
| 43 | - * | |
| 44 | - * 枚举 {@link UserTypeEnum} | |
| 45 | - */ | |
| 46 | - private Integer userType; | |
| 47 | - /** | |
| 48 | - * 应用名 | |
| 49 | - * | |
| 50 | - * 目前读取 `spring.application.name` 配置项 | |
| 51 | - */ | |
| 52 | - private String applicationName; | |
| 53 | - | |
| 54 | - // ========== 请求相关字段 ========== | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * 请求方法名 | |
| 58 | - */ | |
| 59 | - private String requestMethod; | |
| 60 | - /** | |
| 61 | - * 访问地址 | |
| 62 | - */ | |
| 63 | - private String requestUrl; | |
| 64 | - /** | |
| 65 | - * 请求参数 | |
| 66 | - * | |
| 67 | - * query: Query String | |
| 68 | - * body: Quest Body | |
| 69 | - */ | |
| 70 | - private String requestParams; | |
| 71 | - /** | |
| 72 | - * 用户 IP | |
| 73 | - */ | |
| 74 | - private String userIp; | |
| 75 | - /** | |
| 76 | - * 浏览器 UA | |
| 77 | - */ | |
| 78 | - private String userAgent; | |
| 79 | - | |
| 80 | - // ========== 执行相关字段 ========== | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * 开始请求时间 | |
| 84 | - */ | |
| 85 | - private Date beginTime; | |
| 86 | - /** | |
| 87 | - * 结束请求时间 | |
| 88 | - */ | |
| 89 | - private Date endTime; | |
| 90 | - /** | |
| 91 | - * 执行时长,单位:毫秒 | |
| 92 | - */ | |
| 93 | - private Integer duration; | |
| 94 | - /** | |
| 95 | - * 结果码 | |
| 96 | - * | |
| 97 | - * 目前使用的 {@link CommonResult#getCode()} 属性 | |
| 98 | - */ | |
| 99 | - private Integer resultCode; | |
| 100 | - /** | |
| 101 | - * 结果提示 | |
| 102 | - * | |
| 103 | - * 目前使用的 {@link CommonResult#getMsg()} 属性 | |
| 104 | - */ | |
| 105 | - private String resultMsg; | |
| 106 | - | |
| 107 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/config/InfConfigDAOImpl.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.apollo.internals.ConfigFrameworkDAO; | |
| 4 | -import cn.iocoder.yudao.framework.apollo.internals.dto.ConfigRespDTO; | |
| 5 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 6 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 7 | -import org.springframework.jdbc.datasource.DriverManagerDataSource; | |
| 8 | - | |
| 9 | -import javax.sql.DataSource; | |
| 10 | -import java.sql.ResultSet; | |
| 11 | -import java.util.Date; | |
| 12 | -import java.util.List; | |
| 13 | - | |
| 14 | -/** | |
| 15 | - * ConfigFrameworkDAO 实现类 | |
| 16 | - * | |
| 17 | - * @author 芋道源码 | |
| 18 | - */ | |
| 19 | -public class InfConfigDAOImpl implements ConfigFrameworkDAO { | |
| 20 | - | |
| 21 | - private final JdbcTemplate jdbcTemplate; | |
| 22 | - | |
| 23 | - public InfConfigDAOImpl(String jdbcUrl, String username, String password) { | |
| 24 | - DataSource dataSource = new DriverManagerDataSource(jdbcUrl, username, password); | |
| 25 | - this.jdbcTemplate = new JdbcTemplate(dataSource); | |
| 26 | - } | |
| 27 | - | |
| 28 | - @Override | |
| 29 | - public boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) { | |
| 30 | - return jdbcTemplate.query("SELECT id FROM inf_config WHERE update_time > ? LIMIT 1", | |
| 31 | - ResultSet::next, maxUpdateTime); | |
| 32 | - } | |
| 33 | - | |
| 34 | - @Override | |
| 35 | - public List<ConfigRespDTO> selectList() { | |
| 36 | - return jdbcTemplate.query("SELECT `key`, `value`, update_time, deleted FROM inf_config", new BeanPropertyRowMapper<>(ConfigRespDTO.class)); | |
| 37 | - } | |
| 38 | - | |
| 39 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/dal/mysql/logger/InfApiErrorLogMapper.java deleted
| 1 | -package cn.iocoder.yudao.userserver.modules.infra.dal.mysql.logger; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | -import cn.iocoder.yudao.userserver.modules.infra.dal.dataobject.logger.InfApiErrorLogDO; | |
| 5 | -import org.apache.ibatis.annotations.Mapper; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * API 错误日志 Mapper | |
| 9 | - * | |
| 10 | - * @author 芋道源码 | |
| 11 | - */ | |
| 12 | -@Mapper | |
| 13 | -public interface InfApiErrorLogMapper extends BaseMapperX<InfApiErrorLogDO> { | |
| 14 | -} |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/package-info.java deleted
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/infra/service/package-info.java deleted
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.member.controller; | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.http
0 → 100644
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/controller/user/SysUserProfileController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.userserver.modules.member.controller.user; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; | |
| 5 | +import io.swagger.annotations.Api; | |
| 6 | +import io.swagger.annotations.ApiOperation; | |
| 7 | +import lombok.extern.slf4j.Slf4j; | |
| 8 | +import org.springframework.validation.annotation.Validated; | |
| 9 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +@Api(tags = "用户个人中心") | |
| 14 | +@RestController | |
| 15 | +@RequestMapping("/system/user/profile") | |
| 16 | +@Validated | |
| 17 | +@Slf4j | |
| 18 | +public class SysUserProfileController { | |
| 19 | + | |
| 20 | + @GetMapping("/get") | |
| 21 | + @ApiOperation("获得登录用户信息") | |
| 22 | + @PreAuthenticated | |
| 23 | + public CommonResult<Boolean> profile() { | |
| 24 | + return null; | |
| 25 | + } | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/member/service/user/MbrUserService.java
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 { |
| 33 | 33 | userMapper.updateById(new MbrUserDO().setId(id).setLoginIp(loginIp).setLoginDate(new Date())); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + @Override | |
| 37 | + public MbrUserDO getUser(Long id) { | |
| 38 | + return userMapper.selectById(id); | |
| 39 | + } | |
| 40 | + | |
| 36 | 41 | } | ... | ... |
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/MbrAuthConvert.java renamed to yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/convert/auth/SysAuthConvert.java
| ... | ... | @@ -8,9 +8,9 @@ import org.mapstruct.Mapping; |
| 8 | 8 | import org.mapstruct.factory.Mappers; |
| 9 | 9 | |
| 10 | 10 | @Mapper |
| 11 | -public interface MbrAuthConvert { | |
| 11 | +public interface SysAuthConvert { | |
| 12 | 12 | |
| 13 | - MbrAuthConvert INSTANCE = Mappers.getMapper(MbrAuthConvert.class); | |
| 13 | + SysAuthConvert INSTANCE = Mappers.getMapper(SysAuthConvert.class); | |
| 14 | 14 | |
| 15 | 15 | @Mapping(source = "mobile", target = "username") |
| 16 | 16 | LoginUser convert0(MbrUserDO bean); | ... | ... |
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; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.security.core.LoginUser; |
| 9 | 9 | import cn.iocoder.yudao.userserver.modules.system.controller.auth.vo.SysAuthLoginReqVO; |
| 10 | -import cn.iocoder.yudao.userserver.modules.system.convert.auth.MbrAuthConvert; | |
| 10 | +import cn.iocoder.yudao.userserver.modules.system.convert.auth.SysAuthConvert; | |
| 11 | 11 | import cn.iocoder.yudao.userserver.modules.member.dal.dataobject.user.MbrUserDO; |
| 12 | 12 | import cn.iocoder.yudao.userserver.modules.system.service.auth.SysAuthService; |
| 13 | 13 | import cn.iocoder.yudao.userserver.modules.member.service.user.MbrUserService; |
| ... | ... | @@ -60,7 +60,7 @@ public class SysAuthServiceImpl implements SysAuthService { |
| 60 | 60 | throw new UsernameNotFoundException(mobile); |
| 61 | 61 | } |
| 62 | 62 | // 创建 LoginUser 对象 |
| 63 | - return MbrAuthConvert.INSTANCE.convert(user); | |
| 63 | + return SysAuthConvert.INSTANCE.convert(user); | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | @Override |
| ... | ... | @@ -125,7 +125,15 @@ public class SysAuthServiceImpl implements SysAuthService { |
| 125 | 125 | |
| 126 | 126 | @Override |
| 127 | 127 | public LoginUser mockLogin(Long userId) { |
| 128 | - return null; | |
| 128 | + // 获取用户编号对应的 MbrUserDO | |
| 129 | + MbrUserDO user = userService.getUser(userId); | |
| 130 | + if (user == null) { | |
| 131 | + throw new UsernameNotFoundException(String.valueOf(userId)); | |
| 132 | + } | |
| 133 | + this.createLoginLog(user.getMobile(), SysLoginLogTypeEnum.LOGIN_MOCK, SysLoginResultEnum.SUCCESS); | |
| 134 | + | |
| 135 | + // 创建 LoginUser 对象 | |
| 136 | + return SysAuthConvert.INSTANCE.convert(user); | |
| 129 | 137 | } |
| 130 | 138 | |
| 131 | 139 | @Override | ... | ... |
yudao-user-server/src/main/resources/application-dev.yaml
| ... | ... | @@ -72,7 +72,7 @@ apollo: |
| 72 | 72 | eagerLoad: |
| 73 | 73 | enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 |
| 74 | 74 | jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 |
| 75 | - dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl | |
| 75 | + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl | |
| 76 | 76 | url: ${spring.datasource.dynamic.datasource.master.url} |
| 77 | 77 | username: ${spring.datasource.dynamic.datasource.master.username} |
| 78 | 78 | password: ${spring.datasource.dynamic.datasource.master.password} | ... | ... |
yudao-user-server/src/main/resources/application-local.yaml
| ... | ... | @@ -72,7 +72,7 @@ apollo: |
| 72 | 72 | eagerLoad: |
| 73 | 73 | enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 |
| 74 | 74 | jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 |
| 75 | - dao: cn.iocoder.yudao.userserver.modules.infra.dal.mysql.config.InfConfigDAOImpl | |
| 75 | + dao: cn.iocoder.yudao.coreservice.modules.infra.dal.mysql.config.InfConfigCoreDAOImpl | |
| 76 | 76 | url: ${spring.datasource.dynamic.datasource.master.url} |
| 77 | 77 | username: ${spring.datasource.dynamic.datasource.master.username} |
| 78 | 78 | password: ${spring.datasource.dynamic.datasource.master.password} | ... | ... |