package com.clx.performance.controller.pc;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.param.pc.PagePoundAuditParam;
import com.clx.performance.param.pc.PoundAuditParam;
import com.clx.performance.service.OrderChildPoundAuditService;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.vo.pc.OrderChildPoundAuditDetailVO;
import com.clx.performance.vo.pc.PageOrderChildPoundAuditVO;
import com.msl.common.base.PageData;
import com.msl.common.result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.constraints.NotBlank;


@Slf4j
@RestController
@RequestMapping(value="/pc/carrier/poundAudit")
@Validated
@Tag(name = "承运端-磅单审核")
@AllArgsConstructor
public class OrderChildPoundAuditController {

    private final OrderChildService orderChildService;

    private final OrderChildPoundAuditService orderChildPoundAuditService;

    @Operation(summary = "磅单审核列表",description = "<br>By:李瑞新")
    @PostMapping("/pagePoundAuditList")
    public Result<PageData<PageOrderChildPoundAuditVO>> pagePoundAuditList(@RequestBody PagePoundAuditParam param) {
        IPage<PageOrderChildPoundAuditVO> page = orderChildService.pagePoundAuditList(param);
        return Result.page(page.getRecords(), page.getTotal(), page.getPages());
    }


    @Operation(summary = "磅单审核详情",description = "<br>By:李瑞新")
    @GetMapping("/getPoundAuditDetail")
    public Result<OrderChildPoundAuditDetailVO> getPoundAuditDetail(@NotBlank(message = "运单编号不能为空") String childNo) {
        return Result.ok(orderChildPoundAuditService.getPoundAuditDetail(childNo));
    }


    @Operation(summary = "磅单审核接口",description = "<br>By:李瑞新")
    @PostMapping("/updatePoundAudit")
    public Result<Object> updatePoundAudit(@RequestBody @Validated PoundAuditParam param) {
        orderChildPoundAuditService.updatePoundAudit(param);
        return Result.ok();
    }
}
