Authored by Lixiaodi

修改错误

@@ -47,7 +47,7 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve @@ -47,7 +47,7 @@ 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 + public Object call(String serviceMethod, Object... param) {
51 logger.info("call ufo service : {}", serviceMethod); 51 logger.info("call ufo service : {}", serviceMethod);
52 ServiceMethod sm = serviceMap.get(serviceMethod); 52 ServiceMethod sm = serviceMap.get(serviceMethod);
53 if (sm == null) { 53 if (sm == null) {
@@ -84,15 +84,17 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve @@ -84,15 +84,17 @@ public class UfoServiceCaller implements ApplicationListener<ContextRefreshedEve
84 Method[] methods = ReflectionUtils.getAllDeclaredMethods(bean.getClass()); 84 Method[] methods = ReflectionUtils.getAllDeclaredMethods(bean.getClass());
85 for (Method method : methods) { 85 for (Method method : methods) {
86 RequestMapping method_requestMappingAnno = method.getAnnotation(RequestMapping.class); 86 RequestMapping method_requestMappingAnno = method.getAnnotation(RequestMapping.class);
  87 + if (method_requestMappingAnno != null) {
87 String[] params = method_requestMappingAnno.params(); 88 String[] params = method_requestMappingAnno.params();
88 String tag = "method="; 89 String tag = "method=";
89 - if (params != null && params.length == 1 && params[1].trim().startsWith(tag)) {  
90 - String methodStr = params[1].trim().substring(tag.length()); 90 + if (params != null && params.length == 1 && params[0].trim().startsWith(tag)) {
  91 + String methodStr = params[0].trim().substring(tag.length());
91 if (StringUtils.isNotBlank(methodStr)) { 92 if (StringUtils.isNotBlank(methodStr)) {
92 serviceMap.put(methodStr, new ServiceMethod(bean, method)); 93 serviceMap.put(methodStr, new ServiceMethod(bean, method));
93 } 94 }
94 } 95 }
95 } 96 }
  97 + }
96 logger.info("Register all ufo service for controller:{} success", bean); 98 logger.info("Register all ufo service for controller:{} success", bean);
97 } 99 }
98 } 100 }
@@ -6,14 +6,20 @@ import com.yohoufo.product.response.ProductDetailResp; @@ -6,14 +6,20 @@ import com.yohoufo.product.response.ProductDetailResp;
6 import com.yohoufo.product.response.ProductSeriesTemplateResp; 6 import com.yohoufo.product.response.ProductSeriesTemplateResp;
7 import com.yohoufo.product.response.StorageDataResp; 7 import com.yohoufo.product.response.StorageDataResp;
8 import com.yohoufo.product.response.StorageLeastPriceResp; 8 import com.yohoufo.product.response.StorageLeastPriceResp;
  9 +
  10 +import javax.annotation.Resource;
  11 +
9 import org.slf4j.Logger; 12 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.web.bind.annotation.RequestMapping; 15 import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.RequestParam; 16 import org.springframework.web.bind.annotation.RequestParam;
13 17
14 import com.yohoufo.common.ApiResponse; 18 import com.yohoufo.common.ApiResponse;
15 import com.yohoufo.common.annotation.IgnoreSession; 19 import com.yohoufo.common.annotation.IgnoreSession;
16 import com.yohoufo.common.annotation.IgnoreSignature; 20 import com.yohoufo.common.annotation.IgnoreSignature;
  21 +import com.yohoufo.common.caller.UfoServiceCaller;
  22 +
17 import org.springframework.web.bind.annotation.RestController; 23 import org.springframework.web.bind.annotation.RestController;
18 24
19 25
@@ -22,6 +28,9 @@ public class ProductController { @@ -22,6 +28,9 @@ public class ProductController {
22 28
23 private final Logger LOG = LoggerFactory.getLogger(ProductController.class); 29 private final Logger LOG = LoggerFactory.getLogger(ProductController.class);
24 30
  31 + @Autowired
  32 + UfoServiceCaller serviceCaller;
  33 +
25 @ApiOperation(name = "ufo.product.data", desc="商品详情") 34 @ApiOperation(name = "ufo.product.data", desc="商品详情")
26 @IgnoreSignature 35 @IgnoreSignature
27 @IgnoreSession 36 @IgnoreSession
@@ -125,6 +134,7 @@ public class ProductController { @@ -125,6 +134,7 @@ public class ProductController {
125 @RequestMapping(params = "method=ufo.product.cancelSaleSkup") 134 @RequestMapping(params = "method=ufo.product.cancelSaleSkup")
126 public ApiResponse cancelSaleSkup( 135 public ApiResponse cancelSaleSkup(
127 @RequestParam(value = "skup", required = false) Integer skup) { 136 @RequestParam(value = "skup", required = false) Integer skup) {
  137 + serviceCaller.call("ufo.product.data", 99);
128 return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE); 138 return new ApiResponse(200, "取消卖出成功!", Boolean.TRUE);
129 } 139 }
130 140