package com.hw.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.WmsMove;
import com.hw.wms.service.IWmsMoveService;
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 xins
 * @date 2024-01-09
 */
@Api(tags = "cangchu1",description = "dd1")
@RestController
@RequestMapping("/move")
public class WmsMoveController extends BaseController
{
    @Autowired
    private IWmsMoveService wmsMoveService;

    /**
     * 查询移库合库记录列表
     */
    @ApiOperation("cccc")
    @RequiresPermissions("wms:move:list")
    @GetMapping("/list")
    public TableDataInfo list(WmsMove wmsMove)
    {
        startPage();
        List<WmsMove> list = wmsMoveService.selectWmsMoveList(wmsMove);
        return getDataTable(list);
    }

    /**
     * 导出移库合库记录列表
     */
    @RequiresPermissions("wms:move:export")
    @Log(title = "移库合库记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsMove wmsMove)
    {
        List<WmsMove> list = wmsMoveService.selectWmsMoveList(wmsMove);
        ExcelUtil<WmsMove> util = new ExcelUtil<WmsMove>(WmsMove.class);
        util.exportExcel(response, list, "移库合库记录数据");
    }

    /**
     * 获取移库合库记录详细信息
     */
    @RequiresPermissions("wms:move:query")
    @GetMapping(value = "/{moveId}")
    public AjaxResult getInfo(@PathVariable("moveId") Long moveId)
    {
        return success(wmsMoveService.selectWmsMoveByMoveId(moveId));
    }

    /**
     * 新增移库合库记录
     */
    @RequiresPermissions("wms:move:add")
    @Log(title = "移库合库记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsMove wmsMove)
    {
        return toAjax(wmsMoveService.insertWmsMove(wmsMove));
    }

    /**
     * 修改移库合库记录
     */
    @RequiresPermissions("wms:move:edit")
    @Log(title = "移库合库记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsMove wmsMove)
    {
        return toAjax(wmsMoveService.updateWmsMove(wmsMove));
    }

    /**
     * 删除移库合库记录
     */
    @RequiresPermissions("wms:move:remove")
    @Log(title = "移库合库记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{moveIds}")
    public AjaxResult remove(@PathVariable Long[] moveIds)
    {
        return toAjax(wmsMoveService.deleteWmsMoveByMoveIds(moveIds));
    }
}
