Commit ae9186f4b413174489758af024bb3c075e057a7b
1 parent
64418838
多模块重构 14:MEMBER 用户,过滤掉操作日志的记录~
Showing
10 changed files
with
32 additions
and
16 deletions
yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java
| @@ -4,6 +4,7 @@ import cn.hutool.core.exceptions.ExceptionUtil; | @@ -4,6 +4,7 @@ import cn.hutool.core.exceptions.ExceptionUtil; | ||
| 4 | import cn.hutool.core.util.ArrayUtil; | 4 | import cn.hutool.core.util.ArrayUtil; |
| 5 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | import cn.hutool.extra.servlet.ServletUtil; | 6 | import cn.hutool.extra.servlet.ServletUtil; |
| 7 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | ||
| 7 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 8 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 9 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 9 | import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; | 10 | import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; |
| @@ -81,6 +82,12 @@ public class OperateLogAspect { | @@ -81,6 +82,12 @@ public class OperateLogAspect { | ||
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | private Object around0(ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation) throws Throwable { | 84 | private Object around0(ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation) throws Throwable { |
| 85 | + // 目前,只有管理员,才记录操作日志!所以非管理员,直接调用,不进行记录 | ||
| 86 | + Integer userType = WebFrameworkUtils.getLoginUserType(); | ||
| 87 | + if (!Objects.equals(userType, UserTypeEnum.ADMIN.getValue())) { | ||
| 88 | + return joinPoint.proceed(); | ||
| 89 | + } | ||
| 90 | + | ||
| 84 | // 记录开始时间 | 91 | // 记录开始时间 |
| 85 | Date startTime = new Date(); | 92 | Date startTime = new Date(); |
| 86 | try { | 93 | try { |
yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java renamed to yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
| @@ -10,8 +10,8 @@ import org.springframework.security.config.annotation.web.configurers.Expression | @@ -10,8 +10,8 @@ import org.springframework.security.config.annotation.web.configurers.Expression | ||
| 10 | /** | 10 | /** |
| 11 | * Infra 模块的 Security 配置 | 11 | * Infra 模块的 Security 配置 |
| 12 | */ | 12 | */ |
| 13 | -@Configuration | ||
| 14 | -public class InfraSecurityConfiguration { | 13 | +@Configuration("infraSecurityConfiguration") |
| 14 | +public class SecurityConfiguration { | ||
| 15 | 15 | ||
| 16 | @Value("${spring.boot.admin.context-path:''}") | 16 | @Value("${spring.boot.admin.context-path:''}") |
| 17 | private String adminSeverContextPath; | 17 | private String adminSeverContextPath; |
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.http
| 1 | ### 请求 /member/user/profile/get 接口 => 没有权限 | 1 | ### 请求 /member/user/profile/get 接口 => 没有权限 |
| 2 | -GET {{userServerUrl}}/member/user/profile/get | 2 | +GET {{appApi}}/member/user/get |
| 3 | Authorization: Bearer test245 | 3 | Authorization: Bearer test245 |
| 4 | +tenant-id: {{appTenentId}} | ||
| 4 | 5 | ||
| 5 | ### 请求 /member/user/profile/revise-nickname 接口 成功 | 6 | ### 请求 /member/user/profile/revise-nickname 接口 成功 |
| 6 | -PUT {{userServerUrl}}/member/user/profile/update-nickname?nickName=yunai222 | 7 | +PUT {{appApi}}/member/user/update-nickname?nickname=yunai222 |
| 7 | Authorization: Bearer test245 | 8 | Authorization: Bearer test245 |
| 9 | +tenant-id: {{appTenentId}} | ||
| 8 | 10 | ||
| 9 | -### 请求 /member/user/profile/get-user-info 接口 成功 | ||
| 10 | -GET {{userServerUrl}}/member/user/profile/get-user-info?id=245 | 11 | +### 请求 /member/user/get-user-info 接口 成功 |
| 12 | +GET {{appApi}}/member/user/get-user-info?id=245 | ||
| 11 | Authorization: Bearer test245 | 13 | Authorization: Bearer test245 |
| 14 | +tenant-id: {{appTenentId}} |
yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/PayRedisKeyCoreConstants.java renamed to yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java
| @@ -3,14 +3,12 @@ package cn.iocoder.yudao.module.pay.dal.redis; | @@ -3,14 +3,12 @@ package cn.iocoder.yudao.module.pay.dal.redis; | ||
| 3 | import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine; | 3 | import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine; |
| 4 | import org.redisson.api.RLock; | 4 | import org.redisson.api.RLock; |
| 5 | 5 | ||
| 6 | -import static cn.iocoder.yudao.framework.redis.core.RedisKeyDefine.KeyTypeEnum.HASH; | ||
| 7 | - | ||
| 8 | /** | 6 | /** |
| 9 | * 支付 Redis Key 枚举类 | 7 | * 支付 Redis Key 枚举类 |
| 10 | * | 8 | * |
| 11 | * @author 芋道源码 | 9 | * @author 芋道源码 |
| 12 | */ | 10 | */ |
| 13 | -public interface PayRedisKeyCoreConstants { | 11 | +public interface RedisKeyConstants { |
| 14 | 12 | ||
| 15 | RedisKeyDefine PAY_NOTIFY_LOCK = new RedisKeyDefine("通知任务的分布式锁", | 13 | RedisKeyDefine PAY_NOTIFY_LOCK = new RedisKeyDefine("通知任务的分布式锁", |
| 16 | "pay_notify:lock:", // 参数来自 DefaultLockKeyBuilder 类 | 14 | "pay_notify:lock:", // 参数来自 DefaultLockKeyBuilder 类 |
yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java
| @@ -7,7 +7,7 @@ import org.springframework.stereotype.Repository; | @@ -7,7 +7,7 @@ import org.springframework.stereotype.Repository; | ||
| 7 | import javax.annotation.Resource; | 7 | import javax.annotation.Resource; |
| 8 | import java.util.concurrent.TimeUnit; | 8 | import java.util.concurrent.TimeUnit; |
| 9 | 9 | ||
| 10 | -import static cn.iocoder.yudao.module.pay.dal.redis.PayRedisKeyCoreConstants.PAY_NOTIFY_LOCK; | 10 | +import static cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants.PAY_NOTIFY_LOCK; |
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * 支付通知的锁 Redis DAO | 13 | * 支付通知的锁 Redis DAO |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/logger/OperateLogDO.java
| 1 | package cn.iocoder.yudao.module.system.dal.dataobject.logger; | 1 | package cn.iocoder.yudao.module.system.dal.dataobject.logger; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; | 3 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; | 5 | import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; |
| 6 | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | 6 | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; |
| @@ -48,10 +48,16 @@ public class OperateLogDO extends TenantBaseDO { | @@ -48,10 +48,16 @@ public class OperateLogDO extends TenantBaseDO { | ||
| 48 | /** | 48 | /** |
| 49 | * 用户编号 | 49 | * 用户编号 |
| 50 | * | 50 | * |
| 51 | - * {@link AdminUserDO#getId()} | 51 | + * 关联 MemberUserDO 的 id 属性,或者 AdminUserDO 的 id 属性 |
| 52 | */ | 52 | */ |
| 53 | private Long userId; | 53 | private Long userId; |
| 54 | /** | 54 | /** |
| 55 | + * 用户类型 | ||
| 56 | + * | ||
| 57 | + * 关联 {@link UserTypeEnum} | ||
| 58 | + */ | ||
| 59 | + private Integer userType; | ||
| 60 | + /** | ||
| 55 | * 操作模块 | 61 | * 操作模块 |
| 56 | */ | 62 | */ |
| 57 | private String module; | 63 | private String module; |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/redis/RedisKeyConstants.java
| @@ -27,7 +27,7 @@ public interface RedisKeyConstants { | @@ -27,7 +27,7 @@ public interface RedisKeyConstants { | ||
| 27 | "social_auth_user:%d:%s", // 参数为 type,code | 27 | "social_auth_user:%d:%s", // 参数为 type,code |
| 28 | STRING, AuthUser.class, Duration.ofDays(1)); | 28 | STRING, AuthUser.class, Duration.ofDays(1)); |
| 29 | 29 | ||
| 30 | - RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交登陆的 state", | 30 | + RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交登陆的 state", // 注意,它是被 JustAuth 的 justauth.type.prefix 使用到 |
| 31 | "social_auth_state:%s", // 参数为 state | 31 | "social_auth_state:%s", // 参数为 state |
| 32 | STRING, String.class, Duration.ofHours(24)); // 值为 state | 32 | STRING, String.class, Duration.ofHours(24)); // 值为 state |
| 33 | 33 |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java
| @@ -9,8 +9,8 @@ import org.springframework.security.config.annotation.web.configurers.Expression | @@ -9,8 +9,8 @@ import org.springframework.security.config.annotation.web.configurers.Expression | ||
| 9 | /** | 9 | /** |
| 10 | * System 模块的 Security 配置 | 10 | * System 模块的 Security 配置 |
| 11 | */ | 11 | */ |
| 12 | -@Configuration | ||
| 13 | -public class SystemSecurityConfiguration { | 12 | +@Configuration("systemSecurityConfiguration") |
| 13 | +public class SecurityConfiguration { | ||
| 14 | 14 | ||
| 15 | @Bean("systemAuthorizeRequestsCustomizer") | 15 | @Bean("systemAuthorizeRequestsCustomizer") |
| 16 | public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { | 16 | public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
| @@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j; | @@ -16,6 +16,7 @@ import lombok.extern.slf4j.Slf4j; | ||
| 16 | import org.springframework.scheduling.annotation.Async; | 16 | import org.springframework.scheduling.annotation.Async; |
| 17 | import org.springframework.scheduling.annotation.AsyncResult; | 17 | import org.springframework.scheduling.annotation.AsyncResult; |
| 18 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 19 | +import org.springframework.validation.annotation.Validated; | ||
| 19 | 20 | ||
| 20 | import javax.annotation.Resource; | 21 | import javax.annotation.Resource; |
| 21 | import java.util.Collection; | 22 | import java.util.Collection; |
| @@ -28,6 +29,7 @@ import static cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO. | @@ -28,6 +29,7 @@ import static cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO. | ||
| 28 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 29 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 29 | 30 | ||
| 30 | @Service | 31 | @Service |
| 32 | +@Validated | ||
| 31 | @Slf4j | 33 | @Slf4j |
| 32 | public class OperateLogServiceImpl implements OperateLogService { | 34 | public class OperateLogServiceImpl implements OperateLogService { |
| 33 | 35 |
更新日志.md
| @@ -10,8 +10,8 @@ | @@ -10,8 +10,8 @@ | ||
| 10 | * 用户前台的社交登陆 | 10 | * 用户前台的社交登陆 |
| 11 | * 用户前台的修改手机、修改密码、忘记密码 | 11 | * 用户前台的修改手机、修改密码、忘记密码 |
| 12 | * 升级 mybatis plus 最新版本,优化多租户的实现 | 12 | * 升级 mybatis plus 最新版本,优化多租户的实现 |
| 13 | +* RedisKeyDefine 的发现机制 | ||
| 13 | 14 | ||
| 14 | -*【优化】操作日志新增用户类型,实现 APP 端的 API 的操作日志的记录 | ||
| 15 | *【修复】管理后台 UI 超时登录后,返回登陆界面时,由于未登陆加载不到字典数据,导致报错的问题 | 15 | *【修复】管理后台 UI 超时登录后,返回登陆界面时,由于未登陆加载不到字典数据,导致报错的问题 |
| 16 | 16 | ||
| 17 | 17 |