Commit 13d6c42a4869cec4608f94cc46d2876797916a8f
1 parent
c5cc818a
系统操作日志:集成 mzt-biz-log 2
Showing
4 changed files
with
13 additions
and
46 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -135,7 +135,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 135 | 135 | public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { |
| 136 | 136 | // 1. 校验客户是否存在 |
| 137 | 137 | validateCustomer(reqVO.getId()); |
| 138 | - | |
| 138 | + // 添加 crmCustomer 到日志上下文 | |
| 139 | 139 | LogRecordContext.putVariable("crmCustomer", customerMapper.selectById(reqVO.getId())); |
| 140 | 140 | // 2.1 数据权限转移 |
| 141 | 141 | crmPermissionService.transferPermission( | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/config/YudaoOperateLogV2Configuration.java
| 1 | 1 | package cn.iocoder.yudao.module.system.framework.bizlog.config; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; | |
| 4 | -import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; | |
| 5 | -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | |
| 6 | -import cn.iocoder.yudao.module.system.framework.bizlog.service.AdminUserParseFunction; | |
| 7 | -import cn.iocoder.yudao.module.system.framework.bizlog.service.ILogRecordServiceImpl; | |
| 8 | -import com.mzt.logapi.beans.Operator; | |
| 9 | -import com.mzt.logapi.service.IOperatorGetService; | |
| 10 | 3 | import com.mzt.logapi.starter.annotation.EnableLogRecord; |
| 11 | -import lombok.extern.slf4j.Slf4j; | |
| 12 | -import org.springframework.context.annotation.Bean; | |
| 13 | 4 | import org.springframework.context.annotation.Configuration; |
| 14 | 5 | |
| 15 | -import java.util.Optional; | |
| 16 | - | |
| 17 | 6 | |
| 18 | 7 | /** |
| 19 | - * 使用 @Configuration 是因为 mzt-biz-log 的配置类是 @Configuration 的 | |
| 8 | + * | |
| 20 | 9 | * |
| 21 | 10 | * @author HUIHUI |
| 22 | 11 | */ |
| 23 | 12 | @Configuration(proxyBeanMethods = false) |
| 24 | 13 | @EnableLogRecord(tenant = "${yudao.info.base-package}") |
| 25 | -@Slf4j | |
| 26 | 14 | public class YudaoOperateLogV2Configuration { |
| 27 | 15 | |
| 28 | - //======================= mzt-biz-log ======================= | |
| 29 | - | |
| 30 | - @Bean | |
| 31 | - public ILogRecordServiceImpl iLogRecordServiceImpl(OperateLogApi operateLogApi) { | |
| 32 | - log.info("ILogRecordServiceImpl 初始化"); | |
| 33 | - return new ILogRecordServiceImpl(operateLogApi); | |
| 34 | - } | |
| 35 | - | |
| 36 | - @Bean | |
| 37 | - public IOperatorGetService operatorGetLoginUserIdService() { | |
| 38 | - // 获取操作用户编号 | |
| 39 | - return () -> Optional.of(WebFrameworkUtils.getLoginUserId()) | |
| 40 | - .map(a -> { | |
| 41 | - Operator operator = new Operator(); | |
| 42 | - operator.setOperatorId(a.toString()); | |
| 43 | - return operator; | |
| 44 | - }) | |
| 45 | - .orElseThrow(() -> new IllegalArgumentException("user is null")); | |
| 46 | - } | |
| 47 | - | |
| 48 | - @Bean | |
| 49 | - public AdminUserParseFunction adminUserParseFunction(AdminUserApi adminUserApi) { | |
| 50 | - return new AdminUserParseFunction(adminUserApi); | |
| 51 | - } | |
| 52 | - | |
| 53 | 16 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/service/AdminUserParseFunction.java renamed to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/function/AdminUserParseFunction.java
| 1 | -package cn.iocoder.yudao.module.system.framework.bizlog.service; | |
| 1 | +package cn.iocoder.yudao.module.system.framework.bizlog.function; | |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ObjUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | 5 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 6 | 6 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 7 | 7 | import com.mzt.logapi.service.IParseFunction; |
| 8 | -import lombok.RequiredArgsConstructor; | |
| 8 | +import jakarta.annotation.Resource; | |
| 9 | 9 | import lombok.extern.slf4j.Slf4j; |
| 10 | +import org.springframework.stereotype.Component; | |
| 10 | 11 | |
| 11 | 12 | /** |
| 12 | 13 | * 自定义函数-通过用户编号获取用户信息 |
| ... | ... | @@ -14,10 +15,11 @@ import lombok.extern.slf4j.Slf4j; |
| 14 | 15 | * @author HUIHUI |
| 15 | 16 | */ |
| 16 | 17 | @Slf4j |
| 17 | -@RequiredArgsConstructor | |
| 18 | +@Component | |
| 18 | 19 | public class AdminUserParseFunction implements IParseFunction { |
| 19 | 20 | |
| 20 | - private final AdminUserApi adminUserApi; | |
| 21 | + @Resource | |
| 22 | + private AdminUserApi adminUserApi; | |
| 21 | 23 | |
| 22 | 24 | @Override |
| 23 | 25 | public boolean executeBefore() { | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/service/ILogRecordServiceImpl.java
| ... | ... | @@ -3,8 +3,9 @@ package cn.iocoder.yudao.module.system.framework.bizlog.service; |
| 3 | 3 | import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; |
| 4 | 4 | import com.mzt.logapi.beans.LogRecord; |
| 5 | 5 | import com.mzt.logapi.service.ILogRecordService; |
| 6 | -import lombok.RequiredArgsConstructor; | |
| 6 | +import jakarta.annotation.Resource; | |
| 7 | 7 | import lombok.extern.slf4j.Slf4j; |
| 8 | +import org.springframework.stereotype.Service; | |
| 8 | 9 | |
| 9 | 10 | import java.util.Collections; |
| 10 | 11 | import java.util.List; |
| ... | ... | @@ -17,10 +18,11 @@ import java.util.List; |
| 17 | 18 | * @author HUIHUI |
| 18 | 19 | */ |
| 19 | 20 | @Slf4j |
| 20 | -@RequiredArgsConstructor | |
| 21 | +@Service | |
| 21 | 22 | public class ILogRecordServiceImpl implements ILogRecordService { |
| 22 | 23 | |
| 23 | - private final OperateLogApi operateLogApi; | |
| 24 | + @Resource | |
| 25 | + private OperateLogApi operateLogApi; | |
| 24 | 26 | |
| 25 | 27 | @Override |
| 26 | 28 | public void record(LogRecord logRecord) { | ... | ... |