package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.RobotOpsFaq;
import com.ruoyi.base.service.IRobotOpsFaqService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 问答库管理Controller
 *
 * @author ruoyi
 * @date 2026-05-07
 */
@RestController
@RequestMapping("/base/faq")
public class RobotOpsFaqController extends BaseController
{
    @Autowired
    private IRobotOpsFaqService robotOpsFaqService;

    /**
     * 查询问答库管理列表
     */
    @PreAuthorize("@ss.hasPermi('base:faq:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotOpsFaq robotOpsFaq)
    {
        startPage();
        List<RobotOpsFaq> list = robotOpsFaqService.selectRobotOpsFaqList(robotOpsFaq);
        return getDataTable(list);
    }

    /**
     * 导出问答库管理列表
     */
    @PreAuthorize("@ss.hasPermi('base:faq:export')")
    @Log(title = "问答库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotOpsFaq robotOpsFaq)
    {
        List<RobotOpsFaq> list = robotOpsFaqService.selectRobotOpsFaqList(robotOpsFaq);
        ExcelUtil<RobotOpsFaq> util = new ExcelUtil<RobotOpsFaq>(RobotOpsFaq.class);
        util.exportExcel(response, list, "问答库管理数据");
    }

    /**
     * 获取问答库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:faq:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotOpsFaqService.selectRobotOpsFaqById(id));
    }

    /**
     * 新增问答库管理
     */
    @PreAuthorize("@ss.hasPermi('base:faq:add')")
    @Log(title = "问答库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotOpsFaq robotOpsFaq)
    {
        return toAjax(robotOpsFaqService.insertRobotOpsFaq(robotOpsFaq));
    }

    /**
     * 修改问答库管理
     */
    @PreAuthorize("@ss.hasPermi('base:faq:edit')")
    @Log(title = "问答库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotOpsFaq robotOpsFaq)
    {
        return toAjax(robotOpsFaqService.updateRobotOpsFaq(robotOpsFaq));
    }

    /**
     * 删除问答库管理
     */
    @PreAuthorize("@ss.hasPermi('base:faq:remove')")
    @Log(title = "问答库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotOpsFaqService.deleteRobotOpsFaqByIds(ids));
    }
}
