package vip.xiaonuo.biz.api.cloud.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.biz.modular.depotRepayOrder.service.DepotRepayOrderService;
import vip.xiaonuo.biz.modular.depotTruckBook.param.DepotTruckBookCheckParam;
import vip.xiaonuo.biz.modular.depotTruckBook.param.DepotTruckBookLicensePlateCheckParam;
import vip.xiaonuo.biz.modular.depotTruckBook.service.DepotTruckBookService;
import vip.xiaonuo.common.pojo.CommonResult;

import javax.annotation.Resource;

@Api(tags = "云端校验控制器")
@ApiSupport(author = "SNOWY_TEAM", order = 1)
@RestController
@Validated
public class CloudCheckController {

    @Resource
    private DepotTruckBookService depotTruckBookService;

    /**
     * 云端车辆预约车牌校验
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("云端车辆预约车牌校验")
    @GetMapping("/api/cloud/depotTruckBook/check_dai_ru_chang")
    public CommonResult<Object> check_dai_ru_chang(DepotTruckBookLicensePlateCheckParam param) {
        return CommonResult.data(depotTruckBookService.check_dai_ru_chang(param));
    }

    @Resource
    DepotRepayOrderService repayOrderService;

    /**
     * 云端车辆出库净重校验
     *
     * @author xiang
     * @date 2023/09/13 09:21
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("云端车辆出库净重校验")
    @PostMapping("/api/cloud/depotTruckBook/check/out_netWeight")
    public CommonResult<Object> check_out_netWeight(@RequestBody DepotTruckBookCheckParam param) {
        repayOrderService.checkOutNetWeight(depotTruckBookService.getOneByBookId(param.getTruckBookId()), param.getNetWeight().movePointLeft(3));
        return CommonResult.ok();
    }

}
