Pārlūkot izejas kodu

商品分类返回

yuanliang 1 gadu atpakaļ
vecāks
revīzija
c0e97c0bf8

+ 4 - 0
mec-application/src/main/java/com/ym/mec/web/controller/GoodsController.java

@@ -14,6 +14,7 @@ import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dto.BrandDto;
+import com.ym.mec.common.dto.ProductAttributeCategoryDto;
 import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -126,8 +127,11 @@ public class GoodsController extends BaseController {
         List<Goods> rows = page.getRows();
         if (!rows.isEmpty()) {
             Map<String, String> brandIdNameMap = goodsService.queryGoodsBrandList().stream().collect(Collectors.toMap(next -> next.getId().toString(), BrandDto::getName));
+            Map<Integer, String> categoryIdNameMap = goodsService.queryGoodsCategoryList().stream().collect(Collectors.toMap(next -> next.getId().intValue(), ProductAttributeCategoryDto::getName));
+
             for (Goods row : rows) {
                 row.setBrandName(brandIdNameMap.getOrDefault(row.getBrand(), row.getBrand()));
+                row.setGoodsCategoryName(categoryIdNameMap.getOrDefault(row.getGoodsCategoryId(), ""));
             }
         }
         return succeed(page);

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.page.GoodsQueryInfo;
 import com.ym.mec.biz.dal.wrapper.GoodsWrapper;
 import com.ym.mec.common.dto.BrandDto;
 import com.ym.mec.common.dto.PmsProductDto;
+import com.ym.mec.common.dto.ProductAttributeCategoryDto;
 import com.ym.mec.common.dto.ProductCategoryDto;
 import com.ym.mec.common.entity.GoodsSubModel;
 import com.ym.mec.common.entity.GoodsSubStockModel;
@@ -159,5 +160,5 @@ public interface GoodsService extends BaseService<Integer, Goods> {
 
     List<BrandDto> queryGoodsBrandList();
 
-    Object queryGoodsCategoryList();
+    List<ProductAttributeCategoryDto> queryGoodsCategoryList();
 }

+ 4 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -39,6 +39,7 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dto.BrandDto;
 import com.ym.mec.common.dto.PmsProductDto;
 import com.ym.mec.common.dto.PmsProductQueryParamDto;
+import com.ym.mec.common.dto.ProductAttributeCategoryDto;
 import com.ym.mec.common.dto.ProductCategoryDto;
 import com.ym.mec.common.entity.GoodsSubModel;
 import com.ym.mec.common.entity.GoodsSubStockModel;
@@ -1073,8 +1074,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if(StringUtils.isNotEmpty(goods.getFreeFeeShowOrganId())){
 			goods.setFreeFeeShowOrganName(StringUtils.join(organizationDao.findByOrganIds(goods.getFreeFeeShowOrganId()),","));
 		}
-		GoodsWrapper.Goods detail = new GoodsWrapper.Goods();
-		BeanUtils.copyProperties(goods, detail);
+		GoodsWrapper.Goods detail = JSON.parseObject(JSON.toJSONString(goods), GoodsWrapper.Goods.class);
 		detail.setGoodsSubList(queryGoodsSub(goodsId));
 		return detail;
 	}
@@ -1101,8 +1101,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if (StringUtils.isEmpty(goodsInfo.getComplementGoodsIdList()) && goodsSubList.isEmpty()) {
 			throw new BizException("子商品信息不能为空");
 		}
+		goodsInfo = JSON.parseObject(JSON.toJSONString(goods), Goods.class);
 		goodsInfo.setStatus(null);
-		BeanUtils.copyProperties(goods, goodsInfo);
 		if (!goodsSubList.isEmpty()) {
 			goodsInfo.setComplementGoodsIdList(null);
 			UpdateWrapper<GoodsSub> delWrapper = new UpdateWrapper<>();
@@ -1215,7 +1215,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
-	public Object queryGoodsCategoryList() {
+	public List<ProductAttributeCategoryDto> queryGoodsCategoryList() {
 		return mallFeignService.getProductAttributeCategoryList();
 	}
 }

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -308,8 +308,9 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="Goods" parameterType="map">
-        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
-        LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_
+        SELECT g.* FROM goods g
+<!--        SELECT g.*,gc.name_ goods_category_name_ FROM goods g-->
+<!--        LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_-->
         <include refid="queryGoodsPageSql"/>
         GROUP BY g.id_
         ORDER BY g.id_ DESC