|
|
@ -1,19 +1,13 @@ |
|
|
package com.project.operation.domain.service.impl.description; |
|
|
package com.project.operation.domain.service.impl.description; |
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
import com.project.appeal.domain.dto.AppealDTO; |
|
|
|
|
|
import com.project.base.domain.result.Result; |
|
|
|
|
|
import com.project.information.application.InformationApplicationService; |
|
|
|
|
|
import com.project.information.application.ProductLineApplicationService; |
|
|
|
|
|
import com.project.information.domain.dto.InformationDTO; |
|
|
|
|
|
import com.project.information.domain.dto.ProductLineDTO; |
|
|
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.entity.ProductLineEntity; |
|
|
import com.project.information.domain.param.ProductLineParam; |
|
|
import com.project.information.mapper.InformationMapper; |
|
|
import com.project.information.domain.service.ProductLineBaseService; |
|
|
import com.project.information.mapper.ProductLineMapper; |
|
|
import com.project.operation.domain.dto.OperationLogDTO; |
|
|
import com.project.operation.domain.dto.OperationLogDTO; |
|
|
import com.project.operation.domain.enums.ModuleEnum; |
|
|
import com.project.operation.domain.enums.ModuleEnum; |
|
|
import com.project.operation.domain.service.DescriptionStrategy; |
|
|
import com.project.operation.domain.service.DescriptionStrategy; |
|
|
import com.project.task.domain.dto.TaskDTO; |
|
|
|
|
|
import lombok.SneakyThrows; |
|
|
import lombok.SneakyThrows; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -21,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.AbstractMap; |
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.Arrays; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Optional; |
|
|
import java.util.Optional; |
|
|
@ -33,15 +26,14 @@ import java.util.stream.Collectors; |
|
|
@Component |
|
|
@Component |
|
|
public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ProductLineBaseService productLineBaseService; |
|
|
private ProductLineMapper productLineMapper; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private InformationApplicationService informationApplicationService; |
|
|
private InformationMapper informationMapper; |
|
|
|
|
|
|
|
|
@SneakyThrows |
|
|
@SneakyThrows |
|
|
@Override |
|
|
@Override |
|
|
public Boolean process(Object[] args, OperationLogDTO operationLogDTO,String methodName) { |
|
|
public Boolean process(Object[] args, OperationLogDTO operationLogDTO,String methodName) { |
|
|
if (methodName.equals("save") && ObjectUtils.isNotEmpty(args) && args[0] instanceof ProductLineDTO) { |
|
|
if (methodName.equals("save") && ObjectUtils.isNotEmpty(args) && args[0] instanceof ProductLineDTO productLineDTO) { |
|
|
ProductLineDTO productLineDTO = (ProductLineDTO) args[0]; |
|
|
|
|
|
|
|
|
|
|
|
if (productLineDTO.getLeaf() == null || StringUtils.isBlank(productLineDTO.getName())) { |
|
|
if (productLineDTO.getLeaf() == null || StringUtils.isBlank(productLineDTO.getName())) { |
|
|
return false; |
|
|
return false; |
|
|
@ -54,15 +46,10 @@ public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
operationLogDTO.setDescription("【"+ productLineDTO.getName()+"】"); |
|
|
operationLogDTO.setDescription("【"+ productLineDTO.getName()+"】"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(methodName.equals("delete") && ObjectUtils.isNotEmpty(args) && args[0] instanceof Long){ |
|
|
if(methodName.equals("delete") && ObjectUtils.isNotEmpty(args) && args[0] instanceof Long id){ |
|
|
Long id = (Long) args[0]; |
|
|
|
|
|
|
|
|
|
|
|
if(id==null){ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
operationLogDTO.setAction("删除"); |
|
|
operationLogDTO.setAction("删除"); |
|
|
ProductLineEntity productLineEntity = productLineBaseService.getById(id); |
|
|
ProductLineEntity productLineEntity = productLineMapper.selectByIdIncludeDeleted(id); |
|
|
|
|
|
|
|
|
if (productLineEntity == null){ |
|
|
if (productLineEntity == null){ |
|
|
return false; |
|
|
return false; |
|
|
@ -70,18 +57,23 @@ public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
operationLogDTO.setDescription("【"+ productLineEntity.getName()+"】"); |
|
|
operationLogDTO.setDescription("【"+ productLineEntity.getName()+"】"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (methodName.equals("batchDelete") && ObjectUtils.isNotEmpty(args) && args[0] instanceof String) { |
|
|
if (methodName.equals("batchDelete") && ObjectUtils.isNotEmpty(args) && args[0] instanceof String ids) { |
|
|
String ids = (String) args[0]; |
|
|
|
|
|
if (StringUtils.isBlank(ids)){ |
|
|
if (StringUtils.isBlank(ids)){ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
List<Long> idList = Arrays.asList(ids.split(",")).stream().map(id -> Long.valueOf(id)).collect(Collectors.toList()); |
|
|
List<Long> idList = Arrays.stream(ids.split(",")) |
|
|
List<InformationDTO> informationDTOList = informationApplicationService.selectBatchIds(idList); |
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
|
|
.map(Long::valueOf) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (idList.isEmpty()) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
List<InformationEntity> infoEntities = informationMapper.selectBatchIdsIncludeDeleted(idList); |
|
|
operationLogDTO.setAction(idList.size() == 1 ? "删除" : "批量删除"); |
|
|
operationLogDTO.setAction(idList.size() == 1 ? "删除" : "批量删除"); |
|
|
if (CollectionUtils.isEmpty(informationDTOList)){ |
|
|
if (CollectionUtils.isEmpty(infoEntities)){ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
String description = informationDTOList.stream() |
|
|
String description = infoEntities.stream() |
|
|
.map(informationDTO ->{ |
|
|
.map(informationDTO ->{ |
|
|
String taskName = Optional.ofNullable(informationDTO.getName()).orElse("未知文件"); |
|
|
String taskName = Optional.ofNullable(informationDTO.getName()).orElse("未知文件"); |
|
|
return "【" + informationDTO.getName() + "】"; |
|
|
return "【" + informationDTO.getName() + "】"; |
|
|
@ -97,4 +89,4 @@ public class DataDescriptionStrategy implements DescriptionStrategy { |
|
|
public String getStrategyName() { |
|
|
public String getStrategyName() { |
|
|
return ModuleEnum.DATA_MANAGEMENT.name(); |
|
|
return ModuleEnum.DATA_MANAGEMENT.name(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |