feat(quotation): 添加区域名称字段并优化默认比率返回逻辑
- 在 DefaultRatioVO 中新增区域名称属性 areaName - PlanController 中处理多区域报价用户时,返回的对象包含区域名称 - 优化根据类别 ID 查询 DefaultRatioVO 时的代码结构,改为直接使用类别对象 - 确保返回的默认比率数据包含区域 ID 和名称信息,提高接口数据的完整性
This commit is contained in:
parent
dc4e3f04f1
commit
f783ef5b13
|
|
@ -76,22 +76,21 @@ public class PlanController extends ControllerBase {
|
||||||
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())
|
.eq(QuotationUserPlanDefault::getCreateById, AppUserUtil.getUserId())
|
||||||
.list();
|
.list();
|
||||||
if (isMultiRegionQuotationsUser()) {
|
if (isMultiRegionQuotationsUser()) {
|
||||||
List<Long> categoryIds = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory")
|
List<DictionaryItem> categories = dictionaryItemService.getListByDictionaryCode("DirectSalesCategory");
|
||||||
.stream()
|
|
||||||
.map(DictionaryItem::getId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
return ApiResult.success(
|
return ApiResult.success(
|
||||||
categoryIds.stream()
|
categories.stream()
|
||||||
.map(categoryId -> {
|
.map(category -> {
|
||||||
QuotationUserPlanDefault d = datas.stream()
|
QuotationUserPlanDefault d = datas.stream()
|
||||||
.filter(pd -> Objects.equals(pd.getAreaId(), categoryId))
|
.filter(pd -> Objects.equals(pd.getAreaId(), category.getId()))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (Objects.isNull(d)) {
|
if (Objects.isNull(d)) {
|
||||||
return new DefaultRatioVO()
|
return new DefaultRatioVO()
|
||||||
.setAreaId(categoryId);
|
.setAreaId(category.getId())
|
||||||
|
.setAreaName(category.getName());
|
||||||
} else {
|
} else {
|
||||||
return new DefaultRatioVO()
|
return new DefaultRatioVO()
|
||||||
|
.setAreaName(category.getName())
|
||||||
.setRatio(d.getRatio());
|
.setRatio(d.getRatio());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -105,11 +104,11 @@ public class PlanController extends ControllerBase {
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (Objects.isNull(d)) {
|
if (Objects.isNull(d)) {
|
||||||
return ApiResult.success(
|
return ApiResult.success(
|
||||||
List.of(new DefaultRatioVO().setAreaId(category.getId()))
|
List.of(new DefaultRatioVO().setAreaId(category.getId()).setAreaName(category.getName()))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ApiResult.success(
|
return ApiResult.success(
|
||||||
List.of(new DefaultRatioVO().setRatio(d.getRatio()))
|
List.of(new DefaultRatioVO().setRatio(d.getRatio()).setAreaName(category.getName()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,9 @@ public class DefaultRatioVO {
|
||||||
*/
|
*/
|
||||||
@NotNull(message = "区域不能为空")
|
@NotNull(message = "区域不能为空")
|
||||||
private Long areaId;
|
private Long areaId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域名称
|
||||||
|
*/
|
||||||
|
private String areaName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue