Authored by Lixiaodi

修改内部服务调用代理类

@@ -47,7 +47,8 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve @@ -47,7 +47,8 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve
47 * @param param 方法参数 47 * @param param 方法参数
48 * @return 返回值 48 * @return 返回值
49 */ 49 */
50 - public Object call(String serviceMethod, Object... param) { 50 + @SuppressWarnings("unchecked")
  51 + public <T> T call(String serviceMethod, Class<T> responseType, Object... param) {
51 logger.info("call ufo service : {}", serviceMethod); 52 logger.info("call ufo service : {}", serviceMethod);
52 ServiceMethod sm = serviceMap.get(serviceMethod); 53 ServiceMethod sm = serviceMap.get(serviceMethod);
53 if (sm == null) { 54 if (sm == null) {
@@ -55,7 +56,7 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve @@ -55,7 +56,7 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve
55 } 56 }
56 57
57 try { 58 try {
58 - return sm.call(param); 59 + return (T) sm.call(param);
59 } catch (Exception e) { 60 } catch (Exception e) {
60 logger.error("service error : " + serviceMethod, e); 61 logger.error("service error : " + serviceMethod, e);
61 return null; 62 return null;
1 package com.yohoufo.product.controller; 1 package com.yohoufo.product.controller;
2 2
3 -import com.yoho.tools.docs.ApiOperation;  
4 -import com.yohoufo.common.utils.UfoJsonUtil;  
5 -import com.yohoufo.product.response.ProductDetailResp;  
6 -import com.yohoufo.product.response.ProductSeriesTemplateResp;  
7 -import com.yohoufo.product.response.StorageDataResp;  
8 -import com.yohoufo.product.response.StorageLeastPriceResp;  
9 -  
10 -import javax.annotation.Resource;  
11 -  
12 import org.slf4j.Logger; 3 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 4 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 5 import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.web.bind.annotation.RequestBody;
15 import org.springframework.web.bind.annotation.RequestMapping; 7 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RequestParam; 8 import org.springframework.web.bind.annotation.RequestParam;
  9 +import org.springframework.web.bind.annotation.RestController;
17 10
  11 +import com.yoho.tools.docs.ApiOperation;
18 import com.yohoufo.common.ApiResponse; 12 import com.yohoufo.common.ApiResponse;
19 import com.yohoufo.common.annotation.IgnoreSession; 13 import com.yohoufo.common.annotation.IgnoreSession;
20 import com.yohoufo.common.annotation.IgnoreSignature; 14 import com.yohoufo.common.annotation.IgnoreSignature;
21 import com.yohoufo.common.caller.UfoServiceCaller; 15 import com.yohoufo.common.caller.UfoServiceCaller;
22 -  
23 -import org.springframework.web.bind.annotation.RestController; 16 +import com.yohoufo.common.utils.UfoJsonUtil;
  17 +import com.yohoufo.product.request.StoragePriceBo;
  18 +import com.yohoufo.product.response.ProductDetailResp;
  19 +import com.yohoufo.product.response.ProductSeriesTemplateResp;
  20 +import com.yohoufo.product.response.StorageDataResp;
  21 +import com.yohoufo.product.response.StorageLeastPriceResp;
24 22
25 23
26 @RestController 24 @RestController
@@ -113,11 +111,7 @@ public class ProductController { @@ -113,11 +111,7 @@ public class ProductController {
113 @IgnoreSignature 111 @IgnoreSignature
114 @IgnoreSession 112 @IgnoreSession
115 @RequestMapping(params = "method=ufo.product.createSkup") 113 @RequestMapping(params = "method=ufo.product.createSkup")
116 - public ApiResponse createSkup(  
117 - @RequestParam(value = "skup", required = false) Integer skup,  
118 - @RequestParam(value = "seller_uid", required = false) Integer sellerUid,  
119 - @RequestParam(value = "price", required = false) String price) {  
120 - 114 + public ApiResponse createSkup(@RequestBody StoragePriceBo skupBo) {
121 return new ApiResponse(200, "创建成功!", Boolean.TRUE); 115 return new ApiResponse(200, "创建成功!", Boolean.TRUE);
122 } 116 }
123 117
@@ -125,6 +119,7 @@ public class ProductController { @@ -125,6 +119,7 @@ public class ProductController {
125 @IgnoreSession 119 @IgnoreSession
126 @RequestMapping(params = "method=ufo.product.saleSkup") 120 @RequestMapping(params = "method=ufo.product.saleSkup")
127 public ApiResponse saleSkup( 121 public ApiResponse saleSkup(
  122 + @RequestParam(value = "product_id", required = false) Integer productId,
128 @RequestParam(value = "skup", required = false) Integer skup) { 123 @RequestParam(value = "skup", required = false) Integer skup) {
129 return new ApiResponse(200, "卖出成功!", Boolean.TRUE); 124 return new ApiResponse(200, "卖出成功!", Boolean.TRUE);
130 } 125 }
@@ -134,8 +129,8 @@ public class ProductController { @@ -134,8 +129,8 @@ public class ProductController {
134 @RequestMapping(params = "method=ufo.product.cancelSaleSkup") 129 @RequestMapping(params = "method=ufo.product.cancelSaleSkup")
135 public ApiResponse cancelSaleSkup( 130 public ApiResponse cancelSaleSkup(
136 @RequestParam(value = "skup", required = false) Integer skup) { 131 @RequestParam(value = "skup", required = false) Integer skup) {
137 - serviceCaller.call("ufo.product.data", 99);  
138 - return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE); 132 + ApiResponse resp = serviceCaller.call("ufo.product.data", ApiResponse.class ,99);
  133 + return new ApiResponse(200, "取消卖出成功!", resp);
139 } 134 }
140 135
141 } 136 }
  1 +package com.yohoufo.product.request;
  2 +
  3 +import java.math.BigDecimal;
  4 +
  5 +public class StoragePriceBo {
  6 +
  7 + private Integer skup;
  8 +
  9 + private Integer productId;
  10 +
  11 + private Integer goodsId;
  12 +
  13 + private Integer storageId;
  14 +
  15 + private Integer depotNum;
  16 +
  17 + private Integer sellerUid;
  18 +
  19 + private BigDecimal price;
  20 +
  21 + private Integer status;
  22 +
  23 + private Integer updateTime;
  24 +
  25 + private Integer createTime;
  26 +
  27 + public Integer getProductId() {
  28 + return productId;
  29 + }
  30 +
  31 + public void setProductId(Integer productId) {
  32 + this.productId = productId;
  33 + }
  34 +
  35 + public Integer getGoodsId() {
  36 + return goodsId;
  37 + }
  38 +
  39 + public void setGoodsId(Integer goodsId) {
  40 + this.goodsId = goodsId;
  41 + }
  42 +
  43 + public Integer getStorageId() {
  44 + return storageId;
  45 + }
  46 +
  47 + public void setStorageId(Integer storageId) {
  48 + this.storageId = storageId;
  49 + }
  50 +
  51 + public Integer getDepotNum() {
  52 + return depotNum;
  53 + }
  54 +
  55 + public void setDepotNum(Integer depotNum) {
  56 + this.depotNum = depotNum;
  57 + }
  58 +
  59 + public Integer getSellerUid() {
  60 + return sellerUid;
  61 + }
  62 +
  63 + public void setSellerUid(Integer sellerUid) {
  64 + this.sellerUid = sellerUid;
  65 + }
  66 +
  67 + public BigDecimal getPrice() {
  68 + return price;
  69 + }
  70 +
  71 + public void setPrice(BigDecimal price) {
  72 + this.price = price;
  73 + }
  74 +
  75 + public Integer getStatus() {
  76 + return status;
  77 + }
  78 +
  79 + public void setStatus(Integer status) {
  80 + this.status = status;
  81 + }
  82 +
  83 + public Integer getUpdateTime() {
  84 + return updateTime;
  85 + }
  86 +
  87 + public void setUpdateTime(Integer updateTime) {
  88 + this.updateTime = updateTime;
  89 + }
  90 +
  91 + public Integer getCreateTime() {
  92 + return createTime;
  93 + }
  94 +
  95 + public void setCreateTime(Integer createTime) {
  96 + this.createTime = createTime;
  97 + }
  98 +
  99 + public Integer getSkup() {
  100 + return skup;
  101 + }
  102 +
  103 + public void setSkup(Integer skup) {
  104 + this.skup = skup;
  105 + }
  106 +}