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

import com.zsElectric.boot.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zsElectric.boot.business.model.query.StationInfoQuery;
import com.zsElectric.boot.business.model.vo.BannerInfoVO;
import com.zsElectric.boot.business.model.vo.StationInfoMapVO;
import com.zsElectric.boot.business.model.vo.StationInfoVO;
import com.zsElectric.boot.business.service.AppletHomeService;
import com.zsElectric.boot.core.web.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@Tag(name = "小程序主页相关接口")
@RestController
@RequestMapping("/applet/v1/homePage")
@RequiredArgsConstructor
public class AppletHomeController {

    private final AppletHomeService appletHomeService;

    /**
     * 用户端分页查询站点信息
     *
     * @param queryParams 查询参数
     * @return 站点信息分页列表
     */
    @Operation(summary = "用户端分页查询站点信息")
    @PostMapping("/getStationInfoPage")
    public PageResult<StationInfoVO> getStationInfoPage(@RequestBody StationInfoQuery queryParams) {
        IPage<StationInfoVO> result = appletHomeService.getStationInfoPage(queryParams);
        return PageResult.success(result);
    }

    /**
     * 首页地图模式-获取充电站列表（按距离排序）
     *
     * @param longitude 经度
     * @param latitude 纬度
     * @return 站点列表
     */
    @Operation(summary = "首页地图模式-获取充电站列表（按距离排序）")
    @GetMapping("/getStationInfoMapList")
    public Result<List<StationInfoMapVO>> getStationInfoMapList(
            @RequestParam BigDecimal longitude,
            @RequestParam BigDecimal latitude) {
        return Result.success(appletHomeService.getStationInfoMapList(longitude, latitude));
    }

    /**
     * 获取首页Banner列表
     *
     * @return Banner列表
     */
    @Operation(summary = "获取首页Banner列表")
    @GetMapping("/getBannerList")
    public Result<List<BannerInfoVO>> getBannerList() {
        return Result.success(appletHomeService.getBannerList());
    }
}
