Commit 6bc7aba6 by tyfanchz

修改:直接使用 dubbo 服务调用商城接口

1 parent 14c9feb8
......@@ -61,5 +61,12 @@
<version>3.0.0-SNAPSHOT</version>
</dependency>
<!--商城接口 -->
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-platform-shopmall-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
</project>
......@@ -2,6 +2,9 @@ package com.glsx.admin.controller;
import javax.validation.groups.Default;
import java.util.List;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.platform.shopmall.dto.CreateMallGoodsRequestDTO;
import cn.com.glsx.platform.shopmall.remote.ShopMallGoodsRemote;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.exception.BusinessException;
......@@ -14,6 +17,7 @@ import com.glsx.admin.remote.ProductFeignClient;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -35,6 +39,9 @@ public class ProductController {
@Autowired
private ProductFeignClient productFeignClient;
@DubboReference(version = "1.0.0")
private ShopMallGoodsRemote shopMallGoodsRemote;
/**
* 分页获取产品列表。
*
......@@ -112,8 +119,15 @@ public class ProductController {
if (StringUtils.isBlank(req.getShopProductId())) {
throw new BusinessException(ResultEnum.PARAM_ERROR);
}
Boolean productIdValid = productFeignClient.checkShopProductId(req);
RpcResponse<CreateMallGoodsRequestDTO> rpcResponse = shopMallGoodsRemote
.selectOneById(Integer.valueOf(req.getShopProductId()));
log.info("$$$$ shopMallGoodsRemote.selectOneById response: {}",
JSON.toJSONString(rpcResponse));
boolean productIdValid = rpcResponse.isSuccess() && rpcResponse.getResult() != null;
return R.ok().data(productIdValid);
//Boolean productIdValid = productFeignClient.checkShopProductId(req);
//return R.ok().data(productIdValid);
}
/**
......
package com.glsx.admin.controller;
import javax.validation.groups.Default;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.platform.shopmall.model.PlatformMallGoodLabel;
import cn.com.glsx.platform.shopmall.remote.ShopMallLGoodLabelRemote;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.GroupA;
......@@ -14,6 +22,7 @@ import com.glsx.admin.remote.ProductContentFeignClient;
import com.glsx.admin.remote.ProductTypeFeignClient;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -21,12 +30,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.groups.Default;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* <p>Description:
* <p>Project: chejia-smart
......@@ -48,6 +51,9 @@ public class ProductTypeController {
@Autowired
private ProductContentFeignClient contentFeignClient;
@DubboReference(version = "1.0.0")
private ShopMallLGoodLabelRemote shopMallLGoodLabelRemote;
/**
* 分页获取产品类型列表。
*
......@@ -108,8 +114,18 @@ public class ProductTypeController {
@RequestMapping(value = "/getShopTagList", method = {RequestMethod.GET, RequestMethod.POST})
public R getShopTagList() {
log.info("$$$$ /productType/getShopTagList ...");
List<String> shopTagList = productTypeFeignClient.getShopTagList();
RpcResponse<List<PlatformMallGoodLabel>> rpcResponse = shopMallLGoodLabelRemote.queryAll();
log.info("$$$$ shopMallLGoodLabelRemote.queryAll response: {}",
JSON.toJSONString(rpcResponse));
List<String> shopTagList = new ArrayList<>();
List<PlatformMallGoodLabel> goodLabelList = rpcResponse.getResult();
if (rpcResponse.isSuccess() && goodLabelList != null) {
goodLabelList.forEach(item -> shopTagList.add(item.getLabelName()));
}
return R.ok().data(shopTagList);
//List<String> shopTagList = productTypeFeignClient.getShopTagList();
//return R.ok().data(shopTagList);
}
/**
......
......@@ -41,9 +41,9 @@ public interface ProductFeignClient {
@ResponseBody
List<DeviceOrderResp> getCommandSetById(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/checkShopProductId", method = {RequestMethod.GET})
@ResponseBody
Boolean checkShopProductId(@SpringQueryMap ProductReq req);
//@RequestMapping(value = "/product/checkShopProductId", method = {RequestMethod.GET})
//@ResponseBody
//Boolean checkShopProductId(@SpringQueryMap ProductReq req);
@RequestMapping(value = "/product/putOnOff", method = {RequestMethod.POST})
@ResponseBody
......
package com.glsx.admin.remote;
import java.util.List;
import com.github.pagehelper.PageInfo;
import com.glsx.admin.pojo.request.ProductTypeReq;
import com.glsx.admin.pojo.response.ProductTypeResp;
......@@ -10,8 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* <p>Description:
* <p>Project: chejia-smart
......@@ -37,9 +36,9 @@ public interface ProductTypeFeignClient {
@ResponseBody
Boolean save(@RequestBody ProductTypeReq req);
@RequestMapping(value = "/productType/getShopTagList", method = {RequestMethod.GET})
@ResponseBody
List<String> getShopTagList();
//@RequestMapping(value = "/productType/getShopTagList", method = {RequestMethod.GET})
//@ResponseBody
//List<String> getShopTagList();
@ResponseBody
@RequestMapping(value = "/productType/getListAndCondition", method = {RequestMethod.POST})
......
......@@ -21,6 +21,10 @@ feign.hystrix.enabled=true
dubbo.protocol.id=dubbo
dubbo.protocol.port=28213
dubbo.registry.address=zookeeper://192.168.1.36:2181?init.timeout=60000
dubbo.registry.timeout=10000
#dubbo.registry.address=zookeeper://192.168.1.36:2181?backup=192.168.3.206:2181&init.timeout=60000
#dubbo.registry.timeout=10000
dubbo.registries.biz-user.address=zookeeper://192.168.1.36:2181?init.timeout=60000
dubbo.registries.biz-user.timeout=10000
dubbo.registries.shopmall.address=zookeeper://192.168.3.206:2181?init.timeout=60000
dubbo.registries.shopmall.timeout=10000
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!