package com.ruoyi.sim.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.sim.service.impl.DebugFaultService;
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.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.sim.domain.DebugFault;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调试故障Controller
 *
 * @author tom
 * @date 2025-02-10
 */
@RestController
@RequestMapping("/sim/debug-fault")
public class DebugFaultController extends BaseController {
    @Autowired
    private DebugFaultService debugFaultService;

    /**
     * 查询调试故障列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DebugFault debugFault) {
        startPage();
        List<DebugFault> list = debugFaultService.selectDebugFaultList(debugFault);
        return getDataTable(list);
    }

    /**
     * 获取调试故障详细信息
     */
    @GetMapping(value = "/{refId}")
    public AjaxResult getInfo(@PathVariable("refId") Long refId) {
        return success(debugFaultService.selectDebugFaultByRefId(refId));
    }

    /**
     * 新增调试故障
     */
    @PostMapping
    public AjaxResult add(@RequestBody DebugFault debugFault) {
        return toAjax(debugFaultService.insertDebugFault(debugFault));
    }

    /**
     * 修改调试故障
     */
    @PutMapping
    public AjaxResult edit(@RequestBody DebugFault debugFault) {
        return toAjax(debugFaultService.updateDebugFault(debugFault));
    }

    /**
     * 删除调试故障
     */
    @DeleteMapping("/{refIds}")
    public AjaxResult remove(@PathVariable Long[] refIds) {
        return toAjax(debugFaultService.deleteDebugFaultByRefIds(refIds));
    }
}
