|
|
|
@ -1,8 +1,10 @@ |
|
|
|
package com.project.operation.domain.service.impl.description; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.project.information.domain.dto.ProductLineDTO; |
|
|
|
import com.project.information.domain.entity.InformationEntity; |
|
|
|
import com.project.information.domain.entity.ProductLineEntity; |
|
|
|
import com.project.information.domain.param.GenerateFromFilesParam; |
|
|
|
import com.project.information.mapper.InformationMapper; |
|
|
|
import com.project.information.mapper.ProductLineMapper; |
|
|
|
import com.project.operation.domain.dto.OperationLogDTO; |
|
|
|
@ -14,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
@ -25,6 +28,9 @@ import java.util.stream.Collectors; |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
|
private static final String CATEGORY_LEVEL_1 = "【一级分类】"; |
|
|
|
private static final String CATEGORY_LEVEL_2 = "【二级分类】"; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ProductLineMapper productLineMapper; |
|
|
|
@Autowired |
|
|
|
@ -43,7 +49,9 @@ public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
|
}else{ |
|
|
|
operationLogDTO.setAction("创建"); |
|
|
|
} |
|
|
|
operationLogDTO.setDescription("【"+ productLineDTO.getName()+"】"); |
|
|
|
|
|
|
|
String categoryPrefix = ObjectUtil.isNull(productLineDTO.getParentId()) ? CATEGORY_LEVEL_1 : CATEGORY_LEVEL_2; |
|
|
|
operationLogDTO.setDescription(categoryPrefix + "/【" + productLineDTO.getName() + "】"); |
|
|
|
} |
|
|
|
|
|
|
|
if(methodName.equals("delete") && ObjectUtils.isNotEmpty(args) && args[0] instanceof Long id){ |
|
|
|
@ -54,7 +62,8 @@ public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
|
if (productLineEntity == null){ |
|
|
|
return false; |
|
|
|
} |
|
|
|
operationLogDTO.setDescription("【"+ productLineEntity.getName()+"】"); |
|
|
|
String categoryPrefix = ObjectUtil.isNull(productLineEntity.getParentId()) ? CATEGORY_LEVEL_1 : CATEGORY_LEVEL_2; |
|
|
|
operationLogDTO.setDescription(categoryPrefix + "/【" + productLineEntity.getName() + "】"); |
|
|
|
} |
|
|
|
|
|
|
|
if (methodName.equals("batchDelete") && ObjectUtils.isNotEmpty(args) && args[0] instanceof String ids) { |
|
|
|
@ -76,12 +85,24 @@ public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
|
String description = infoEntities.stream() |
|
|
|
.map(informationDTO ->{ |
|
|
|
String taskName = Optional.ofNullable(informationDTO.getName()).orElse("未知文件"); |
|
|
|
return "【" + informationDTO.getName() + "】"; |
|
|
|
return "【" + taskName + "】"; |
|
|
|
}) |
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
operationLogDTO.setDescription(description); |
|
|
|
} |
|
|
|
|
|
|
|
if (methodName.equals("batchUploadAndOverwrite") && ObjectUtils.isNotEmpty(args) && args[0] instanceof MultipartFile[] files) { |
|
|
|
String description = Arrays.stream(files) |
|
|
|
.map(f -> "【" + Optional.ofNullable(f.getOriginalFilename()).orElse("未知文件") + "】") |
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
operationLogDTO.setDescription(description); |
|
|
|
} |
|
|
|
|
|
|
|
if (methodName.equals("generateFromFiles") && ObjectUtils.isNotEmpty(args) && args[0] instanceof GenerateFromFilesParam param) { |
|
|
|
String fileName = Optional.ofNullable(param.getFileName()).orElse("未知文件"); |
|
|
|
operationLogDTO.setDescription("【" + fileName + "】"); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|