package com.usky.sas.controller.web;

import com.usky.common.core.bean.ApiResult;
import com.usky.sas.service.SasMapNavigateService;
import com.usky.sas.service.vo.MapDeviceDetailResponse;
import com.usky.sas.service.vo.MapNavigateResponse;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * 电子地图导航接口
 *
 * GET /prod-api/service-sas/map/navigate
 * GET /prod-api/service-sas/map/device/{deviceId}/detail
 */
@RestController
@RequestMapping("/map")
public class SasMapNavigateController {

    @Autowired
    private SasMapNavigateService sasMapNavigateService;

    @GetMapping("/navigate")
    public ApiResult<MapNavigateResponse> navigate(@RequestParam("mapId") String mapId,
                                                   @RequestParam(value = "x", required = false) Double x,
                                                   @RequestParam(value = "y", required = false) Double y) {
        return ApiResult.success(sasMapNavigateService.navigate(mapId, x, y));
    }

    @GetMapping("/device/{deviceId}/detail")
    public ApiResult<MapDeviceDetailResponse> deviceDetail(@PathVariable("deviceId") String deviceId) {
        return ApiResult.success(sasMapNavigateService.deviceDetail(deviceId));
    }
}

