系统操作日志:集成 mzt-biz-log 2
This commit is contained in:
parent
c5cc818a49
commit
13d6c42a48
@ -135,7 +135,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||
// 1. 校验客户是否存在
|
||||
validateCustomer(reqVO.getId());
|
||||
|
||||
// 添加 crmCustomer 到日志上下文
|
||||
LogRecordContext.putVariable("crmCustomer", customerMapper.selectById(reqVO.getId()));
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
|
@ -1,53 +1,16 @@
|
||||
package cn.iocoder.yudao.module.system.framework.bizlog.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.framework.bizlog.service.AdminUserParseFunction;
|
||||
import cn.iocoder.yudao.module.system.framework.bizlog.service.ILogRecordServiceImpl;
|
||||
import com.mzt.logapi.beans.Operator;
|
||||
import com.mzt.logapi.service.IOperatorGetService;
|
||||
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* 使用 @Configuration 是因为 mzt-biz-log 的配置类是 @Configuration 的
|
||||
*
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableLogRecord(tenant = "${yudao.info.base-package}")
|
||||
@Slf4j
|
||||
public class YudaoOperateLogV2Configuration {
|
||||
|
||||
//======================= mzt-biz-log =======================
|
||||
|
||||
@Bean
|
||||
public ILogRecordServiceImpl iLogRecordServiceImpl(OperateLogApi operateLogApi) {
|
||||
log.info("ILogRecordServiceImpl 初始化");
|
||||
return new ILogRecordServiceImpl(operateLogApi);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IOperatorGetService operatorGetLoginUserIdService() {
|
||||
// 获取操作用户编号
|
||||
return () -> Optional.of(WebFrameworkUtils.getLoginUserId())
|
||||
.map(a -> {
|
||||
Operator operator = new Operator();
|
||||
operator.setOperatorId(a.toString());
|
||||
return operator;
|
||||
})
|
||||
.orElseThrow(() -> new IllegalArgumentException("user is null"));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AdminUserParseFunction adminUserParseFunction(AdminUserApi adminUserApi) {
|
||||
return new AdminUserParseFunction(adminUserApi);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cn.iocoder.yudao.module.system.framework.bizlog.service;
|
||||
package cn.iocoder.yudao.module.system.framework.bizlog.function;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.mzt.logapi.service.IParseFunction;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 自定义函数-通过用户编号获取用户信息
|
||||
@ -14,10 +15,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
public class AdminUserParseFunction implements IParseFunction {
|
||||
|
||||
private final AdminUserApi adminUserApi;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
@ -3,8 +3,9 @@ package cn.iocoder.yudao.module.system.framework.bizlog.service;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import com.mzt.logapi.beans.LogRecord;
|
||||
import com.mzt.logapi.service.ILogRecordService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -17,10 +18,11 @@ import java.util.List;
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ILogRecordServiceImpl implements ILogRecordService {
|
||||
|
||||
private final OperateLogApi operateLogApi;
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
@Override
|
||||
public void record(LogRecord logRecord) {
|
||||
|
Loading…
Reference in New Issue
Block a user