Преглед изворни кода

feat(app): 新增场地列表查询功能

- 新增场地列表查询接口和相关服务
- 实现场地信息分页查询和筛选功能
- 添加场地详情和距离计算逻辑
SheepHy пре 3 недеља
родитељ
комит
1baa95b461

+ 17 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/AppHomeController.java

@@ -1,19 +1,19 @@
 package org.jeecg.modules.app.controller;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.app.dto.GetPlaceListDTO;
 import org.jeecg.modules.app.service.IAppHomeService;
 import org.jeecg.modules.app.service.IUserService;
 import org.jeecg.modules.app.vo.HomeVO;
 import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.jeecg.modules.app.vo.PlaceVO;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -57,4 +57,17 @@ public class AppHomeController {
     public Result<MsgInfoVO> getMsgInfo(@RequestParam(required = false) @Schema(description = "消息ID") String id){
         return Result.ok(userService.getMsgInfo(id));
     }
+
+    /**
+     * @Author SheepHy
+     * @Description 场地列表查询
+     * @Date 10:37 2025/7/4
+     * @Param
+     * @return
+     **/
+    @PostMapping("/getPlaceList")
+    @Operation(summary = "场地列表查询")
+    public Result<Page<PlaceVO>> getPlaceList(@RequestBody GetPlaceListDTO getPlaceListDTO){
+        return Result.ok(userService.getPlaceList(getPlaceListDTO));
+    }
 }

+ 35 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/CommonAppController.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.app.controller;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.vo.DictModel;
+import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Slf4j
+@Tag(name = "App公共相关接口")
+@RestController
+@RequestMapping("/app/common")
+public class CommonAppController {
+    @Resource
+    private SysBaseApiImpl sysBaseApi;
+    /**
+     * 根据字典code查询字典项
+     *
+     * @param dictCode 顺序:tableName,text,code
+     * @param dictCode 要查询的key
+     * @return
+     */
+    @Operation(description="根据字典code查询字典项")
+    @GetMapping("/getDictItems")
+    public List<DictModel> getDictItems(@RequestParam("dictCode") String dictCode) {
+        return sysBaseApi.getDictItems(dictCode);
+    }
+}

+ 25 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/dto/GetPlaceListDTO.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.app.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="场地分页查询入参DTO")
+public class GetPlaceListDTO {
+    @Schema(description ="页码")
+    private long size;
+    @Schema(description ="当前页")
+    private long current;
+    @Schema(description ="筛选类型")
+    private String venueType;
+    @Schema(description ="经度")
+    private double longitude;
+    @Schema(description ="纬度")
+    private double latitude;
+
+
+}

+ 13 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/IUserService.java

@@ -1,8 +1,11 @@
 package org.jeecg.modules.app.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.jeecg.modules.app.dto.GetPlaceListDTO;
 import org.jeecg.modules.app.vo.LoginUserVO;
 import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
+import org.jeecg.modules.app.vo.PlaceVO;
 
 import java.util.List;
 
@@ -33,4 +36,14 @@ public interface IUserService {
      * @return MsgInfoVO {@link MsgInfoVO}
      **/
     MsgInfoVO getMsgInfo(String id);
+
+    /**
+     * @Author SheepHy
+     * @Description 场地列表查询
+     * @Date 10:37 2025/7/4
+     * @Param
+     * @return
+     **/
+    Page<PlaceVO> getPlaceList(GetPlaceListDTO getPlaceListDTO);
+
 }

+ 40 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/UserServiceImpl.java

@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
 import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.log4j.Log4j2;
 import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.shiro.SecurityUtils;
@@ -11,10 +12,14 @@ import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.RedisUtil;
+import org.jeecg.modules.app.dto.GetPlaceListDTO;
 import org.jeecg.modules.app.service.IUserService;
 import org.jeecg.modules.app.vo.LoginUserVO;
 import org.jeecg.modules.app.vo.MsgInfoVO;
 import org.jeecg.modules.app.vo.MsgVO;
+import org.jeecg.modules.app.vo.PlaceVO;
+import org.jeecg.modules.system.app.mapper.AppCategoryMapper;
+import org.jeecg.modules.system.app.mapper.AppSiteMapper;
 import org.jeecg.modules.system.entity.SysAnnouncement;
 import org.jeecg.modules.system.entity.SysAnnouncementSend;
 import org.jeecg.modules.system.entity.SysUser;
@@ -22,11 +27,11 @@ import org.jeecg.modules.system.mapper.SysAnnouncementMapper;
 import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
 import org.jeecg.modules.system.mapper.SysUserMapper;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import static org.jeecg.common.constant.CommonConstant.PREFIX_USER_TOKEN;
