package com.trade.admin.trade.salesorder;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;
import com.trade.common.core.domain.ResponseResult;
import com.trade.service.trade.salesorder.service.ISalesOrderInvoiceService;
import com.trade.service.trade.salesorder.vo.SalesOrderInvoiceDtlVO;
import com.trade.service.trade.salesorder.vo.SalesOrderInvoiceSearch;
import com.trade.service.trade.salesorder.vo.SalesOrderInvoiceVO;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/salesOrderInvoiceB")
@Validated
public class SalesOrderInvoiceBController {

    @Resource
    private ISalesOrderInvoiceService salesOrderInvoiceService;

    /**
     * 获取发票列表
     */
    @RequestMapping("/queryList")
    @PreAuthorize("@ss.hasPermi('trade:salesInvoice:list')")
    public ResponseResult<PageInfo<SalesOrderInvoiceVO>> queryList(SalesOrderInvoiceSearch search) {
        return ResponseResult.success(salesOrderInvoiceService.queryListBySearch(search));
    }

    /**
     * 根据发票号获取发票详情
     */
    @RequestMapping("/getDetailByInvoiceNo")
    @PreAuthorize("@ss.hasPermi('trade:salesInvoice:detail')")
    public ResponseResult<SalesOrderInvoiceDtlVO> getDetailByInvoiceNo(
            @NotBlank(message = "发票编号不能为空") String invoiceNo) {
        return ResponseResult.success(salesOrderInvoiceService.getDetailByInvoiceNo(invoiceNo));
    }
}
