1.添加大哥数据入库花费时间日志

This commit is contained in:
2025-06-24 19:09:22 +08:00
parent a60ae2df1a
commit 8065a8d048

View File

@@ -2,6 +2,8 @@ package com.yupi.springbootinit.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@@ -10,18 +12,22 @@ import com.yupi.springbootinit.mapper.ServerBigBrotherMapper;
import com.yupi.springbootinit.model.entity.ServerBigBrother;
import com.yupi.springbootinit.service.ServerBigBrotherService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
/*
* @author: ziin
* @date: 2025/6/24 16:19
*/
@Service
@Slf4j
public class ServerBigBrotherServiceImpl extends ServiceImpl<ServerBigBrotherMapper, ServerBigBrother> implements ServerBigBrotherService{
@Override
@Transactional(rollbackFor = Exception.class)
@Async("taskExecutor")
public void saveData(ServerBigBrother bigBrother) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ServerBigBrother serverBigBrother = baseMapper.selectOne(Wrappers.<ServerBigBrother>lambdaQuery()
.eq(ServerBigBrother::getDisplayId, bigBrother.getDisplayId())
.eq(ServerBigBrother::getTenantId, bigBrother.getTenantId()));
@@ -30,6 +36,9 @@ public class ServerBigBrotherServiceImpl extends ServiceImpl<ServerBigBrotherMap
} else {
bigBrother.setId(serverBigBrother.getId());
updateById(bigBrother);
stopWatch.stop();
long totalTimeMillis = stopWatch.getTotalTimeMillis();
log.info("当前存储花费: {}ms",totalTimeMillis);
}
}
}