package com.ruoyi.manage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.RecordOut;
import com.ruoyi.manage.service.IRecordOutService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮挡出库记录Controller
 * 
 * @author wangh
 * @date 2024-01-18
 */
@Controller
@RequestMapping("/manage/record_out")
public class RecordOutController extends BaseController
{
    private String prefix = "manage/record_out";

    @Autowired
    private IRecordOutService recordOutService;

    @RequiresPermissions("manage:record_out:view")
    @GetMapping()
    public String record_out()
    {
        return prefix + "/record_out";
    }

    /**
     * 查询轮挡出库记录列表
     */
    @RequiresPermissions("manage:record_out:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordOut recordOut)
    {
        startPage();
        List<RecordOut> list = recordOutService.selectRecordOutList(recordOut);
        return getDataTable(list);
    }

    /**
     * 导出轮挡出库记录列表
     */
    @RequiresPermissions("manage:record_out:export")
    @Log(title = "轮挡出库记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordOut recordOut)
    {
        List<RecordOut> list = recordOutService.selectRecordOutList(recordOut);
        ExcelUtil<RecordOut> util = new ExcelUtil<RecordOut>(RecordOut.class);
        return util.exportExcel(list, "轮挡出库记录数据");
    }

    /**
     * 新增轮挡出库记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存轮挡出库记录
     */
    @RequiresPermissions("manage:record_out:add")
    @Log(title = "轮挡出库记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordOut recordOut)
    {
        return toAjax(recordOutService.insertRecordOut(recordOut));
    }

    /**
     * 修改轮挡出库记录
     */
    @RequiresPermissions("manage:record_out:edit")
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordOut recordOut = recordOutService.selectRecordOutByObjid(objid);
        mmap.put("recordOut", recordOut);
        return prefix + "/edit";
    }

    /**
     * 修改保存轮挡出库记录
     */
    @RequiresPermissions("manage:record_out:edit")
    @Log(title = "轮挡出库记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordOut recordOut)
    {
        return toAjax(recordOutService.updateRecordOut(recordOut));
    }

    /**
     * 删除轮挡出库记录
     */
    @RequiresPermissions("manage:record_out:remove")
    @Log(title = "轮挡出库记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordOutService.deleteRecordOutByObjids(ids));
    }
}
