|
@@ -1,21 +1,17 @@
|
|
|
package cn.rankin.cmsweb.controller.product;
|
|
|
|
|
|
import cn.rankin.cmsweb.service.product.MerchantProductService;
|
|
|
-import cn.rankin.cmsweb.service.user.MerchantService;
|
|
|
+import cn.rankin.cmsweb.service.user.MerchantInfoSetService;
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
|
import cn.rankin.common.utils.util.BeanUtil;
|
|
|
import cn.rankin.data.api.product.dto.MerchantProductDTO;
|
|
|
import cn.rankin.data.api.product.dto.MerchantProductSearchDTO;
|
|
|
import cn.rankin.data.api.product.vo.MerchantProductVo;
|
|
|
-import cn.rankin.data.api.user.vo.MerchantVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/merchant/product")
|
|
@@ -25,34 +21,16 @@ public class MerchantProductController {
|
|
|
private MerchantProductService merchantProductService;
|
|
|
|
|
|
@Autowired
|
|
|
- private MerchantService merchantService;
|
|
|
+ private MerchantInfoSetService merchantInfoSetService;
|
|
|
|
|
|
@RequestMapping(method = RequestMethod.GET)
|
|
|
public APIResult<Page<MerchantProductVo>> search(MerchantProductSearchDTO searchDTO) {
|
|
|
- APIResult<Page<MerchantProductVo>> pageAPIResult = merchantProductService.search(BeanUtil.convertToMap(searchDTO));
|
|
|
- List<MerchantProductVo> merchantProductVoList = pageAPIResult.getData().getList();
|
|
|
- if (!CollectionUtils.isEmpty(merchantProductVoList)) {
|
|
|
- List<String> merchantIdList = new ArrayList<>();
|
|
|
- merchantProductVoList.forEach(merchantProductVo -> {
|
|
|
- String merchantId = merchantProductVo.getMerchantId();
|
|
|
- if (!merchantIdList.contains(merchantId)) {
|
|
|
- merchantIdList.add(merchantId);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- APIResult<Map<String, MerchantVo>> mapAPIResult = merchantService.findByIds(merchantIdList);
|
|
|
- Map<String, MerchantVo> merchantVoMap = mapAPIResult.getData();
|
|
|
- if (!CollectionUtils.isEmpty(merchantVoMap)) {
|
|
|
- for (MerchantProductVo merchantProductVo : merchantProductVoList) {
|
|
|
- String merchantId = merchantProductVo.getMerchantId();
|
|
|
- MerchantVo merchantVo = merchantVoMap.get(merchantId);
|
|
|
- if (merchantVo != null) {
|
|
|
- merchantProductVo.setMerchantName(merchantVo.getName());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ APIResult<Page<MerchantProductVo>> apiResult = merchantProductService.search(BeanUtil.convertToMap(searchDTO));
|
|
|
+ if (apiResult.getSuccess()) {
|
|
|
+ List<MerchantProductVo> merchantProductVoList = apiResult.getData().getList();
|
|
|
+ merchantInfoSetService.setMerchantInfo(merchantProductVoList);
|
|
|
}
|
|
|
- return pageAPIResult;
|
|
|
+ return apiResult;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|