Browse Source

处理JSON问题

yuanliang 1 năm trước cách đây
mục cha
commit
94d7ad24a7

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

@@ -193,6 +193,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		paramDto.setPublishStatus(1);
 		paramDto.setPageSize(1000);
 		paramDto.setPageNum(1);
+		paramDto.setJson(JSON.toJSONString(paramDto));
 		List<PmsProductDto> productList = mallFeignService.getProductList(paramDto).getRows();
 		if(CollectionUtils.isEmpty(productList)){
 			throw new BizException("子商品不存在");
@@ -305,6 +306,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					.productIds(String.join(",", goodIdList))
 					.pageSize(9999)
 					.pageNum(1).build();
+			build.setJson(JSON.toJSONString(build));
 			Map<String, PmsProductDto> map = mallFeignService.getProductList(build)
 					.getRows().stream().collect(Collectors.toMap(next -> next.getGoodsId() + "_" + next.getSkuStockId(), Function.identity()));
 			goodsSubList.forEach(next -> {
@@ -870,6 +872,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 				.pageNum(query.getPage())
 				.pageSize(query.getRows())
 				.build();
+		dto.setJson(JSON.toJSONString(dto));
 		return mallFeignService.getProductList(dto);
 	}
 

+ 1 - 0
mec-client-api/src/main/java/com/ym/mec/mall/MallFeignService.java

@@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 @FeignClient(name = "${app-config.open-feign.mall-server.name:mall-server}",

+ 2 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/dto/PmsProductQueryParamDto.java

@@ -35,4 +35,6 @@ public class PmsProductQueryParamDto {
     private Integer pageSize;
 //    @NotNull(message = "页码不能为空")
     private Integer pageNum;
+
+    private String json;
 }

+ 3 - 1
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/controller/open/OpenController.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.admin.controller.open;
 
+import com.alibaba.fastjson.JSON;
 import com.ym.mec.common.dto.PmsProductDto;
 import com.ym.mec.common.dto.PmsProductQueryParamDto;
 import com.ym.mec.common.page.PageInfo;
@@ -76,7 +77,8 @@ public class OpenController {
     @PostMapping(value = "/product/list")
     @ResponseBody
     public PageInfo<PmsProductDto> getProductList(@RequestBody @Validated PmsProductQueryParamDto productQueryParam){
-
+        String json = productQueryParam.getJson();
+        productQueryParam = JSON.parseObject(json,PmsProductQueryParamDto.class);
         List<PmsProductDto> feignProductList = productService.getFeignProductList(productQueryParam);
         CommonPage<PmsProductDto> dtoCommonPage = CommonPage.restPage(feignProductList);
         PageInfo<PmsProductDto> pageInfo = new PageInfo<>();