Browse Source

调整产品信息接口 返回 品牌品类系列名称

contract
15989082884@163.com 2 years ago
parent
commit
93b4c706c3
  1. 1
      src/main/java/com/qs/serve/modules/goods/controller/GoodsCategoryController.java
  2. 28
      src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java
  3. 26
      src/main/java/com/qs/serve/modules/goods/entity/GoodsCategory.java
  4. 18
      src/main/java/com/qs/serve/modules/tbs/entity/TbsActivityGoods.java

1
src/main/java/com/qs/serve/modules/goods/controller/GoodsCategoryController.java

@ -91,6 +91,7 @@ public class GoodsCategoryController {
categoryWrapper.eq(GoodsCategory::getEnable,1); categoryWrapper.eq(GoodsCategory::getEnable,1);
categoryWrapper.in(GoodsCategory::getId,param.getSelectIds()); categoryWrapper.in(GoodsCategory::getId,param.getSelectIds());
List<GoodsCategory> list = goodsCategoryService.list(categoryWrapper); List<GoodsCategory> list = goodsCategoryService.list(categoryWrapper);
list.forEach(GoodsCategory::initCategoryNameByPathsName);
// List<GoodsCategoryTreeVo> treeNodes = list.stream().map(cate->{ // List<GoodsCategoryTreeVo> treeNodes = list.stream().map(cate->{
// GoodsCategoryTreeVo treeNode = CopierUtil.copy(cate,new GoodsCategoryTreeVo()); // GoodsCategoryTreeVo treeNode = CopierUtil.copy(cate,new GoodsCategoryTreeVo());
// treeNode.setId(cate.getId()+""); // treeNode.setId(cate.getId()+"");

28
src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java

@ -9,18 +9,15 @@ import com.qs.serve.common.model.enums.BizType;
import com.qs.serve.common.model.enums.SystemModule; import com.qs.serve.common.model.enums.SystemModule;
import com.qs.serve.common.util.CollectionUtil; import com.qs.serve.common.util.CollectionUtil;
import com.qs.serve.common.util.PageUtil; import com.qs.serve.common.util.PageUtil;
import com.qs.serve.common.util.StringUtils;
import com.qs.serve.common.util.ValidateTools; import com.qs.serve.common.util.ValidateTools;
import com.qs.serve.modules.goods.entity.GoodsSku; import com.qs.serve.modules.goods.entity.*;
import com.qs.serve.modules.goods.entity.GoodsSkuSpecValue;
import com.qs.serve.modules.goods.entity.GoodsSpuSpec;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo; import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBo; import com.qs.serve.modules.goods.entity.bo.GoodsSpuBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuEditBo; import com.qs.serve.modules.goods.entity.bo.GoodsSpuEditBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuTasteBo; import com.qs.serve.modules.goods.entity.bo.GoodsSpuTasteBo;
import com.qs.serve.modules.goods.entity.vo.GoodsSpuVo; import com.qs.serve.modules.goods.entity.vo.GoodsSpuVo;
import com.qs.serve.modules.goods.service.GoodsSkuService; import com.qs.serve.modules.goods.service.*;
import com.qs.serve.modules.goods.service.GoodsSkuSpecValueService;
import com.qs.serve.modules.goods.service.GoodsSpuSpecService;
import com.qs.serve.modules.tbs.common.TbsGoodsType; import com.qs.serve.modules.tbs.common.TbsGoodsType;
import com.qs.serve.modules.tbs.entity.TbsActivityGoods; import com.qs.serve.modules.tbs.entity.TbsActivityGoods;
import com.qs.serve.modules.tbs.service.TbsActivityGoodsService; import com.qs.serve.modules.tbs.service.TbsActivityGoodsService;
@ -31,11 +28,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.qs.serve.modules.goods.entity.GoodsSpu;
import com.qs.serve.modules.goods.service.GoodsSpuService;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* 商品 spu * 商品 spu
@ -54,6 +49,7 @@ public class GoodsSpuController {
private GoodsSkuSpecValueService goodsSkuSpecValueService; private GoodsSkuSpecValueService goodsSkuSpecValueService;
private TbsActivityGoodsService activityGoodsService; private TbsActivityGoodsService activityGoodsService;
private TbsBudgetConditionService budgetConditionService; private TbsBudgetConditionService budgetConditionService;
private GoodsCategoryService goodsCategoryService;
/** /**
* 翻页搜索 * 翻页搜索
@ -91,6 +87,20 @@ public class GoodsSpuController {
} }
param.setShelf(1); param.setShelf(1);
List<GoodsSpu> list = goodsSpuService.selectSpuList(param); List<GoodsSpu> list = goodsSpuService.selectSpuList(param);
list.forEach(a->{
if(StringUtils.hasText(a.getCategoryFirst())){
GoodsCategory first = goodsCategoryService.getById(a.getCategoryFirst());
if (first!=null) a.setCateFirstLabel(first.getName());
}
if(StringUtils.hasText(a.getCategorySecond())){
GoodsCategory second = goodsCategoryService.getById(a.getCategorySecond());
if (second!=null) a.setCateSecondLabel(second.getName());
}
if(StringUtils.hasText(a.getCategoryThird())){
GoodsCategory third = goodsCategoryService.getById(a.getCategoryThird());
if (third!=null) a.setCateThirdLabel(third.getName());
}
});
return R.ok(list); return R.ok(list);
} }

26
src/main/java/com/qs/serve/modules/goods/entity/GoodsCategory.java

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.qs.serve.common.util.StringUtils;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
@ -105,5 +106,30 @@ public class GoodsCategory implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private List<Long> selectIds; private List<Long> selectIds;
@TableField(exist = false)
private String brandLabel;
@TableField(exist = false)
private String categoryLabel;
@TableField(exist = false)
private String seriseLabel;
public void initCategoryNameByPathsName(){
if(!StringUtils.hasText(this.levelPathNames)){
return;
}
String[] names = this.levelPathNames.split("_");
if(names.length==1){
this.brandLabel = names[0];
}else if(names.length==2){
this.brandLabel = names[0];
this.categoryLabel = names[1];
}else if(names.length >=3){
this.brandLabel = names[0];
this.categoryLabel = names[1];
this.seriseLabel = names[2];
}
}
} }

18
src/main/java/com/qs/serve/modules/tbs/entity/TbsActivityGoods.java

@ -114,13 +114,13 @@ public class TbsActivityGoods implements Serializable {
private String skuName; private String skuName;
@TableField(exist = false) @TableField(exist = false)
private String brandName; private String brandLabel;
@TableField(exist = false) @TableField(exist = false)
private String categoryName; private String categoryLabel;
@TableField(exist = false) @TableField(exist = false)
private String seriseName; private String seriseLabel;
public void initCategoryNameByPathsName(){ public void initCategoryNameByPathsName(){
if(!StringUtils.hasText(this.getTargetLevelPathNames())){ if(!StringUtils.hasText(this.getTargetLevelPathNames())){
@ -128,14 +128,14 @@ public class TbsActivityGoods implements Serializable {
} }
String[] names = this.getTargetLevelPathNames().split("_"); String[] names = this.getTargetLevelPathNames().split("_");
if(names.length==1){ if(names.length==1){
this.brandName = names[0]; this.brandLabel = names[0];
}else if(names.length==2){ }else if(names.length==2){
this.brandName = names[0]; this.brandLabel = names[0];
this.categoryName = names[1]; this.categoryLabel = names[1];
}else if(names.length >=3){ }else if(names.length >=3){
this.brandName = names[0]; this.brandLabel = names[0];
this.categoryName = names[1]; this.categoryLabel = names[1];
this.seriseName = names[2]; this.seriseLabel = names[2];
} }
} }

Loading…
Cancel
Save