From a1e4cfc3de4f3f3f3956b769bc7af40d097c8a4c Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期二, 17 十月 2023 15:12:57 +0800
Subject: [PATCH] 修改bug

---
 cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java |  100 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 88 insertions(+), 12 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 5c0343c..ff3ea1f 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,9 +1,11 @@
 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;
-import com.dsh.other.entity.SiteType;
+import com.dsh.other.entity.*;
 import com.dsh.other.feignclient.account.CityManagerClient;
 import com.dsh.other.feignclient.activity.UserCouponClient;
 import com.dsh.other.feignclient.activity.model.QueryUserCouponByIdAndUserId;
@@ -15,9 +17,7 @@
 import com.dsh.other.model.dto.siteDto.TSiteDTO;
 import com.dsh.other.model.vo.siteVo.ExpireSiteSearchVO;
 import com.dsh.other.model.vo.siteVo.SiteSearchVO;
-import com.dsh.other.service.ISiteBookingService;
-import com.dsh.other.service.ISiteService;
-import com.dsh.other.service.ISiteTypeService;
+import com.dsh.other.service.*;
 import com.dsh.other.util.PayMoneyUtil;
 import com.dsh.other.util.ResultUtil;
 import com.dsh.other.util.TokenUtil;
@@ -109,15 +109,43 @@
      * @return
      */
     @RequestMapping("/base/site/addSite")
-    public Object addSite(@RequestBody Site site){
+    public Integer addSite(@RequestBody Site site){
         if(site.getId()!= null ){
-
-            return siteService.updateById(site);
+            siteService.updateById(site);
+            return site.getId();
         }else {
-            return siteService.save(site);
+            boolean save = siteService.save(site);
+            return site.getId();
         }
     }
 
+
+    /**
+     * 添加场地管理
+     * @return
+     */
+    @RequestMapping("/base/site/addSiteBooking")
+    public Object addSiteBooking(@RequestBody SiteBooking siteBooking){
+        if(siteBooking.getId()!= null ){
+
+            return siteBookingService.updateById(siteBooking);
+        }else {
+            return siteBookingService.save(siteBooking);
+        }
+    }
+
+    @RequestMapping("/base/site/listById")
+    public Site listById(@RequestParam("id") Integer id){
+        Site byId = siteService.getById(id);
+        return byId;
+    }
+
+
+    @RequestMapping("/base/site/listBooks")
+    public  List<SiteBooking> listBooks(@RequestParam("id") Integer id){
+        List<SiteBooking> siteId = siteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id));
+        return siteId;
+    }
     @ResponseBody
     @PostMapping("/base/site/querySiteType")
     @ApiOperation(value = "获取场地类型", tags = {"用户—预约场地"})
@@ -320,14 +348,36 @@
             @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<SiteBooking> queryMySiteById(Integer id){
+    public ResultUtil<Map<String,Object>> queryMySiteById(Integer id){
         try {
+            HashMap<String, Object> map = new HashMap<>();
             SiteBooking byId = siteBookingService.getById(id);
-            return ResultUtil.success(byId);
+            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;
+
     }
 
 
@@ -467,6 +517,32 @@
 
 
     @ResponseBody
+    @PostMapping("/base/site/queryByCode")
+    public Integer queryByCode(@RequestBody String code){
+
+        return siteBookingService.queryByCode(code);
+    }
+
+
+    @Autowired
+   private StoreService service;
+
+    @Autowired
+    private IOperatorUserService operatorUserService;
+
+    @ResponseBody
+    @PostMapping("/base/site/queryOperator")
+    public OperatorUser queryOperator(@RequestBody List<Integer> stores){
+
+        Store one = service.getOne(new QueryWrapper<Store>().in("id", stores));
+        OperatorUser o = operatorUserService.getById(one.getOperatorId());
+
+        return o;
+    }
+
+
+
+    @ResponseBody
     @PostMapping("/base/site/getNewAddSiteList")
     public List<SiteVo> getAppUserSiteList(){
         List<SiteVo> siteVos = new ArrayList<>();

--
Gitblit v1.7.1