package com.zsElectric.boot.business.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zsElectric.boot.business.model.query.ThirdPartyStationInfoQuery;
import com.zsElectric.boot.business.model.query.ThirdPartyEquipmentInfoQuery;
import com.zsElectric.boot.business.model.dto.StationDetailDTO;
import com.zsElectric.boot.business.model.vo.PartyStationInfoVO;
import com.zsElectric.boot.business.model.vo.ThirdPartyStationInfoVO;
import com.zsElectric.boot.business.model.vo.ThirdPartyEquipmentInfoVO;
import com.zsElectric.boot.business.model.vo.StationDetailVO;
import com.zsElectric.boot.business.service.ThirdPartyChargingService;
import com.zsElectric.boot.common.annotation.Log;
import com.zsElectric.boot.common.enums.LogModuleEnum;
import com.zsElectric.boot.core.web.PageResult;
import com.zsElectric.boot.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 第三方充电站/充电桩信息查询控制器
 *
 * @author system
 * @since 2025-12-11
 */
@Tag(name = "第三方充电站/充电桩信息查询接口")
@RestController
@RequestMapping("/api/v1/third-party-charging")
@RequiredArgsConstructor
public class ThirdPartyChargingController {

    private final ThirdPartyChargingService chargingService;

    @Operation(summary = "充电站信息分页列表")
    @PostMapping("/stations/page")
    @Log(value = "充电站信息分页列表", module = LogModuleEnum.OTHER)
    public PageResult<ThirdPartyStationInfoVO> getStationInfoPage(@RequestBody ThirdPartyStationInfoQuery queryParams) {
        IPage<ThirdPartyStationInfoVO> result = chargingService.getStationInfoPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "充电桩信息分页列表")
    @PostMapping("/equipments/page")
    @Log(value = "充电桩信息分页列表", module = LogModuleEnum.OTHER)
    public PageResult<ThirdPartyEquipmentInfoVO> getEquipmentInfoPage(@RequestBody ThirdPartyEquipmentInfoQuery queryParams) {
        IPage<ThirdPartyEquipmentInfoVO> result = chargingService.getEquipmentInfoPage(queryParams);
        return PageResult.success(result);
    }

    @Operation(summary = "查询站点详情信息", description = "查询站点的banner信息、提示语、营业时间、客服电话")
    @GetMapping("/stations/detail/{stationId}")
    @Log(value = "查询站点详情信息", module = LogModuleEnum.OTHER)
    public Result<StationDetailVO> getStationDetail(@PathVariable Long stationId) {
        StationDetailVO result = chargingService.getStationDetail(stationId);
        return Result.success(result);
    }

    @Operation(summary = "修改站点详情信息", description = "修改站点的banner信息、提示语、营业时间、客服电话")
    @PostMapping("/stations/detail/update")
    @Log(value = "修改站点详情信息", module = LogModuleEnum.OTHER)
    public Result<Boolean> updateStationDetail(@Valid @RequestBody StationDetailDTO dto) {
        boolean result = chargingService.updateStationDetail(dto);
        return Result.success(result);
    }

}
