|
|
|
|
package com.project.operation.application;
|
|
|
|
|
|
|
|
|
|
import com.project.base.domain.exception.BusinessErrorException;
|
|
|
|
|
import com.project.base.domain.result.PageResult;
|
|
|
|
|
import com.project.base.domain.result.Result;
|
|
|
|
|
import com.project.base.domain.utils.ExcelUtil;
|
|
|
|
|
import com.project.operation.application.impl.OperationLogApplicationService;
|
|
|
|
|
import com.project.operation.domain.dto.OperationLogDTO;
|
|
|
|
|
import com.project.operation.domain.dto.OperationLogExportDTO;
|
|
|
|
|
import com.project.operation.domain.param.OperationLogParam;
|
|
|
|
|
import com.project.operation.domain.service.SaveOperationLogDomainService;
|
|
|
|
|
import com.project.operation.domain.service.SearchOperationLogDomainService;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class OperationLogApplicationServiceImpl implements OperationLogApplicationService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SaveOperationLogDomainService saveOperationLogDomainService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SearchOperationLogDomainService searchOperationLogDomainService;
|
|
|
|
|
|
|
|
|
|
private static final String SHEET_NAME = "操作日志数据";
|
|
|
|
|
private static final String EXCEL_FILENAME = "operationLog";
|
|
|
|
|
private static final Integer PAGE_MAX_SIZE = 5001;
|
|
|
|
|
private static final Integer PAGE_DEFAULT_CURRENT = 1;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存日志
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void saveOperationLog(OperationLogDTO operationLogDTO) {
|
|
|
|
|
saveOperationLogDomainService.saveOperationLog(operationLogDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询日志
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Result<PageResult<OperationLogDTO>> list(OperationLogParam param) {
|
|
|
|
|
return searchOperationLogDomainService.list(param);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Async("asycExecutor")
|
|
|
|
|
public void saveOperationLogAsync(OperationLogDTO operationLogDTO) {
|
|
|
|
|
this.saveOperationLog(operationLogDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出日志
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void export(HttpServletResponse response, OperationLogParam param) {
|
|
|
|
|
//获取日志列表
|
|
|
|
|
param.setSize(PAGE_MAX_SIZE);
|
|
|
|
|
param.setCurrent(PAGE_DEFAULT_CURRENT);
|
|
|
|
|
List<OperationLogExportDTO> operationLogExportDTOList = searchOperationLogDomainService.list(param).getData().getContent()
|
|
|
|
|
.stream().map(dto -> dto.toEntity(OperationLogExportDTO::new)).collect(Collectors.toList());
|
|
|
|
|
if (operationLogExportDTOList.size() == PAGE_MAX_SIZE) {
|
|
|
|
|
throw new BusinessErrorException("最大条数限制5000条超过最大限制不允许导出");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExcelUtil<OperationLogExportDTO> util = new ExcelUtil<>();
|
|
|
|
|
util.exportExcel(response,operationLogExportDTOList,SHEET_NAME,EXCEL_FILENAME,OperationLogExportDTO.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|