package cn.reghao.tnb.content.app.geo.controller;

import cn.reghao.jutil.web.WebResult;
import cn.reghao.tnb.content.app.geo.model.vo.MapMarker;
import cn.reghao.tnb.content.app.geo.model.vo.MapPoint;
import cn.reghao.tnb.content.app.geo.service.MapService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author reghao
 * @date 2023-08-31 10:32:28
 */
@Tag(name = "地图接口")
@RestController
@RequestMapping("/api/geo/map")
public class MapController {
    private final MapService mapService;

    public MapController(MapService mapService) {
        this.mapService = mapService;
    }

    @Operation(summary = "添加一个经纬度坐标", description = "N")
    @PostMapping(value = "/position", produces = MediaType.APPLICATION_JSON_VALUE)
    public String addGeoPoint(@RequestBody @Validated MapPoint mapPoint) {
        mapService.addGeoPoint(mapPoint);
        return WebResult.success();
    }

    @Operation(summary = "获取坐标列表构成的路径", description = "N")
    @GetMapping(value = "/trail", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getTrailPath() {
        List list = mapService.getTrailPath();
        return WebResult.success(list);
    }

    @Operation(summary = "获取地图标记", description = "N")
    @GetMapping(value = "/marks", produces = MediaType.APPLICATION_JSON_VALUE)
    public String getTrailMarks() {
        List<MapMarker> list = mapService.getTrailMarks();
        //List<MapMarker> list = mapService.getStationMarks().subList(0, 1000);
        return WebResult.success(list);
    }
}
