Commit b1715557 by zhouhaibao

feat(sop): 添加商户信息到策略门店DTO

- 在SopStrategyStoreDTO中新增merchantId和merchantName字段
- 添加Apache Commons Collections依赖用于集合判空
- 优化StrategySopQueryService中的门店信息处理逻辑
- 当门店关系列表不为空时才进行数据转换操作
- 为每个门店DTO设置对应的商户ID和商户名称
- 确保数据安全性和避免空指针异常
1 parent 58a81f7a
...@@ -15,4 +15,12 @@ public class SopStrategyStoreDTO implements Serializable { ...@@ -15,4 +15,12 @@ public class SopStrategyStoreDTO implements Serializable {
@ApiModelProperty(notes = "门店编码") @ApiModelProperty(notes = "门店编码")
private String storeCode; private String storeCode;
@ApiModelProperty(value = "商户ID")
private Integer merchantId;
@ApiModelProperty(value = "商户名称")
private String merchantName;
} }
\ No newline at end of file \ No newline at end of file
...@@ -28,6 +28,7 @@ import com.github.pagehelper.Page; ...@@ -28,6 +28,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -108,10 +109,17 @@ public class StrategySopQueryService { ...@@ -108,10 +109,17 @@ public class StrategySopQueryService {
dto.setUpdatedTime(strategy.getUpdatedDate()); dto.setUpdatedTime(strategy.getUpdatedDate());
List<SopStrategyStoreRel> storeRels = sopStrategyStoreRelMapper.selectByStrategyId(strategy.getId()); List<SopStrategyStoreRel> storeRels = sopStrategyStoreRelMapper.selectByStrategyId(strategy.getId());
List<SopStrategyStoreDTO> storeDTOs = storeRels.stream() List<SopStrategyStoreDTO> storeDTOs= new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeRels)) {
storeDTOs = storeRels.stream()
.map(rel -> BeanUtil.copyProperties(rel, SopStrategyStoreDTO.class)) .map(rel -> BeanUtil.copyProperties(rel, SopStrategyStoreDTO.class))
.collect(Collectors.toList()); .collect(Collectors.toList());
for (SopStrategyStoreDTO storeDTO : storeDTOs) {
storeDTO.setMerchantId(storeDTO.getStoreId().intValue());
storeDTO.setMerchantName(storeDTO.getStoreName());
}
dto.setStoreIds(storeDTOs); dto.setStoreIds(storeDTOs);
}
dto.setStoreDescription(buildStoreDescription(strategy.getStoreScopeType(), storeDTOs)); dto.setStoreDescription(buildStoreDescription(strategy.getStoreScopeType(), storeDTOs));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!