package com.sckw.transport.controller.enterpriseApp;


import com.sckw.core.web.response.BaseResult;
import com.sckw.core.web.response.result.PageDataResult;
import com.sckw.transport.model.param.forklift.reponse.GatekeeperOrderResp;
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderIsPassParam;
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderPassParam;
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderPassReasonParam;
import com.sckw.transport.model.param.forklift.request.GatekeeperOrderQueryParam;
import com.sckw.transport.model.vo.StatisticsWaybillResp;
import com.sckw.transport.service.app.GatekeeperOrderService;
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: donglang
 * Time: 2026-01-05
 * Des: 铲车司机Controller
 * Version: 1.0
 */

@RestController
@RequestMapping("/appGatekeeper")
@RequiredArgsConstructor
@Tag(name = "APP门卫接口", description = "app端门卫接口")
public class AppGatekeeperController {

    private final GatekeeperOrderService gatekeeperOrderService;

    /**
     * 分页查询门卫订单
     *
     * @param param
     * @return
     */
    @Operation(summary = "分页查询门卫订单", description = "分页查询门卫订单")
    @PostMapping("/pageQueryGatekeeperOrder")
    public BaseResult<PageDataResult<GatekeeperOrderResp>> pageQueryGatekeeperOrder(@RequestBody @Valid GatekeeperOrderQueryParam param){
        PageDataResult<GatekeeperOrderResp> gatekeeperOrderList = gatekeeperOrderService.pageQueryGatekeeperOrder(param);
        return BaseResult.success(gatekeeperOrderList);
    }

    /**
     * 门卫订单状态统计
     *
     * @param param
     * @return
     */
    @Operation(summary = "门卫订单状态统计", description = "门卫订单状态统计")
    @PostMapping("/statisticsGatekeeperOrder")
    public BaseResult<StatisticsWaybillResp> statisticsGatekeeperOrder(@RequestBody @Valid GatekeeperOrderQueryParam param){
        return BaseResult.success(gatekeeperOrderService.statisticsGatekeeperOrder(param));
    }

    /**
     * 放行
     *
     * @param param
     * @return
     */
    @Operation(summary = "放行", description = "放行")
    @PostMapping("/pass")
    public BaseResult pass(@RequestBody @Valid GatekeeperOrderPassParam param){
        gatekeeperOrderService.pass(param);
        return BaseResult.success();
    }

    /**
     * 保存放行原因
     *
     * @param param
     * @return
     */
    @Operation(summary = "保存放行原因", description = "保存放行原因")
    @PostMapping("/savePassReason")
    public BaseResult savePassReason(@RequestBody @Valid GatekeeperOrderPassReasonParam param){
        gatekeeperOrderService.savePassReason(param);
        return BaseResult.success();
    }

    /**
     * 是否放行
     *
     * @param param
     * @return
     */
    @Operation(summary = "放行", description = "放行")
    @PostMapping("/isPass")
    public BaseResult isPass(@RequestBody @Valid GatekeeperOrderIsPassParam param){
        Boolean isPass = gatekeeperOrderService.checkIsPass(param);
        return BaseResult.success(isPass);
    }

}
