package com.hw.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.wms.domain.WmsBaseContainer;
import com.hw.wms.service.IWmsBaseContainerService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 料箱信息Controller
 * 
 * @author xs
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/wmscontainer")
public class WmsBaseContainerController extends BaseController
{
    @Autowired
    private IWmsBaseContainerService wmsBaseContainerService;

    /**
     * 查询料箱信息列表
     */
    @RequiresPermissions("wms:wmscontainer:list")
    @GetMapping("/list")
    public TableDataInfo list(WmsBaseContainer wmsBaseContainer)
    {
        startPage();
        List<WmsBaseContainer> list = wmsBaseContainerService.selectWmsBaseContainerList(wmsBaseContainer);
        return getDataTable(list);
    }

    /**
     * 导出料箱信息列表
     */
    @RequiresPermissions("wms:wmscontainer:export")
    @Log(title = "料箱信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsBaseContainer wmsBaseContainer)
    {
        List<WmsBaseContainer> list = wmsBaseContainerService.selectWmsBaseContainerList(wmsBaseContainer);
        ExcelUtil<WmsBaseContainer> util = new ExcelUtil<WmsBaseContainer>(WmsBaseContainer.class);
        util.exportExcel(response, list, "料箱信息数据");
    }

    /**
     * 获取料箱信息详细信息
     */
    @RequiresPermissions("wms:wmscontainer:query")
    @GetMapping(value = "/{baseContainerId}")
    public AjaxResult getInfo(@PathVariable("baseContainerId") Long baseContainerId)
    {
        return success(wmsBaseContainerService.selectWmsBaseContainerByBaseContainerId(baseContainerId));
    }

    /**
     * 新增料箱信息
     */
    @RequiresPermissions("wms:wmscontainer:add")
    @Log(title = "料箱信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsBaseContainer wmsBaseContainer)
    {
        return toAjax(wmsBaseContainerService.insertWmsBaseContainer(wmsBaseContainer));
    }

    /**
     * 修改料箱信息
     */
    @RequiresPermissions("wms:wmscontainer:edit")
    @Log(title = "料箱信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsBaseContainer wmsBaseContainer)
    {
        return toAjax(wmsBaseContainerService.updateWmsBaseContainer(wmsBaseContainer));
    }

    /**
     * 删除料箱信息
     */
    @RequiresPermissions("wms:wmscontainer:remove")
    @Log(title = "料箱信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseContainerIds}")
    public AjaxResult remove(@PathVariable Long[] baseContainerIds)
    {
        return toAjax(wmsBaseContainerService.deleteWmsBaseContainerByBaseContainerIds(baseContainerIds));
    }
}
