Commit b0673f13 by zhangxingmin

push

parent d408c720
......@@ -62,13 +62,22 @@ public class ApiSpeciesSettingServiceImpl implements ApiSpeciesSettingService {
@Override
public List<ApiSpeciesTypeDto> querySpeciesTypeDtoList(String productLaunchBizId) {
List<ApiSpeciesTypeDto> apiSpeciesTypeDtoList = new ArrayList<>();
List<SpeciesSetting> speciesSettingList = iSpeciesSettingService.queryList(SpeciesSettingDto.builder().productLaunchBizId(productLaunchBizId).build());
List<SpeciesSetting> speciesSettingList = iSpeciesSettingService
.queryList(SpeciesSettingDto.builder().productLaunchBizId(productLaunchBizId).build());
if (!CollectionUtils.isEmpty(speciesSettingList)) {
// 按规格类型分组
Map<String, List<SpeciesSetting>> speciesSettingByType = speciesSettingList.stream()
// 首先按ID排序
List<SpeciesSetting> sortedList = speciesSettingList.stream()
.sorted(Comparator.comparing(SpeciesSetting::getId))
.collect(Collectors.groupingBy(SpeciesSetting::getTypeName));
.collect(Collectors.toList());
// 使用LinkedHashMap保持插入顺序,按规格类型分组
Map<String, List<SpeciesSetting>> speciesSettingByType = new LinkedHashMap<>();
for (SpeciesSetting setting : sortedList) {
String typeName = setting.getTypeName();
speciesSettingByType.computeIfAbsent(typeName, k -> new ArrayList<>()).add(setting);
}
// 为每个规格类型创建DTO
apiSpeciesTypeDtoList = speciesSettingByType.entrySet().stream().map(entry -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment