Authored by Lixiaodi

修改内部服务调用代理类

... ... @@ -47,7 +47,8 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve
* @param param 方法参数
* @return 返回值
*/
public Object call(String serviceMethod, Object... param) {
@SuppressWarnings("unchecked")
public <T> T call(String serviceMethod, Class<T> responseType, Object... param) {
logger.info("call ufo service : {}", serviceMethod);
ServiceMethod sm = serviceMap.get(serviceMethod);
if (sm == null) {
... ... @@ -55,7 +56,7 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve
}
try {
return sm.call(param);
return (T) sm.call(param);
} catch (Exception e) {
logger.error("service error : " + serviceMethod, e);
return null;
... ...
package com.yohoufo.product.controller;
import com.yoho.tools.docs.ApiOperation;
import com.yohoufo.common.utils.UfoJsonUtil;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
import com.yohoufo.product.response.StorageDataResp;
import com.yohoufo.product.response.StorageLeastPriceResp;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import com.yoho.tools.docs.ApiOperation;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.caller.UfoServiceCaller;
import org.springframework.web.bind.annotation.RestController;
import com.yohoufo.common.utils.UfoJsonUtil;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
import com.yohoufo.product.response.StorageDataResp;
import com.yohoufo.product.response.StorageLeastPriceResp;
@RestController
... ... @@ -113,11 +111,7 @@ public class ProductController {
@IgnoreSignature
@IgnoreSession
@RequestMapping(params = "method=ufo.product.createSkup")
public ApiResponse createSkup(
@RequestParam(value = "skup", required = false) Integer skup,
@RequestParam(value = "seller_uid", required = false) Integer sellerUid,
@RequestParam(value = "price", required = false) String price) {
public ApiResponse createSkup(@RequestBody StoragePriceBo skupBo) {
return new ApiResponse(200, "创建成功!", Boolean.TRUE);
}
... ... @@ -125,6 +119,7 @@ public class ProductController {
@IgnoreSession
@RequestMapping(params = "method=ufo.product.saleSkup")
public ApiResponse saleSkup(
@RequestParam(value = "product_id", required = false) Integer productId,
@RequestParam(value = "skup", required = false) Integer skup) {
return new ApiResponse(200, "卖出成功!", Boolean.TRUE);
}
... ... @@ -134,8 +129,8 @@ public class ProductController {
@RequestMapping(params = "method=ufo.product.cancelSaleSkup")
public ApiResponse cancelSaleSkup(
@RequestParam(value = "skup", required = false) Integer skup) {
serviceCaller.call("ufo.product.data", 99);
return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE);
ApiResponse resp = serviceCaller.call("ufo.product.data", ApiResponse.class ,99);
return new ApiResponse(200, "取消卖出成功!", resp);
}
}
\ No newline at end of file
... ...
package com.yohoufo.product.request;
import java.math.BigDecimal;
public class StoragePriceBo {
private Integer skup;
private Integer productId;
private Integer goodsId;
private Integer storageId;
private Integer depotNum;
private Integer sellerUid;
private BigDecimal price;
private Integer status;
private Integer updateTime;
private Integer createTime;
public Integer getProductId() {
return productId;
}
public void setProductId(Integer productId) {
this.productId = productId;
}
public Integer getGoodsId() {
return goodsId;
}
public void setGoodsId(Integer goodsId) {
this.goodsId = goodsId;
}
public Integer getStorageId() {
return storageId;
}
public void setStorageId(Integer storageId) {
this.storageId = storageId;
}
public Integer getDepotNum() {
return depotNum;
}
public void setDepotNum(Integer depotNum) {
this.depotNum = depotNum;
}
public Integer getSellerUid() {
return sellerUid;
}
public void setSellerUid(Integer sellerUid) {
this.sellerUid = sellerUid;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getSkup() {
return skup;
}
public void setSkup(Integer skup) {
this.skup = skup;
}
}
\ No newline at end of file
... ...