@@ -43,7 +48,11 @@ public class UserServiceImpl implements IUserService {
     private SysAnnouncementSendMapper sysAnnouncementSendMapper;
     @Resource
     private SysAnnouncementMapper sysAnnouncementMapper;
-    @Autowired
+    @Resource
+    private AppSiteMapper appSiteMapper;
+    @Resource
+    private AppCategoryMapper appCategoryMapper;
+    @Resource
     private RedisUtil redisUtil;
 
     @Override
@@ -101,6 +110,35 @@ public class UserServiceImpl implements IUserService {
         return msgInfoVO;
     }
 
+    @Override
+    public Page<PlaceVO> getPlaceList(GetPlaceListDTO getPlaceListDTO) {
+        Page<PlaceVO> page = new Page<>(getPlaceListDTO.getCurrent(), getPlaceListDTO.getSize());
+        Page<PlaceVO> placeList = appSiteMapper.getPlaceList(page, getPlaceListDTO.getVenueType());
+        placeList.getRecords().forEach(placeVO -> {
+            List<String> list = new ArrayList<>();
+            String[] split = placeVO.getCategoryId().split(",");
+            Arrays.stream(split).forEach(id -> {
+                list.add(appCategoryMapper.selectById(id).getName());
+            });
+            //todo 待申请第三方地图接口
+            placeVO.setKm(0.0)
+                    .setCategory(list);
+        });
+        if(getPlaceListDTO.getVenueType().equals("1")
+                || getPlaceListDTO.getVenueType().equals("2")
+                || getPlaceListDTO.getVenueType().equals("3")){
+            // 按 km 升序排序(从近到远)
+            placeList.getRecords().sort((p1, p2) -> {
+                Double km1 = p1.getKm();
+                Double km2 = p2.getKm();
+                return km1.compareTo(km2);
+            });
+        }
+        return placeList;
+    }
+
+
+
     private LoginUserVO generateLoginUserVO(SysUser user) {
         String orgCode = user.getOrgCode().substring(0, 3);
         String userAccount = "";

+ 36 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/vo/PlaceVO.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.app.vo;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@Schema(description="场地分页返回参数")
+public class PlaceVO extends Page<PlaceVO> {
+    @Schema(description = "id")
+    private String id;
+    @Schema(description = "场地名称")
+    private String name;
+    @Schema(description = "好评率")
+    private BigDecimal goodRate;
+    @Schema(description = "评论数")
+    private String comments;
+    @Schema(description = "地址")
+    private String address;
+    @Schema(description = "距离(KM)")
+    private double km;
+    @Schema(description = "是否有票")
+    private boolean ticketWhether;
+    @Schema(description = "类目")
+    private List<String> category;
+    @Schema(hidden = true)
+    private String categoryId;
+
+}

+ 13 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/AppSiteMapper.java

@@ -1,10 +1,11 @@
 package org.jeecg.modules.system.app.mapper;
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.app.vo.PlaceVO;
 import org.jeecg.modules.system.app.entity.AppSite;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 /**
  * @Description: 场地表
@@ -14,4 +15,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface AppSiteMapper extends BaseMapper<AppSite> {
 
+    /**
+     * @Author SheepHy
+     * @Description 场地列表查询
+     * @Date 10:37 2025/7/4
+     * @Param
+     * @return
+     **/
+    Page<PlaceVO> getPlaceList(@Param("page")IPage<PlaceVO> page, @Param("venueType")String venueType);
+
 }

+ 32 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppSiteMapper.xml

@@ -1,5 +1,36 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.system.app.mapper.AppSiteMapper">
-
+    <select id="getPlaceList" resultType="org.jeecg.modules.app.vo.PlaceVO">
+        SELECT
+            a.id,
+            a.name,
+            a.good_rate AS goodRate,
+            a.address,
+            a.category_id,
+            CASE
+                WHEN EXISTS (
+                    SELECT SUM(inventory)
+                    FROM nm_site_peice_rules
+                    WHERE site_id = a.id
+                ) THEN 1
+                ELSE 0
+                END AS ticketWhether
+        FROM nm_site a LEFT JOIN sys_depart b ON a.tenant_id = b.id WHERE 1=1
+        <if test="venueType != null and venueType == 0">
+            ORDER BY  a.good_rate DESC
+        </if>
+        <if test="venueType != null and venueType == 1">
+            AND b.org_category = 2
+        </if>
+        <if test="venueType != null and venueType == 2">
+            AND b.org_category = 2 ORDER BY  a.good_rate DESC
+        </if>
+        <if test="venueType != null and venueType == 3">
+            AND b.org_category = 3
+        </if>
+        <if test="venueType != null and venueType == 4">
+            AND b.org_category = 3 ORDER BY  a.good_rate DESC
+        </if>
+    </select>
 </mapper>