From ae9186f4b413174489758af024bb3c075e057a7b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 4 Feb 2022 17:51:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A8=A1=E5=9D=97=E9=87=8D=E6=9E=84?= =?UTF-8?q?=2014=EF=BC=9AMEMBER=20=E7=94=A8=E6=88=B7=EF=BC=8C=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=8E=89=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E7=9A=84?= =?UTF-8?q?=E8=AE=B0=E5=BD=95~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operatelog/core/aop/OperateLogAspect.java | 7 +++++++ ...yConfiguration.java => SecurityConfiguration.java} | 4 ++-- .../member/controller/app/user/AppUserController.http | 11 +++++++---- ...isKeyCoreConstants.java => RedisKeyConstants.java} | 4 +--- .../pay/dal/redis/notify/PayNotifyLockRedisDAO.java | 2 +- .../system/dal/dataobject/logger/OperateLogDO.java | 10 ++++++++-- .../module/system/dal/redis/RedisKeyConstants.java | 2 +- ...yConfiguration.java => SecurityConfiguration.java} | 4 ++-- .../system/service/logger/OperateLogServiceImpl.java | 2 ++ 更新日志.md | 2 +- 10 files changed, 32 insertions(+), 16 deletions(-) rename yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/{InfraSecurityConfiguration.java => SecurityConfiguration.java} (96%) rename yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/{PayRedisKeyCoreConstants.java => RedisKeyConstants.java} (80%) rename yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/{SystemSecurityConfiguration.java => SecurityConfiguration.java} (94%) diff --git a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java b/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java index 6cda19f82..cb5dc0d00 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-operatelog/src/main/java/cn/iocoder/yudao/framework/operatelog/core/aop/OperateLogAspect.java +++ b/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; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.servlet.ServletUtil; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.dto.OperateLogCreateReqDTO; @@ -81,6 +82,12 @@ public class OperateLogAspect { } private Object around0(ProceedingJoinPoint joinPoint, OperateLog operateLog, ApiOperation apiOperation) throws Throwable { + // 目前,只有管理员,才记录操作日志!所以非管理员,直接调用,不进行记录 + Integer userType = WebFrameworkUtils.getLoginUserType(); + if (!Objects.equals(userType, UserTypeEnum.ADMIN.getValue())) { + return joinPoint.proceed(); + } + // 记录开始时间 Date startTime = new Date(); try { diff --git a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java similarity index 96% rename from yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java rename to yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java index 8af44d694..3b2a5501e 100644 --- a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/InfraSecurityConfiguration.java +++ b/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 /** * Infra 模块的 Security 配置 */ -@Configuration -public class InfraSecurityConfiguration { +@Configuration("infraSecurityConfiguration") +public class SecurityConfiguration { @Value("${spring.boot.admin.context-path:''}") private String adminSeverContextPath; diff --git a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.http b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.http index 26bd55aaf..4e4be2a4d 100644 --- a/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.http +++ b/yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/controller/app/user/AppUserController.http @@ -1,11 +1,14 @@ ### 请求 /member/user/profile/get 接口 => 没有权限 -GET {{userServerUrl}}/member/user/profile/get +GET {{appApi}}/member/user/get Authorization: Bearer test245 +tenant-id: {{appTenentId}} ### 请求 /member/user/profile/revise-nickname 接口 成功 -PUT {{userServerUrl}}/member/user/profile/update-nickname?nickName=yunai222 +PUT {{appApi}}/member/user/update-nickname?nickname=yunai222 Authorization: Bearer test245 +tenant-id: {{appTenentId}} -### 请求 /member/user/profile/get-user-info 接口 成功 -GET {{userServerUrl}}/member/user/profile/get-user-info?id=245 +### 请求 /member/user/get-user-info 接口 成功 +GET {{appApi}}/member/user/get-user-info?id=245 Authorization: Bearer test245 +tenant-id: {{appTenentId}} diff --git a/yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/PayRedisKeyCoreConstants.java b/yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java similarity index 80% rename from yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/PayRedisKeyCoreConstants.java rename to yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/RedisKeyConstants.java index acba20be9..4f5aaf750 100644 --- a/yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/PayRedisKeyCoreConstants.java +++ b/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; import cn.iocoder.yudao.framework.redis.core.RedisKeyDefine; import org.redisson.api.RLock; -import static cn.iocoder.yudao.framework.redis.core.RedisKeyDefine.KeyTypeEnum.HASH; - /** * 支付 Redis Key 枚举类 * * @author 芋道源码 */ -public interface PayRedisKeyCoreConstants { +public interface RedisKeyConstants { RedisKeyDefine PAY_NOTIFY_LOCK = new RedisKeyDefine("通知任务的分布式锁", "pay_notify:lock:", // 参数来自 DefaultLockKeyBuilder 类 diff --git a/yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java b/yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java index 227eda28a..2d1f13f16 100644 --- a/yudao-module-pay/yudao-module-pay-impl/src/main/java/cn/iocoder/yudao/module/pay/dal/redis/notify/PayNotifyLockRedisDAO.java +++ b/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; import javax.annotation.Resource; import java.util.concurrent.TimeUnit; -import static cn.iocoder.yudao.module.pay.dal.redis.PayRedisKeyCoreConstants.PAY_NOTIFY_LOCK; +import static cn.iocoder.yudao.module.pay.dal.redis.RedisKeyConstants.PAY_NOTIFY_LOCK; /** * 支付通知的锁 Redis DAO diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/logger/OperateLogDO.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/logger/OperateLogDO.java index c365a3347..c76ec5f7b 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/logger/OperateLogDO.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/logger/OperateLogDO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.system.dal.dataobject.logger; -import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; @@ -48,9 +48,15 @@ public class OperateLogDO extends TenantBaseDO { /** * 用户编号 * - * {@link AdminUserDO#getId()} + * 关联 MemberUserDO 的 id 属性,或者 AdminUserDO 的 id 属性 */ private Long userId; + /** + * 用户类型 + * + * 关联 {@link UserTypeEnum} + */ + private Integer userType; /** * 操作模块 */ diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/redis/RedisKeyConstants.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/redis/RedisKeyConstants.java index d2d28219b..a98edc17f 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/redis/RedisKeyConstants.java +++ b/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 { "social_auth_user:%d:%s", // 参数为 type,code STRING, AuthUser.class, Duration.ofDays(1)); - RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交登陆的 state", + RedisKeyDefine SOCIAL_AUTH_STATE = new RedisKeyDefine("社交登陆的 state", // 注意,它是被 JustAuth 的 justauth.type.prefix 使用到 "social_auth_state:%s", // 参数为 state STRING, String.class, Duration.ofHours(24)); // 值为 state diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java similarity index 94% rename from yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java rename to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java index 3c6866e37..53b99ce8c 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SystemSecurityConfiguration.java +++ b/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 /** * System 模块的 Security 配置 */ -@Configuration -public class SystemSecurityConfiguration { +@Configuration("systemSecurityConfiguration") +public class SecurityConfiguration { @Bean("systemAuthorizeRequestsCustomizer") public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java index dc1175f60..b1e0383fe 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java +++ b/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; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.Collection; @@ -28,6 +29,7 @@ import static cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO. import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @Service +@Validated @Slf4j public class OperateLogServiceImpl implements OperateLogService { diff --git a/更新日志.md b/更新日志.md index 7d12c7575..1f957cbe1 100644 --- a/更新日志.md +++ b/更新日志.md @@ -10,8 +10,8 @@ * 用户前台的社交登陆 * 用户前台的修改手机、修改密码、忘记密码 * 升级 mybatis plus 最新版本,优化多租户的实现 +* RedisKeyDefine 的发现机制 -*【优化】操作日志新增用户类型,实现 APP 端的 API 的操作日志的记录 *【修复】管理后台 UI 超时登录后,返回登陆界面时,由于未登陆加载不到字典数据,导致报错的问题