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

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.TWarehousebillsCntr;
import com.ruoyi.shipping.service.ITWarehousebillsCntrService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 凯和订单从Controller
 * 
 * @author ruoyi
 * @date 2021-04-08
 */
@RestController
@RequestMapping("/shipping/warehousecntr")
public class TWarehousebillsCntrController extends BaseController
{
    @Autowired
    private ITWarehousebillsCntrService tWarehousebillsCntrService;

    /**
     * 查询凯和订单从列表
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntr:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWarehousebillsCntr tWarehousebillsCntr)
    {
        startPage();
        List<TWarehousebillsCntr> list = tWarehousebillsCntrService.selectTWarehousebillsCntrList(tWarehousebillsCntr);
        return getDataTable(list);
    }

    /**
     * 导出凯和订单从列表
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntr:export')")
    @Log(title = "凯和订单从", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TWarehousebillsCntr tWarehousebillsCntr)
    {
        List<TWarehousebillsCntr> list = tWarehousebillsCntrService.selectTWarehousebillsCntrList(tWarehousebillsCntr);
        ExcelUtil<TWarehousebillsCntr> util = new ExcelUtil<TWarehousebillsCntr>(TWarehousebillsCntr.class);
        return util.exportExcel(list, "cntr");
    }

    /**
     * 获取凯和订单从详细信息
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntr:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId)
    {
        return AjaxResult.success(tWarehousebillsCntrService.selectTWarehousebillsCntrById(fId));
    }

    /**
     * 新增凯和订单从
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntr:add')")
    @Log(title = "凯和订单从", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWarehousebillsCntr tWarehousebillsCntr)
    {
        return toAjax(tWarehousebillsCntrService.insertTWarehousebillsCntr(tWarehousebillsCntr));
    }

    /**
     * 修改凯和订单从
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntr:edit')")
    @Log(title = "凯和订单从", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWarehousebillsCntr tWarehousebillsCntr)
    {
        return toAjax(tWarehousebillsCntrService.updateTWarehousebillsCntr(tWarehousebillsCntr));
    }

    /**
     * 删除凯和订单从
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntr:remove')")
    @Log(title = "凯和订单从", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long[] fIds)
    {
        return toAjax(tWarehousebillsCntrService.deleteTWarehousebillsCntrByIds(fIds));
    }
}
