package com.cmvr.web.controller.inspection;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cmvr.common.annotation.Log;
import com.cmvr.common.core.controller.BaseController;
import com.cmvr.common.core.domain.AjaxResult;
import com.cmvr.common.enums.BusinessType;
import com.cmvr.inspection.domain.InspectionMap;
import com.cmvr.inspection.domain.vo.InspectionMapVo;
import com.cmvr.inspection.service.IInspectionMapService;
import com.cmvr.common.utils.poi.ExcelUtil;
import com.cmvr.common.core.page.TableDataInfo;

/**
 * 巡检地图Controller
 * 
 * @author cmvr-iot
 * @since 2026-05-29
 */
@RestController
@RequestMapping("/inspection/map")
@Api(tags = "智能巡检--地图管理")
public class InspectionMapController extends BaseController
{
    @Autowired
    private IInspectionMapService inspectionMapService;

    /**
     * 查询巡检地图列表
     */
    @ApiOperation("查询巡检地图列表")
    @PreAuthorize("@ss.hasPermi('inspection:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionMap inspectionMap)
    {
        startPage();
        List<InspectionMapVo> list = inspectionMapService.selectInspectionMapList(inspectionMap);
        return getDataTable(list);
    }

    /**
     * 导出巡检地图列表
     */
    @ApiOperation("导出巡检地图列表")
    @PreAuthorize("@ss.hasPermi('inspection:map:export')")
    @Log(title = "巡检地图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionMap inspectionMap)
    {
        List<InspectionMapVo> list = inspectionMapService.selectInspectionMapList(inspectionMap);
        ExcelUtil<InspectionMapVo> util = new ExcelUtil<>(InspectionMapVo.class);
        util.exportExcel(response, list, "巡检地图数据");
    }

    /**
     * 获取巡检地图详细信息
     */
    @ApiOperation("获取巡检地图详细信息")
    @PreAuthorize("@ss.hasPermi('inspection:map:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(inspectionMapService.selectInspectionMapById(id));
    }

    /**
     * 新增巡检地图
     */
    @ApiOperation("新增巡检地图")
    @PreAuthorize("@ss.hasPermi('inspection:map:add')")
    @Log(title = "巡检地图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionMap inspectionMap)
    {
        return toAjax(inspectionMapService.insertInspectionMap(inspectionMap));
    }

    /**
     * 修改巡检地图
     */
    @ApiOperation("修改巡检地图")
    @PreAuthorize("@ss.hasPermi('inspection:map:edit')")
    @Log(title = "巡检地图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionMap inspectionMap)
    {
        return toAjax(inspectionMapService.updateInspectionMap(inspectionMap));
    }

    /**
     * 删除巡检地图
     */
    @ApiOperation("删除巡检地图")
    @PreAuthorize("@ss.hasPermi('inspection:map:remove')")
    @Log(title = "巡检地图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(inspectionMapService.deleteInspectionMapByIds(ids));
    }
}
