package com.prolog.cs.biz.outbound.controller;

import com.prolog.cs.biz.outbound.model.OutboundHandover;
import com.prolog.cs.biz.outbound.model.dto.OutboundHandoverDTO;
import com.prolog.cs.biz.outbound.service.OutboundHandoverService;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "出库交接")
@RestController
@RequestMapping("/outbound-handover")
public class OutboundHandoverController {

    @Autowired
    private OutboundHandoverService service;

    @UserLog
    @ApiOperation(value = "分页查询出库交接记录")
    @GetMapping("/page")
    public RestMessage<Page<OutboundHandover>> getPage(String billGroupId, String srcCode, String shipperName, String warehouseId, Integer pageNum, Integer pageSize) {
        return RestMessage.success("操作成功", service.getPage(billGroupId, srcCode, shipperName, warehouseId, pageNum, pageSize));
    }

    @UserLog
    @ApiOperation(value = "新增出库交接记录")
    @PostMapping("/add")
    public RestMessage<?>add(@RequestBody OutboundHandover model) {
        service.add(model);
        return RestMessage.success("操作成功", null);
    }

    @UserLog
    @ApiOperation(value = "根据订单号查询条码详情")
    @GetMapping("/list-barcodedetai")
    public RestMessage<OutboundHandoverDTO> getBarcodeDetail(String billGroupId, String warehouseId) {
        return RestMessage.success("操作成功", service.getBarcodeDetail(billGroupId, warehouseId));
    }

    @UserLog
    @ApiOperation(value = "根据订单号查询条码列表")
    @GetMapping("/list-barcodedetais")
    public RestMessage<List<OutboundHandoverDTO>> getBarcodeDetails(String billGroupId, String warehouseId) {
        return RestMessage.success("操作成功", service.getBarcodeDetails(billGroupId, warehouseId));
    }

}
