package com.ruoyi.web.controller.warehouse.warehouseBusiness;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
import com.ruoyi.warehouseBusiness.service.ITWarehousebillsitemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 仓库明细从表Controller
 *
 * @author ruoyi
 * @date 2020-12-11
 */
@RestController
@RequestMapping("/warehouseBusiness/warehousebillsitems")
public class TWarehousebillsitemsController extends BaseController {
    @Autowired
    private ITWarehousebillsitemsService tWarehousebillsitemsService;

    /**
     * 查询仓库明细从表列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:warehousebillsitems:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWarehousebillsitems tWarehousebillsitems) {
        startPage();
        List<TWarehousebillsitems> list = tWarehousebillsitemsService.selectTWarehousebillsitemsList(tWarehousebillsitems);
        return getDataTable(list);
    }

    /**
     * 导出仓库明细从表列表
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:warehousebillsitems:export')")
    @Log(title = "仓库明细从表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TWarehousebillsitems tWarehousebillsitems) {
        List<TWarehousebillsitems> list = tWarehousebillsitemsService.selectTWarehousebillsitemsList(tWarehousebillsitems);
        ExcelUtil<TWarehousebillsitems> util = new ExcelUtil<TWarehousebillsitems>(TWarehousebillsitems.class);
        return util.exportExcel(list, "warehousebillsitems");
    }

    /**
     * 获取仓库明细从表详细信息
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:warehousebillsitems:query')")
    @GetMapping(value = "/{fId}")
    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
        return AjaxResult.success(tWarehousebillsitemsService.selectTWarehousebillsitemsById(fId));
    }

    /**
     * 新增仓库明细从表
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:warehousebillsitems:add')")
    @Log(title = "仓库明细从表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWarehousebillsitems tWarehousebillsitems) {
        return toAjax(tWarehousebillsitemsService.insertTWarehousebillsitems(tWarehousebillsitems));
    }

    /**
     * 修改仓库明细从表
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:warehousebillsitems:edit')")
    @Log(title = "仓库明细从表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWarehousebillsitems tWarehousebillsitems) {
        return toAjax(tWarehousebillsitemsService.updateTWarehousebillsitems(tWarehousebillsitems));
    }

    /**
     * 删除仓库明细从表
     */
    @PreAuthorize("@ss.hasPermi('warehouseBusiness:warehousebillsitems:remove')")
    @Log(title = "仓库明细从表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{fIds}")
    public AjaxResult remove(@PathVariable Long[] fIds) {
        return toAjax(tWarehousebillsitemsService.deleteTWarehousebillsitemsByIds(fIds));
    }

    /**
     * 获取箱号
     * @return
     */
    @GetMapping("/getFBoxNo")
    public AjaxResult getFBoxNo(){
        List<Map<String, Object>> maps = tWarehousebillsitemsService.selectStorageFeeItemfTruckNo();
        return AjaxResult.success(maps);
    }
}
