generated from root/miduo_server
测试发货
parent
3fd282d2dd
commit
6f3cbbdd1c
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form action="http://localhost:9992/delivery/test" method="post">
|
||||||
|
用 户 Id:<input type="text" name="userId"><br><br>
|
||||||
|
物 品 Id:<input type="text" name="itemId"><br><br>
|
||||||
|
物品数量:<input type="text" name="itemNum"><br><br>
|
||||||
|
<input type="submit" value="发送">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.jmfy.controller;
|
||||||
|
|
||||||
|
import com.jmfy.dto.JsonResult;
|
||||||
|
import com.jmfy.thrift.idl.RPCRequestIFace;
|
||||||
|
import com.jmfy.thrift.idl.Result;
|
||||||
|
import com.jmfy.thrift.pool.ClientAdapterPo;
|
||||||
|
import com.jmfy.thrift.pool.ServiceKey;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class TestController {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);
|
||||||
|
|
||||||
|
@RequestMapping(value = "/test")
|
||||||
|
public JsonResult deliveryGoods(HttpServletRequest request){
|
||||||
|
int userId = Integer.parseInt(request.getParameter("userId"));
|
||||||
|
int itemId = Integer.parseInt(request.getParameter("itemId"));
|
||||||
|
int itemNum = Integer.parseInt(request.getParameter("itemNum"));
|
||||||
|
|
||||||
|
//TODO 根据大区id和小区id从redis找到对应服的 IP和 Port
|
||||||
|
String ip = "127.0.0.1";
|
||||||
|
String port = "7900";
|
||||||
|
//TODO RPC 发货
|
||||||
|
Result result = null;
|
||||||
|
ClientAdapterPo<RPCRequestIFace.Client> rPCClient = null;
|
||||||
|
String serviceKey = getServiceKey(ServiceKey.RPCCore,ip,port);
|
||||||
|
try {
|
||||||
|
rPCClient = ClientAdapterPo.getClientAdapterPo(serviceKey);
|
||||||
|
result = rPCClient.getClient().TestdeliveryGood(userId,itemId,itemNum);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
rPCClient.returnObject(serviceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonResult jsonResult = new JsonResult();
|
||||||
|
jsonResult.setRet(result.getResultCode());
|
||||||
|
jsonResult.setMsg(result.getResultMsg());
|
||||||
|
return jsonResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getServiceKey(String serviceName, String host, String port) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
return sb.append(serviceName).append("|")
|
||||||
|
.append(host).append("|")
|
||||||
|
.append(port).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ struct Result {
|
||||||
|
|
||||||
service RPCRequestIFace{
|
service RPCRequestIFace{
|
||||||
|
|
||||||
Result deliveryGood(1:string openid, 2:i32 userId, 3:string payitem, 4:string billno, 5:string amt,
|
Result deliveryGood(1:string openid, 2:i32 userId, 3:string payitem, 4:string billno, 5:string amt,
|
||||||
6:string channel_id, 7:string token, 8:string serverOrder) throws (1:common.InvalidOperException ouch);
|
6:string channel_id, 7:string token, 8:string serverOrder) throws (1:common.InvalidOperException ouch);
|
||||||
|
Result TestdeliveryGood(1:i32 userId, 2:i32 itemId ,3:i32 itemNum) throws (1:common.InvalidOperException ouch);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue