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.RecordInvalidatedImg;
import com.ruoyi.manage.service.IRecordInvalidatedImgService;
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-09-27
 */
@Controller
@RequestMapping("/manage/record_invalidated_img")
public class RecordInvalidatedImgController extends BaseController
{
    private String prefix = "manage/record_invalidated_img";

    @Autowired
    private IRecordInvalidatedImgService recordInvalidatedImgService;

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

    /**
     * 查询轮挡报废图片记录列表
     */
    //@RequiresPermissions("manage:record_invalidated_img:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordInvalidatedImg recordInvalidatedImg)
    {
        startPage();
        List<RecordInvalidatedImg> list = recordInvalidatedImgService.selectRecordInvalidatedImgList(recordInvalidatedImg);
        return getDataTable(list);
    }

    /**
     * 导出轮挡报废图片记录列表
     */
    @RequiresPermissions("manage:record_invalidated_img:export")
    @Log(title = "轮挡报废图片记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordInvalidatedImg recordInvalidatedImg)
    {
        List<RecordInvalidatedImg> list = recordInvalidatedImgService.selectRecordInvalidatedImgList(recordInvalidatedImg);
        ExcelUtil<RecordInvalidatedImg> util = new ExcelUtil<RecordInvalidatedImg>(RecordInvalidatedImg.class);
        return util.exportExcel(list, "轮挡报废图片记录数据");
    }

    /**
     * 新增轮挡报废图片记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存轮挡报废图片记录
     */
    @RequiresPermissions("manage:record_invalidated_img:add")
    @Log(title = "轮挡报废图片记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordInvalidatedImg recordInvalidatedImg)
    {
        return toAjax(recordInvalidatedImgService.insertRecordInvalidatedImg(recordInvalidatedImg));
    }

    /**
     * 修改轮挡报废图片记录
     */
    @RequiresPermissions("manage:record_invalidated_img:edit")
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap)
    {
        RecordInvalidatedImg recordInvalidatedImg = recordInvalidatedImgService.selectRecordInvalidatedImgByObjid(objid);
        mmap.put("recordInvalidatedImg", recordInvalidatedImg);
        return prefix + "/edit";
    }

    /**
     * 修改保存轮挡报废图片记录
     */
    @RequiresPermissions("manage:record_invalidated_img:edit")
    @Log(title = "轮挡报废图片记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordInvalidatedImg recordInvalidatedImg)
    {
        return toAjax(recordInvalidatedImgService.updateRecordInvalidatedImg(recordInvalidatedImg));
    }

    /**
     * 删除轮挡报废图片记录
     */
    @RequiresPermissions("manage:record_invalidated_img:remove")
    @Log(title = "轮挡报废图片记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordInvalidatedImgService.deleteRecordInvalidatedImgByObjids(ids));
    }
}
