liujie
2026-07-30 fc767bf18e262b724c78b5f860b6d908d4993dcb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.tourguide.api.mini;
 
import com.tourguide.common.api.ApiResponse;
import com.tourguide.modules.operation.dto.MiniScenicMeetingPointResponse;
import com.tourguide.modules.operation.dto.MiniScenicServiceResponse;
import com.tourguide.modules.operation.dto.MiniScenicSpotResponse;
import com.tourguide.modules.operation.service.MiniScenicSpotService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * 游客小程序景区公开查询接口。
 * 仅返回启用中的运营景区、汇合点和讲解服务,并支持基于游客位置计算距离和最近景区。
 */
@RestController
@RequestMapping("/api/mini/scenic-spots")
public class MiniScenicSpotController {
    private final MiniScenicSpotService scenicSpotService;
 
    public MiniScenicSpotController(MiniScenicSpotService scenicSpotService) {
        this.scenicSpotService = scenicSpotService;
    }
 
    /**
     * 查询可用景区列表,可按名称搜索,并在提供坐标时返回距离和按距离排序。
     *
     * @param keyword 景区名称关键字
     * @param longitude 游客当前位置经度,需要与纬度同时提供
     * @param latitude 游客当前位置纬度,需要与经度同时提供
     * @param limit 返回数量上限
     * @return 可在小程序展示的景区列表
     */
    @GetMapping
    public ApiResponse<List<MiniScenicSpotResponse>> list(
            @RequestParam(required = false) String keyword,
            @RequestParam(required = false) Double longitude,
            @RequestParam(required = false) Double latitude,
            @RequestParam(required = false) Integer limit) {
        return ApiResponse.success(scenicSpotService.list(keyword, longitude, latitude, limit));
    }
 
    /**
     * 根据游客当前位置查询距离最近的可用景区。
     *
     * @param longitude 游客当前位置经度
     * @param latitude 游客当前位置纬度
     * @return 最近景区及距离信息
     */
    @GetMapping("/nearest")
    public ApiResponse<MiniScenicSpotResponse> nearest(
            @RequestParam Double longitude,
            @RequestParam Double latitude) {
        return ApiResponse.success(scenicSpotService.nearest(longitude, latitude));
    }
 
    /**
     * 查询指定景区启用中的汇合点,并在提供游客坐标时计算各汇合点距离。
     *
     * @param id 景区主键
     * @param longitude 游客当前位置经度,需要与纬度同时提供
     * @param latitude 游客当前位置纬度,需要与经度同时提供
     * @return 景区汇合点列表
     */
    @GetMapping("/{id}/meeting-points")
    public ApiResponse<List<MiniScenicMeetingPointResponse>> meetingPoints(
            @PathVariable Long id,
            @RequestParam(required = false) Double longitude,
            @RequestParam(required = false) Double latitude) {
        return ApiResponse.success(scenicSpotService.meetingPoints(id, longitude, latitude));
    }
 
    /**
     * 查询指定景区当前可购买的拼团快讲、拼团精讲、包团快讲和包团精讲服务。
     *
     * @param id 景区主键
     * @return 景区讲解服务及价格配置列表
     */
    @GetMapping("/{id}/services")
    public ApiResponse<List<MiniScenicServiceResponse>> services(@PathVariable Long id) {
        return ApiResponse.success(scenicSpotService.services(id));
    }
}