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.RecordInspectionImg;
import com.ruoyi.manage.service.IRecordInspectionImgService;
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_inspection_img")
public class RecordInspectionImgController extends BaseController
{
    private String prefix = "manage/record_inspection_img";

    @Autowired
    private IRecordInspectionImgService recordInspectionImgService;

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

    /**
     * 查询巡检历史图片列表
     */
    //@RequiresPermissions("manage:record_inspection_img:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordInspectionImg recordInspectionImg)
    {
        startPage();
        List<RecordInspectionImg> list = recordInspectionImgService.selectRecordInspectionImgList(recordInspectionImg);
        return getDataTable(list);
    }

    /**
     * 导出巡检历史图片列表
     */
    @RequiresPermissions("manage:record_inspection_img:export")
    @Log(title = "巡检历史图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordInspectionImg recordInspectionImg)
    {
        List<RecordInspectionImg> list = recordInspectionImgService.selectRecordInspectionImgList(recordInspectionImg);
        ExcelUtil<RecordInspectionImg> util = new ExcelUtil<RecordInspectionImg>(RecordInspectionImg.class);
        return util.exportExcel(list, "巡检历史图片数据");
    }

    /**
     * 新增巡检历史图片
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存巡检历史图片
     */
    @RequiresPermissions("manage:record_inspection_img:add")
    @Log(title = "巡检历史图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordInspectionImg recordInspectionImg)
    {
        return toAjax(recordInspectionImgService.insertRecordInspectionImg(recordInspectionImg));
    }

    /**
     * 修改巡检历史图片
     */
    @RequiresPermissions("manage:record_inspection_img:edit")
    @GetMapping("/edit/{inspectionId}")
    public String edit(@PathVariable("inspectionId") Long inspectionId, ModelMap mmap)
    {
        RecordInspectionImg recordInspectionImg = recordInspectionImgService.selectRecordInspectionImgByInspectionId(inspectionId);
        mmap.put("recordInspectionImg", recordInspectionImg);
        return prefix + "/edit";
    }

    /**
     * 修改保存巡检历史图片
     */
    @RequiresPermissions("manage:record_inspection_img:edit")
    @Log(title = "巡检历史图片", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordInspectionImg recordInspectionImg)
    {
        return toAjax(recordInspectionImgService.updateRecordInspectionImg(recordInspectionImg));
    }

    /**
     * 删除巡检历史图片
     */
    @RequiresPermissions("manage:record_inspection_img:remove")
    @Log(title = "巡检历史图片", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recordInspectionImgService.deleteRecordInspectionImgByInspectionIds(ids));
    }
}
