mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-04 19:38:02 +00:00
update 替换BeanCopyUtil用法使用mapstruct
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package org.dromara.common.log.domain.convert;
|
||||
|
||||
import org.dromara.common.log.event.OperLogEvent;
|
||||
import org.dromara.system.api.domain.bo.RemoteOperLogBo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 操作日志转换器
|
||||
* @author zhujie
|
||||
*/
|
||||
@Mapper
|
||||
public interface OperLogEventConvert {
|
||||
|
||||
OperLogEventConvert INSTANCE = Mappers.getMapper(OperLogEventConvert.class);
|
||||
|
||||
/**
|
||||
* OperLogEventToRemoteOperLogBo
|
||||
* @param operLogEvent 待转换对象
|
||||
* @return 转换后对象
|
||||
*/
|
||||
@Mapping(target = "params", ignore = true)
|
||||
RemoteOperLogBo convert(OperLogEvent operLogEvent);
|
||||
}
|
@@ -5,10 +5,10 @@ import cn.hutool.http.useragent.UserAgentUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.utils.BeanCopyUtils;
|
||||
import org.dromara.common.core.utils.ServletUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
||||
import org.dromara.common.log.domain.convert.OperLogEventConvert;
|
||||
import org.dromara.system.api.RemoteLogService;
|
||||
import org.dromara.system.api.domain.bo.RemoteLogininforBo;
|
||||
import org.dromara.system.api.domain.bo.RemoteOperLogBo;
|
||||
@@ -36,7 +36,7 @@ public class LogEventListener {
|
||||
@Async
|
||||
@EventListener
|
||||
public void saveLog(OperLogEvent operLogEvent) {
|
||||
RemoteOperLogBo sysOperLog = BeanCopyUtils.copy(operLogEvent, RemoteOperLogBo.class);
|
||||
RemoteOperLogBo sysOperLog = OperLogEventConvert.INSTANCE.convert(operLogEvent);
|
||||
remoteLogService.saveLog(sysOperLog);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user