系统操作日志使用异步插入,解决平台所有日志阻塞问题!! 屮

This commit is contained in:
wangliwen 2022-06-20 14:25:07 +08:00
parent e1edb302f5
commit b165e91663
2 changed files with 8 additions and 5 deletions

View File

@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture;
/** /**
* 操作日志 * 操作日志
@ -28,8 +29,8 @@ public class SysLogOperationServiceImpl extends BaseServiceImpl<SysLogOperationD
@Override @Override
public PageData<SysLogOperationDTO> page(Map<String, Object> params) { public PageData<SysLogOperationDTO> page(Map<String, Object> params) {
IPage<SysLogOperationEntity> page = baseDao.selectPage( IPage<SysLogOperationEntity> page = baseDao.selectPage(
getPage(params, Constant.CREATE_DATE, false), getPage(params, Constant.CREATE_DATE, false),
getWrapper(params) getWrapper(params)
); );
return getPageData(page, SysLogOperationDTO.class); return getPageData(page, SysLogOperationDTO.class);
@ -42,7 +43,7 @@ public class SysLogOperationServiceImpl extends BaseServiceImpl<SysLogOperationD
return ConvertUtils.sourceToTarget(entityList, SysLogOperationDTO.class); return ConvertUtils.sourceToTarget(entityList, SysLogOperationDTO.class);
} }
private QueryWrapper<SysLogOperationEntity> getWrapper(Map<String, Object> params){ private QueryWrapper<SysLogOperationEntity> getWrapper(Map<String, Object> params) {
String status = (String) params.get("status"); String status = (String) params.get("status");
QueryWrapper<SysLogOperationEntity> wrapper = new QueryWrapper<>(); QueryWrapper<SysLogOperationEntity> wrapper = new QueryWrapper<>();
@ -54,7 +55,9 @@ public class SysLogOperationServiceImpl extends BaseServiceImpl<SysLogOperationD
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void save(SysLogOperationEntity entity) { public void save(SysLogOperationEntity entity) {
insert(entity); CompletableFuture.runAsync(() -> {
insert(entity);
});
} }
} }

View File

@ -210,7 +210,7 @@ public class ResourceController {
@ApiOperation("导入") @ApiOperation("导入")
@LogOperation("导入") @LogOperation("导入")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "source", value = "请求来源", paramType = "string", dataType = "string") @ApiImplicitParam(name = "file", value = "数据文件文件", paramType = "file", dataType = "file")
}) })
public Result importResource(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) { public Result importResource(@RequestParam("file") MultipartFile uploadFile, HttpServletRequest request) {
List<Map<String, Object>> dept = List<Map<String, Object>> dept =