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.InspectionWaypoint;
import com.cmvr.inspection.domain.vo.InspectionWaypointVo;
import com.cmvr.inspection.service.IInspectionWaypointService;
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/waypoint")
@Api(tags = "智能巡检--点位管理")
public class InspectionWaypointController extends BaseController
{
    @Autowired
    private IInspectionWaypointService inspectionWaypointService;

    /**
     * 查询巡检点位列表
     */
    @ApiOperation("查询巡检点位列表")
    @PreAuthorize("@ss.hasPermi('inspection:waypoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(InspectionWaypoint inspectionWaypoint)
    {
        startPage();
        List<InspectionWaypointVo> list = inspectionWaypointService.selectInspectionWaypointList(inspectionWaypoint);
        return getDataTable(list);
    }

    /**
     * 导出巡检点位列表
     */
    @ApiOperation("导出巡检点位列表")
    @PreAuthorize("@ss.hasPermi('inspection:waypoint:export')")
    @Log(title = "巡检点位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionWaypoint inspectionWaypoint)
    {
        List<InspectionWaypointVo> list = inspectionWaypointService.selectInspectionWaypointList(inspectionWaypoint);
        ExcelUtil<InspectionWaypointVo> util = new ExcelUtil<>(InspectionWaypointVo.class);
        util.exportExcel(response, list, "巡检点位数据");
    }

    /**
     * 获取巡检点位详细信息
     */
    @ApiOperation("获取巡检点位详细信息")
    @PreAuthorize("@ss.hasPermi('inspection:waypoint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(inspectionWaypointService.selectInspectionWaypointById(id));
    }

    /**
     * 新增巡检点位
     */
    @ApiOperation("新增巡检点位")
    @PreAuthorize("@ss.hasPermi('inspection:waypoint:add')")
    @Log(title = "巡检点位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InspectionWaypoint inspectionWaypoint)
    {
        return toAjax(inspectionWaypointService.insertInspectionWaypoint(inspectionWaypoint));
    }

    /**
     * 修改巡检点位
     */
    @ApiOperation("修改巡检点位")
    @PreAuthorize("@ss.hasPermi('inspection:waypoint:edit')")
    @Log(title = "巡检点位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InspectionWaypoint inspectionWaypoint)
    {
        return toAjax(inspectionWaypointService.updateInspectionWaypoint(inspectionWaypoint));
    }

    /**
     * 删除巡检点位
     */
    @ApiOperation("删除巡检点位")
    @PreAuthorize("@ss.hasPermi('inspection:waypoint:remove')")
    @Log(title = "巡检点位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(inspectionWaypointService.deleteInspectionWaypointByIds(ids));
    }

}
