From f0f6bd6f7499d1fa737f705091337befb98f5112 Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期四, 28 九月 2023 18:33:31 +0800
Subject: [PATCH] 后台

---
 cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
index 9d8a468..8b391ea 100644
--- a/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
+++ b/cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java
@@ -1,5 +1,9 @@
 package com.dsh.other.controller;
 
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.dsh.other.entity.Site;
 import com.dsh.other.entity.SiteBooking;
@@ -32,10 +36,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author zhibing.pu
@@ -67,14 +68,19 @@
 
 
     /**
+     * 获取场地预约记录
+     */
+    @RequestMapping("/base/site/listAll")
+    public List<SiteBooking> listAll(@RequestBody SiteBookingQuery query){
+        return siteBookingService.listAll(query);
+    }
+    /**
      * 获取所有场地
      * @return
      */
     @RequestMapping("/base/site/list")
     public List<TSiteDTO> listAll(@RequestBody SiteSearchVO vo){
-
         return siteTypeService.listAll(vo);
-
     }
     /**
      * 获取场地有效期在两个月内的场地列表
@@ -304,6 +310,44 @@
             return ResultUtil.runErr();
         }
     }
+    @ResponseBody
+    @PostMapping("/api/site/queryMySiteById")
+    @ApiOperation(value = "获取我的预约场地列表详情2.0", tags = {"用户—预约场地"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(value = "id", name = "id", dataType = "int", required = true),
+            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
+    })
+    public ResultUtil<Map<String,Object>> queryMySiteById(Integer id){
+        try {
+            HashMap<String, Object> map = new HashMap<>();
+            SiteBooking byId = siteBookingService.getById(id);
+            List<Integer> ids = getIds(byId.getSiteId());
+            map.put("data",byId);
+            map.put("ids",ids);
+            return ResultUtil.success(map);
+        }catch (Exception e){
+            e.printStackTrace();
+            return ResultUtil.runErr();
+        }
+    }
+
+    public List<Integer>  getIds(Integer siteId) {
+        HttpRequest httpRequest = HttpRequest.get("https://try.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId);
+        HttpResponse execute = httpRequest.execute();
+        String body = execute.body();
+        JSONObject jsonObject = JSONObject.parseObject(body);
+        Object data = jsonObject.get("data");
+        JSONArray array = JSONArray.parseArray(data.toString());
+        List<Integer> ids =new ArrayList<>();
+        for (Object o : array) {
+            JSONObject jsonObject1 = JSONObject.parseObject(o.toString());
+            Object id = jsonObject1.get("id");
+            Integer integer = Integer.valueOf(id.toString());
+            ids.add(integer);
+        }
+        return ids;
+
+    }
 
 
     @ResponseBody

--
Gitblit v1.7.1