liujie
2023-09-28 f0f6bd6f7499d1fa737f705091337befb98f5112
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;
@@ -313,16 +317,38 @@
            @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;
    }
    @ResponseBody
    @PostMapping("/api/site/cancelMySite")