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.DriverConductRulesLogRequest;
import com.sckw.fleet.model.request.DriverConductRulesRequest;
import com.sckw.fleet.model.request.DriverConductRulesUpdateRequest;
import com.sckw.fleet.model.request.TruckDispatchCoefficientUpdateRequest;
import com.sckw.fleet.model.vo.KwfDriverConductRulesLogVO;
import com.sckw.fleet.model.vo.KwfDriverConductRulesVO;
import com.sckw.fleet.model.vo.KwfTruckDispatchCoefficientVO;
import com.sckw.fleet.service.KwfAutoDispatchService;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zk
 * @desc 司机
 * @date 2023/7/6 0006
 */
@RestController
@RequestMapping("/kwfDriver/auto")
@Tag(name = "司机行为规则", description = "提供司机行为规则相关操作接口")
@RequiredArgsConstructor
public class KwfAutoDispatchController {

    private final KwfAutoDispatchService autoDispatchService;

    /**
     * 查询自动派车系数
     *
     * @param request
     * @return
     */
    @Operation(summary = "查询自动派车系数", description = "查询自动派车系数")
    @PostMapping("/queryAutoTruckDispatch")
    public BaseResult<KwfTruckDispatchCoefficientVO> queryAutoTruckDispatch(@RequestBody @Valid DriverConductRulesRequest request){
        KwfTruckDispatchCoefficientVO autoDispatchVO = autoDispatchService.queryAutoTruckDispatch(request);
        return BaseResult.success(autoDispatchVO);
    }


    /**
     * 修改自动派车系数
     *
     * @param request
     * @return
     */
    @Operation(summary = "修改自动派车系数", description = "修改自动派车系数")
    @PostMapping("/updateAutoDispatch")
    public BaseResult updateAutoDispatch(@RequestBody @Valid TruckDispatchCoefficientUpdateRequest request){
        autoDispatchService.updateAutoDispatch(request);
        return BaseResult.success();
    }



    /**
     * 查询司机行为规则
     *
     * @param request
     * @return
     */
    @Operation(summary = "查询司机行为规则", description = "查询司机行为规则")
    @PostMapping("/queryDriverConductRules")
    public BaseResult<KwfDriverConductRulesVO> queryDriverConductRules(@RequestBody @Valid DriverConductRulesRequest request){
        KwfDriverConductRulesVO driverConductRulesVO = autoDispatchService.queryDriverConductRules(request);
        return BaseResult.success(driverConductRulesVO);
    }

    /**
     * 修改司机行为规则
     *
     * @param request
     * @return
     */
    @Operation(summary = "修改司机行为规则", description = "修改司机行为规则")
    @PostMapping("/updateDriverConduct")
    public BaseResult update(@RequestBody @Valid DriverConductRulesUpdateRequest request){
        autoDispatchService.updateDriverConduct(request);
        return BaseResult.success();
    }

    /**
     * 分页查询司机行为规则日志
     *
     * @param request
     * @return
     */
    @Operation(summary = "分页查询司机行为规则日志", description = "分页查询司机行为规则日志")
    @PostMapping("/queryDriverRulesLogPage")
    public BaseResult<PageDataResult<KwfDriverConductRulesLogVO>> queryDriverRulesLogPage( @Valid @RequestBody DriverConductRulesLogRequest request){
        PageDataResult<KwfDriverConductRulesLogVO> driverConductRulesLogVOPage = autoDispatchService.queryDriverRulesLogPage(request);
        return BaseResult.success(driverConductRulesLogVOPage);
    }






}
