|
@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.chelvc.cloud.uc.api.model.Scope;
|
|
|
import com.chelvc.cloud.vehicle.api.constant.CategoryType;
|
|
|
import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.CategoryDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.GoodsDetailDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.MerchantDetailDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.param.CommentQueryParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.GoodsModifyParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.GoodsPagingParam;
|
|
@@ -34,8 +36,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.validation.constraints.NotEmpty;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 商品业务操作实现
|
|
@@ -162,4 +167,30 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
public void updateGoodsStatus(@NotEmpty List<Long> ids, @NonNull GoodsStatus status) {
|
|
|
this.lambdaUpdate().set(Goods::getStatus, status).in(Goods::getId, ids).update();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String,Object> getCategoryAndGoods(GoodsQueryParam param){
|
|
|
+ Map<String,Object> goodsMap = new HashMap<>();
|
|
|
+ List<Goods> goods = this.lambdaQuery()
|
|
|
+ .like(StringUtils.notEmpty(param.getGoodsName()),Goods::getName,param.getGoodsName())
|
|
|
+ .eq(StringUtils.notEmpty(param.getCategoryId()),Goods::getCategoryId,param.getCategoryId())
|
|
|
+ .eq(StringUtils.notEmpty(param.getStatus()),Goods::getStatus,param.getStatus())
|
|
|
+ .eq(StringUtils.notEmpty(param.getMerchantId()),Goods::getMerchantId,param.getMerchantId())
|
|
|
+ .orderByDesc(Goods::getId)
|
|
|
+ .list();
|
|
|
+ List<GoodsDTO> goodsList = GoodsCopier.INSTANCE.copying(goods);
|
|
|
+ if (goodsList == null && goodsList.size() < 1 ){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ goodsMap.put("goodsList",goodsList);
|
|
|
+ List<Long> idSet = goodsList.stream()
|
|
|
+ .map(GoodsDTO::getCategoryId) // 将每个Person对象映射到其id
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!idSet.isEmpty()) {
|
|
|
+ List<CategoryDTO> categories = this.categoryService.listCategories(idSet);
|
|
|
+ goodsMap.put("categories",categories);
|
|
|
+ }
|
|
|
+ return goodsMap;
|
|
|
+ }
|
|
|
}
|