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

import java.util.List;

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

/**
 * 凯和费用协议明细Controller
 * 
 * @author ruoyi
 * @date 2022-01-07
 */
@RestController
@RequestMapping("/warehouse/item")
public class TShipDealItemController extends BaseController
{
    @Autowired
    private ITShipDealItemService tShipDealItemService;

    /**
     * 查询凯和费用协议明细列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShipDealItem tShipDealItem)
    {
        startPage();
        List<TShipDealItem> list = tShipDealItemService.selectTShipDealItemList(tShipDealItem);
        return getDataTable(list);
    }

    /**
     * 导出凯和费用协议明细列表
     */
    @PreAuthorize("@ss.hasPermi('warehouse:item:export')")
    @Log(title = "凯和费用协议明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShipDealItem tShipDealItem)
    {
        List<TShipDealItem> list = tShipDealItemService.selectTShipDealItemList(tShipDealItem);
        ExcelUtil<TShipDealItem> util = new ExcelUtil<TShipDealItem>(TShipDealItem.class);
        return util.exportExcel(list, "item");
    }

    /**
     * 获取凯和费用协议明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouse:item:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId)
    {
        return AjaxResult.success(tShipDealItemService.selectTShipDealItemById(fId));
    }

    /**
     * 新增凯和费用协议明细
     */
    @PreAuthorize("@ss.hasPermi('warehouse:item:add')")
    @Log(title = "凯和费用协议明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShipDealItem tShipDealItem)
    {
        return toAjax(tShipDealItemService.insertTShipDealItem(tShipDealItem));
    }

    /**
     * 修改凯和费用协议明细
     */
    @PreAuthorize("@ss.hasPermi('warehouse:item:edit')")
    @Log(title = "凯和费用协议明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShipDealItem tShipDealItem)
    {
        return toAjax(tShipDealItemService.updateTShipDealItem(tShipDealItem));
    }

    /**
     * 删除凯和费用协议明细
     */
    @PreAuthorize("@ss.hasPermi('warehouse:item:remove')")
    @Log(title = "凯和费用协议明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long[] fIds)
    {
        return toAjax(tShipDealItemService.deleteTShipDealItemByIds(fIds));
    }
}
