From ee9cb0da4a43bcf523ebb157678f64a2895fba1a Mon Sep 17 00:00:00 2001 From: nickchange <126672920+nickchange@users.noreply.github.com> Date: 星期二, 10 十月 2023 15:30:38 +0800 Subject: [PATCH] 10.10 --- cloud-server-other/src/main/java/com/dsh/other/controller/SiteController.java | 110 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 97 insertions(+), 13 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 d701c3b..52181c6 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,13 +1,14 @@ package com.dsh.other.controller; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.TSite; import com.dsh.other.feignclient.account.CityManagerClient; -import com.dsh.other.feignclient.account.model.CityManager; import com.dsh.other.feignclient.activity.UserCouponClient; import com.dsh.other.feignclient.activity.model.QueryUserCouponByIdAndUserId; import com.dsh.other.feignclient.activity.model.UserCoupon; @@ -16,7 +17,6 @@ import com.dsh.other.feignclient.model.SiteVo; import com.dsh.other.model.*; import com.dsh.other.model.dto.siteDto.TSiteDTO; -import com.dsh.other.model.vo.questionVo.QuestionChangeStateVO; import com.dsh.other.model.vo.siteVo.ExpireSiteSearchVO; import com.dsh.other.model.vo.siteVo.SiteSearchVO; import com.dsh.other.service.ISiteBookingService; @@ -28,18 +28,15 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; 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 @@ -69,16 +66,28 @@ @Autowired private CityManagerClient cityManagerClient; - + /** + * 获取所有场地 + */ + @RequestMapping("/base/site/getList") + @ResponseBody + public List<Site> getList(){ + return siteService.list(new QueryWrapper<Site>().ne("state",3)); + } + /** + * 获取场地预约记录 + */ + @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); - } /** * 获取场地有效期在两个月内的场地列表 @@ -113,6 +122,33 @@ } } + + /** + * 添加场地管理 + * @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 = {"用户—预约场地"}) @@ -143,7 +179,6 @@ return ResultUtil.runErr(); } } - @@ -309,6 +344,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 @@ -324,6 +397,8 @@ if(null == uid){ return ResultUtil.tokenErr(); } + + return siteService.cancelMySite(uid, id); }catch (Exception e){ e.printStackTrace(); @@ -445,6 +520,15 @@ @ResponseBody + @PostMapping("/base/site/queryByCode") + public Integer queryByCode(@RequestBody String code){ + + return siteBookingService.queryByCode(code); + } + + + + @ResponseBody @PostMapping("/base/site/getNewAddSiteList") public List<SiteVo> getAppUserSiteList(){ List<SiteVo> siteVos = new ArrayList<>(); -- Gitblit v1.7.1