package com.prolog.rdc.tms.app.controller.business;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.business.ReceiptAndDeliveryCountDTO;
import com.prolog.rdc.tms.app.model.dto.business.ReceiptAndDeliveryDTO;
import com.prolog.rdc.tms.app.model.dto.business.ReceiptAndDeliveryNodeDTO;
import com.prolog.rdc.tms.app.model.vo.business.ReceiptAndDeliveryQueryVO;
import com.prolog.rdc.tms.app.service.business.ReceiptAndDeliveryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hongbo.pan
 * @date 2022/10/31
 */
@RestController
@Api(tags = "业务APP--收发货小程序控制层")
@RequestMapping("/receiptAndDelivery")
public class ReceiptAndDeliveryController {

    @Autowired
    private ReceiptAndDeliveryService receiptAndDeliveryService;

    @UserLog("合计数量")
    @ApiOperation(value = "合计数量", notes = "合计数量")
    @PostMapping("/count")
    public RestMessage<ReceiptAndDeliveryCountDTO> count(@RequestBody ReceiptAndDeliveryQueryVO vo) {
        ReceiptAndDeliveryCountDTO dto = receiptAndDeliveryService.count(vo);
        return RestMessage.newInstance(true, "查询成功！", dto);
    }

    @UserLog("收发货小程序查询")
    @ApiOperation(value = "收发货小程序查询", notes = "收发货小程序查询")
    @PostMapping("/findByCondition")
    public RestMessage<Page<ReceiptAndDeliveryDTO>> findByCondition(@RequestBody ReceiptAndDeliveryQueryVO vo) {
        Page<ReceiptAndDeliveryDTO> page = receiptAndDeliveryService.findByCondition(vo);
        return RestMessage.newInstance(true, "查询成功！", page);
    }

    @UserLog("运单节点查询")
    @ApiOperation(value = "运单节点查询", notes = "运单节点查询")
    @PostMapping("/findNodeByShipBillId")
    public RestMessage<List<ReceiptAndDeliveryNodeDTO>> findNodeByShipBillId(@RequestParam("shipBillId") String shipBillId) {
        List<ReceiptAndDeliveryNodeDTO> list = receiptAndDeliveryService.findNodeByShipBillId(shipBillId);
        return RestMessage.newInstance(true, "查询成功！", list);
    }
}
