package com.sckw.transport.controller;


import com.sckw.core.web.response.BaseResult;
import com.sckw.core.web.response.result.PageDataResult;
import com.sckw.transport.model.ParkingChangeStrategySaveParam;
import com.sckw.transport.model.param.*;
import com.sckw.transport.service.ParkingChangeStrategyService;
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.*;

import java.util.List;

/**
 * Author: donglang
 * Time: 2026-01-05
 * Des: 收费策略Controller
 * Version: 1.0
 */

@RestController
@RequestMapping("/strategy")
@RequiredArgsConstructor
@Tag(name = "收费策略接口", description = "收费策略接口")
public class ParkingChangeStrategyController {

    private final ParkingChangeStrategyService parkingChangeStrategyService;

    /**
     * 分页查询收费策略
     *
     * @param param
     * @return
     */
    @Operation(summary = "分页查询收费策略", description = "分页查询收费策略")
    @PostMapping("/pageQueryChangeStrategy")
    public BaseResult<PageDataResult<ParkingChangeStrategyResp>> pageQueryChangeStrategy(@RequestBody @Valid ParkingChangeStrategyQueryParam param){
        PageDataResult<ParkingChangeStrategyResp> gatekeeperOrderList = parkingChangeStrategyService.pageQueryChangeStrategy(param);
        return BaseResult.success(gatekeeperOrderList);
    }

    /**
     * 保存收费策略
     *
     * @param param
     * @return
     */
    @Operation(summary = "保存收费策略", description = "保存收费策略")
    @PostMapping("/saveChangeStrategy")
    public BaseResult saveChangeStrategy(@RequestBody @Valid ParkingChangeStrategySaveParam param){
        parkingChangeStrategyService.saveChangeStrategy(param);
        return BaseResult.success();
    }

    /**
     * 删除收费策略
     *
     * @param id
     * @return
     */
    @Operation(summary = "删除收费策略", description = "删除收费策略")
    @PostMapping("/deleteChangeStrategy")
    public BaseResult deleteChangeStrategy(@RequestParam Long id){
        parkingChangeStrategyService.deleteChangeStrategy(id);
        return BaseResult.success();
    }

    /**
     * 查询单位分配
     *
     * @param id
     * @return
     */
    @Operation(summary = "查询单位分配", description = "查询单位分配")
    @PostMapping("/queryChangeStrategyEnt")
    public BaseResult<List<ParkingChangeStrategyUnitResp>> queryChangeStrategyEnt(@RequestParam Long id){
        List<ParkingChangeStrategyUnitResp> changeStrategyUnitRespList = parkingChangeStrategyService.queryChangeStrategyEnt(id);
        return BaseResult.success(changeStrategyUnitRespList);
    }

    /**
     * 保存单位分配
     *
     * @param param
     * @return
     */
    @Operation(summary = "保存单位分配", description = "保存单位分配")
    @PostMapping("/saveChangeStrategyEnt")
    public BaseResult<ParkingChangeStrategyUnitSaveResp> saveChangeStrategyEnt(@RequestBody @Valid ParkingChangeStrategyUnitSaveParam param){
        ParkingChangeStrategyUnitSaveResp unitSaveResp = parkingChangeStrategyService.saveChangeStrategyEnt(param);
        return BaseResult.success(unitSaveResp);
    }


    /**
     * 查询收费策略开关
     *
     * @param
     * @return
     */
    @Operation(summary = "查询收费策略开关", description = "查询收费策略开关")
    @PostMapping("/querySwitch")
    public BaseResult<ParkingStrategySwitchResp> querySwitch(){
        ParkingStrategySwitchResp resp = parkingChangeStrategyService.querySwitch();
        return BaseResult.success(resp);
    }

    /**
     * 修改收费策略开关
     *
     * @param
     * @return
     */
    @Operation(summary = "开启关闭收费策略开关", description = "开启关闭收费策略开关")
    @PostMapping("/updateSwitch")
    public BaseResult updateSwitch(@RequestBody @Valid ParkingStrategySwitchSaveParam param){
        parkingChangeStrategyService.updateSwitch(param);
        return BaseResult.success();
    }


}
