package com.ruoyi.web.controller.shipping.finance;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shipping.domain.TFeeInvoice;
import com.ruoyi.shipping.service.ITFeeInvoiceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 发票从Controller
 * 
 * @author ruoyi
 * @date 2021-04-22
 */
@RestController
@RequestMapping("/shipping/invoice")
public class TFeeInvoiceController extends BaseController
{
    @Autowired
    private ITFeeInvoiceService tFeeInvoiceService;

    /**
     * 查询发票从列表
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:list')")
    @GetMapping("/list")
    public TableDataInfo list(TFeeInvoice tFeeInvoice)
    {
        startPage();
        List<TFeeInvoice> list = tFeeInvoiceService.selectTFeeInvoiceList(tFeeInvoice);
        return getDataTable(list);
    }

    /**
     * 导出发票从列表
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:export')")
    @Log(title = "发票从", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TFeeInvoice tFeeInvoice)
    {
        List<TFeeInvoice> list = tFeeInvoiceService.selectTFeeInvoiceList(tFeeInvoice);
        ExcelUtil<TFeeInvoice> util = new ExcelUtil<TFeeInvoice>(TFeeInvoice.class);
        return util.exportExcel(list, "invoice");
    }

    /**
     * 获取发票从详细信息
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId)
    {
        return AjaxResult.success(tFeeInvoiceService.selectTFeeInvoiceById(fId));
    }

    /**
     * 新增发票从
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:add')")
    @Log(title = "发票从", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TFeeInvoice tFeeInvoice)
    {
        return toAjax(tFeeInvoiceService.insertTFeeInvoice(tFeeInvoice));
    }

    /**
     * 修改发票从
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:edit')")
    @Log(title = "发票从", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TFeeInvoice tFeeInvoice)
    {
        return toAjax(tFeeInvoiceService.updateTFeeInvoice(tFeeInvoice));
    }

    /**
     * 删除发票从
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:remove')")
    @Log(title = "发票从", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long fIds)
    {
        return tFeeInvoiceService.deleteTFeeInvoiceById(fIds);
    }
    /**
     * 删除发票从
     */
    @PreAuthorize("@ss.hasPermi('shipping:invoice:removeByid')")
    @Log(title = "发票从", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{fId}")
    public AjaxResult removeByid(@PathVariable Long fId)
    {
        return tFeeInvoiceService.deleteTFeeInvoiceById(fId);
    }
}
