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.RecordInspectionTask;
import com.ruoyi.manage.service.IRecordInspectionTaskService;
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-25
 */
@Controller
@RequestMapping("/manage/record_inspection_task")
public class RecordInspectionTaskController extends BaseController {
    private String prefix = "manage/record_inspection_task";

    @Autowired
    private IRecordInspectionTaskService recordInspectionTaskService;

    @RequiresPermissions("manage:record_inspection_task:view")
    @GetMapping("/{id}")
    public String record_inspection_task(@PathVariable("id") String id,ModelMap mmap) {
        mmap.put("inspetionId",id);
        System.out.println(id);
        return prefix + "/record_inspection_task";
    }
    @RequiresPermissions("manage:record_inspection_task:view")
    @GetMapping()
    public String record_inspection_task() {
        return prefix + "/record_inspection_task";
    }

    /**
     * 查询巡检机位信息列表
     */
    @RequiresPermissions("manage:record_inspection_task:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecordInspectionTask recordInspectionTask) {
        startPage();
        List<RecordInspectionTask> list = recordInspectionTaskService.selectRecordInspectionTaskList(recordInspectionTask);
        return getDataTable(list);
    }

    /**
     * 导出巡检机位信息列表
     */
    @RequiresPermissions("manage:record_inspection_task:export")
    @Log(title = "巡检机位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecordInspectionTask recordInspectionTask) {
        List<RecordInspectionTask> list = recordInspectionTaskService.selectRecordInspectionTaskList(recordInspectionTask);
        ExcelUtil<RecordInspectionTask> util = new ExcelUtil<RecordInspectionTask>(RecordInspectionTask.class);
        return util.exportExcel(list, "巡检机位信息数据");
    }

    /**
     * 新增巡检机位信息
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存巡检机位信息
     */
    @RequiresPermissions("manage:record_inspection_task:add")
    @Log(title = "巡检机位信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecordInspectionTask recordInspectionTask) {
        return toAjax(recordInspectionTaskService.insertRecordInspectionTask(recordInspectionTask));
    }

    /**
     * 修改巡检机位信息
     */
    @RequiresPermissions("manage:record_inspection_task:edit")
    @GetMapping("/edit/{objid}")
    public String edit(@PathVariable("objid") Long objid, ModelMap mmap) {
        RecordInspectionTask recordInspectionTask = recordInspectionTaskService.selectRecordInspectionTaskByObjid(objid);
        mmap.put("recordInspectionTask", recordInspectionTask);
        return prefix + "/edit";
    }

    /**
     * 修改保存巡检机位信息
     */
    @RequiresPermissions("manage:record_inspection_task:edit")
    @Log(title = "巡检机位信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecordInspectionTask recordInspectionTask) {
        return toAjax(recordInspectionTaskService.updateRecordInspectionTask(recordInspectionTask));
    }

    /**
     * 删除巡检机位信息
     */
    @RequiresPermissions("manage:record_inspection_task:remove")
    @Log(title = "巡检机位信息", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(recordInspectionTaskService.deleteRecordInspectionTaskByObjids(ids));
    }
}
