package com.sckw.fleet.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.core.web.response.result.PageDataResult;
import com.sckw.fleet.model.request.DeleteTruckRoteReq;
import com.sckw.fleet.model.request.QueryTruckRouteByDriverReq;
import com.sckw.fleet.model.request.QueryTruckRoteReq;
import com.sckw.fleet.model.request.TruckRoteDetailReq;
import com.sckw.fleet.model.vo.QueryTruckRoteVo;
import com.sckw.fleet.model.vo.TruckRoteDetailVo;
import com.sckw.fleet.service.KwfTruckRouteService;
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.*;

/**
 * @author PC
 * 卡车线路管理
 */
@RestController
@RequestMapping("/truckRoute")
@RequiredArgsConstructor
@Tag(name = "卡车线路管理", description = "卡车线路管理")
public class KwfTruckRouteController {
    private final KwfTruckRouteService truckService;
    /**
     *  分页获取车辆信息
     **/
    @PostMapping("/pageTruckRoute")
    @Operation(summary = "分页获取车辆惯用路线信息", description = "分页获取车辆惯用路线信息")
    public BaseResult<PageDataResult<QueryTruckRoteVo>> pageTruckRoute(@RequestBody QueryTruckRoteReq req) {
        return BaseResult.success(truckService.pageTruckRoute(req));
    }

    /**
     * 删除车辆信息
     * @param req 请求参数
     * @return 删除结果
     */
    @PostMapping("/deleteTruckRoute")
    @Operation(summary = "删除车辆惯用信息", description = "删除车辆惯用信息")
    public BaseResult<Boolean> deleteTruckRoute(@Valid @RequestBody DeleteTruckRoteReq req) {
        return BaseResult.success(truckService.deleteTruckRoute(req));
    }

    /**
     * 车辆惯用路线详情
     * @param req 请求参数
     * @return 详情结果
     */
    @PostMapping("/truckRouteDetail")
    @Operation(summary = "车辆惯用路线详情", description = "车辆惯用路线详情")
    public BaseResult<TruckRoteDetailVo> truckRouteDetail(@Valid @RequestBody TruckRoteDetailReq req) {
        return BaseResult.success(truckService.truckRouteDetail(req));
    }

    /**
     * 根据司机ID和装货卸货地址查询常用路线
     * @param req 请求参数
     * @return 常用路线信息
     */
    @PostMapping("/queryByDriver")
    @Operation(summary = "根据司机ID和装货卸货地址查询常用路线", description = "根据司机ID和装货卸货地址查询常用路线")
    public BaseResult<QueryTruckRoteVo> queryTruckRouteByDriver(@Valid @RequestBody QueryTruckRouteByDriverReq req) {
        return BaseResult.success(truckService.queryTruckRouteByDriver(req));
    }

}
