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

/**
 * 凯和箱明细Controller
 * 
 * @author ruoyi
 * @date 2021-04-08
 */
@RestController
@RequestMapping("/shipping/cntritems")
public class TWarehousebillsCntritemsController extends BaseController
{
    @Autowired
    private ITWarehousebillsCntritemsService tWarehousebillsCntritemsService;

    /**
     * 查询凯和箱明细列表
     */
    //@PreAuthorize("@ss.hasPermi('shipping:cntritems:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWarehousebillsCntritems tWarehousebillsCntritems)
    {
        startPage();
        List<TWarehousebillsCntritems> list = tWarehousebillsCntritemsService.selectTWarehousebillsCntritemsList(tWarehousebillsCntritems);
        return getDataTable(list);
    }

    /**
     * 导出凯和箱明细列表
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntritems:export')")
    @Log(title = "凯和箱明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TWarehousebillsCntritems tWarehousebillsCntritems)
    {
        List<TWarehousebillsCntritems> list = tWarehousebillsCntritemsService.selectTWarehousebillsCntritemsList(tWarehousebillsCntritems);
        ExcelUtil<TWarehousebillsCntritems> util = new ExcelUtil<TWarehousebillsCntritems>(TWarehousebillsCntritems.class);
        return util.exportExcel(list, "cntritems");
    }

    /**
     * 获取凯和箱明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntritems:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId)
    {
        return AjaxResult.success(tWarehousebillsCntritemsService.selectTWarehousebillsCntritemsById(fId));
    }

    /**
     * 新增凯和箱明细
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntritems:add')")
    @Log(title = "凯和箱明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWarehousebillsCntritems tWarehousebillsCntritems)
    {
        return toAjax(tWarehousebillsCntritemsService.insertTWarehousebillsCntritems(tWarehousebillsCntritems));
    }

    /**
     * 修改凯和箱明细
     */
    @PreAuthorize("@ss.hasPermi('shipping:cntritems:edit')")
    @Log(title = "凯和箱明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWarehousebillsCntritems tWarehousebillsCntritems)
    {
        return toAjax(tWarehousebillsCntritemsService.updateTWarehousebillsCntritems(tWarehousebillsCntritems));
    }

    /**
     * 删除凯和箱明细
     */
    //@PreAuthorize("@ss.hasPermi('shipping:cntritems:remove')")
    @Log(title = "凯和箱明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long[] fIds)
    {
        return toAjax(tWarehousebillsCntritemsService.deleteTWarehousebillsCntritemsByIds(fIds));
    }
}
