소스 검색

秋香api

gongfuzhu 11 달 전
부모
커밋
50c1c36e67

+ 11 - 13
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/api/qiuxiang/QiuXiangApi.java

@@ -128,8 +128,8 @@ public class QiuXiangApi {
      * @param orderRequest 下单请求参数
      * @return 订单信息,包含订单ID
      */
-    public String placeOrder(String token, OrderRequest orderRequest) {
-        String url = BASE_URL + "/user/order";
+    public JSONObject placeOrder(OrderRequest orderRequest) {
+        String url = "/user/order";
 
         JSONObject body = new JSONObject();
         body.put("adcode", orderRequest.getAdcode());
@@ -146,8 +146,7 @@ public class QiuXiangApi {
         }
 
         String result = postRequest(url, body.toString());
-        JSONObject json = new JSONObject(result);
-        return json.toString();
+        return new JSONObject(result);
     }
 
     /**
@@ -158,9 +157,9 @@ public class QiuXiangApi {
      * @param count
      * @return
      */
-    public JSONArray orderList(String lastOrderId, int count) {
+    public JSONArray orderList(String lastOrderId, String count) {
         String url = "/user/order/list";
-        Map<String, String> orderId1 = Map.of("lastOrderId", lastOrderId, "count", String.valueOf(count));
+        Map<String, String> orderId1 = Map.of("lastOrderId", lastOrderId, "count",count);
         String request = getRequest(url, orderId1);
 
 
@@ -208,10 +207,9 @@ public class QiuXiangApi {
      * @param orderId
      * @return
      */
-    public JSONObject driverLocation(String token, String orderId) {
+    public JSONObject driverLocation( String orderId) {
         String url = "/user/order/driver/location";
         String request = getRequest(url, Map.of("orderId", orderId));
-
         return new JSONObject(request);
     }
 
@@ -229,8 +227,8 @@ public class QiuXiangApi {
     }
 
     private String getRequest(String url, Map<String, String> params) {
-//        String phone = authHelper.getCurrentUser().getPhone();
-        String token = loginUser("13368172379");
+        String phone = authHelper.getCurrentUser().getPhone();
+        String token = loginUser(phone);
         String result = HttpRequest.get(BASE_URL + url)
                 .header("Token", token)
                 .formStr(params)
@@ -245,8 +243,8 @@ public class QiuXiangApi {
     }
 
     private String deleteRequest(String url, String jsonString) {
-//        String phone = authHelper.getCurrentUser().getPhone();
-        String token = loginUser("13368172379");
+        String phone = authHelper.getCurrentUser().getPhone();
+        String token = loginUser(phone);
         String result = HttpRequest.delete(BASE_URL + url)
                 .header("Token", token)
                 .body(jsonString)
@@ -263,7 +261,7 @@ public class QiuXiangApi {
 
     private String postRequest(String url, String jsonString) {
         String phone = authHelper.getCurrentUser().getPhone();
-        String token = loginUser("13368172379");
+        String token = loginUser(phone);
         String result = HttpRequest.post(url)
                 .header("Token", token)
                 .body(jsonString)

+ 72 - 0
SpringBatchServiceServer/src/main/java/com/zswl/cloud/springBtach/server/core/controller/QiuXiangController.java

@@ -0,0 +1,72 @@
+package com.zswl.cloud.springBtach.server.core.controller;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import com.github.microservice.auth.client.content.ResultContent;
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.zswl.cloud.springBatch.client.model.qiuxiang.OrderRequest;
+import com.zswl.cloud.springBtach.server.core.api.qiuxiang.QiuXiangApi;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+@Log4j2
+@RestController
+@RequestMapping("qx")
+public class QiuXiangController {
+
+    @Autowired
+    QiuXiangApi qiuXiangApi;
+
+    @ApiOperation("下单")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "addOrder", method = RequestMethod.POST)
+    public ResultContent placeOrder(@RequestBody OrderRequest orderRequest) {
+        JSONObject entries = qiuXiangApi.placeOrder(orderRequest);
+        return ResultContent.buildContent(entries);
+    }
+
+    @ApiOperation("获取订单列表")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "orderList", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
+    public ResultContent orderList(@RequestBody Map<String, String> orderRequest) {
+
+        JSONArray objects = qiuXiangApi.orderList(orderRequest.get("lastOrderId"), orderRequest.get("count"));
+        return ResultContent.buildContent(objects);
+    }
+
+    @ApiOperation("订单详情")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "orderDelit", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
+    public ResultContent orderDelit(@RequestBody Map<String, String> orderRequest) {
+
+        return ResultContent.buildContent(qiuXiangApi.orderDelit(orderRequest.get("orderId")));
+    }
+
+    @ApiOperation("取消订单")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "cancelOrder", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
+    public ResultContent cancelOrder(@RequestBody Map<String, String> orderRequest) {
+
+        return ResultContent.buildContent(qiuXiangApi.cancelOrder(orderRequest.get("orderId"), orderRequest.get("reason")));
+    }
+
+    @ApiOperation("获取司机位置")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "driverLocation", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
+    public ResultContent driverLocation(@RequestBody Map<String, String> orderRequest) {
+        return ResultContent.buildContent(qiuXiangApi.driverLocation(orderRequest.get("orderId")));
+    }
+    @ApiOperation("获取司机行驶轨迹")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @RequestMapping(value = "driverLocation", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
+    public ResultContent driverLocationLog(@RequestBody Map<String, String> orderRequest) {
+        return ResultContent.buildContent(qiuXiangApi.driverLocationLog(orderRequest.get("orderId")));
+    }
+
+}