package com.zsElectric.boot.business.controller.applet;

import com.zsElectric.boot.business.model.vo.AppletConnectorListVO;
import com.zsElectric.boot.business.model.vo.AppletStationDetailVO;
import com.zsElectric.boot.business.model.vo.AppletStationPriceListVO;
import com.zsElectric.boot.business.service.AppletHomeService;
import com.zsElectric.boot.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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 java.math.BigDecimal;

@Tag(name = "充电相关接口")
@RestController
@RequestMapping("/applet/v1/station")
@RequiredArgsConstructor
public class AppletStationController {

    private final AppletHomeService appletHomeService;

    /**
     * 获取电站详情
     *
     * @param stationId 站点ID
     * @param longitude 经度（用于计算距离）
     * @param latitude 纬度（用于计算距离）
     * @return 电站详情
     */
    @Operation(summary = "获取电站详情")
    @GetMapping("/detail")
    public Result<AppletStationDetailVO> getStationDetail(
            @RequestParam Long stationId,
            @RequestParam(required = false) BigDecimal longitude,
            @RequestParam(required = false) BigDecimal latitude) {
        return Result.success(appletHomeService.getStationDetail(stationId, longitude, latitude));
    }

    /**
     * 获取充电终端列表
     *
     * @param stationId 站点ID
     * @return 充电终端列表
     */
    @Operation(summary = "获取充电终端列表")
    @GetMapping("/connectors")
    public Result<AppletConnectorListVO> getConnectorList(@RequestParam Long stationId) {
        return Result.success(appletHomeService.getConnectorList(stationId));
    }

    /**
     * 获取电站价格列表
     *
     * @param stationId 站点ID
     * @return 电站价格列表
     */
    @Operation(summary = "获取电站价格列表")
    @GetMapping("/prices")
    public Result<AppletStationPriceListVO> getStationPriceList(@RequestParam Long stationId) {
        return Result.success(appletHomeService.getStationPriceList(stationId));
    }
}
