package com.ruoyi.inspection.controller;

import java.util.List;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.inspection.domain.InspectionManageTable;
import com.ruoyi.inspection.service.IInspectionManageTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 巡检点管理Controller
 *
 * @author ruoyi
 * @date 2024-08-29
 */
@RestController
@RequestMapping("/inspection/manage")
public class InspectionManageTableController extends BaseController {
    @Autowired
    private IInspectionManageTableService inspectionManageTableService;

    /**
     * 查询巡检点管理列表
     */
    @PreAuthorize("@ss.hasPermi('inspection:manage:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionManageTable inspectionManageTable) {
        startPage();
        List<InspectionManageTable> list = inspectionManageTableService.selectInspectionManageTableList(inspectionManageTable);
        return getDataTable(list);
    }

    /**
     * 导出巡检点管理列表
     */

    @PreAuthorize("@ss.hasPermi('inspection:manage:export')")
    @Log(title = "巡检点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionManageTable inspectionManageTable) {
        List<InspectionManageTable> list = inspectionManageTableService.selectInspectionManageTableList(inspectionManageTable);
        ExcelUtil<InspectionManageTable> util = new ExcelUtil<InspectionManageTable>(InspectionManageTable.class);
        util.exportExcel(response, list, "巡检点管理数据");
    }

    /**
     * 获取巡检点管理详细信息
     */

    @PreAuthorize("@ss.hasPermi('inspection:manage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(inspectionManageTableService.selectInspectionManageTableById(id));
    }

    /**
     * 新增巡检点管理
     */

    @PreAuthorize("@ss.hasPermi('inspection:manage:add')")
    @Log(title = "巡检点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionManageTable inspectionManageTable) {
        return toAjax(inspectionManageTableService.insertInspectionManageTable(inspectionManageTable));
    }

    /**
     * 修改巡检点管理
     */

    @PreAuthorize("@ss.hasPermi('inspection:manage:edit')")
    @Log(title = "巡检点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionManageTable inspectionManageTable) {
        return toAjax(inspectionManageTableService.updateInspectionManageTable(inspectionManageTable));
    }

    /**
     * 删除巡检点管理
     */
    @PreAuthorize("@ss.hasPermi('inspection:manage:remove')")
    @Log(title = "巡检点管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(inspectionManageTableService.deleteInspectionManageTableByIds(ids));
    }
}
