package com.ruoyi.web.controller.ai;

import com.ruoyi.ai.domain.AiHelp;
import com.ruoyi.ai.service.IAiHelpService;
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 io.swagger.annotations.ApiOperation;
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;
import java.util.List;

/**
 * 【帮助管理】Controller
 * 
 * @author shi
 * @date 2025-11-13
 */
@RestController
@RequestMapping("/ai/help")
public class AiHelpController extends BaseController
{
    @Autowired
    private IAiHelpService aiHelpService;

    /**
     * 查询【帮助管理】列表
     */
    @PreAuthorize("@ss.hasPermi('ai:help:list')")
    @GetMapping("/list")
    public TableDataInfo list(AiHelp aiHelp)
    {
        startPage();
        List<AiHelp> list = aiHelpService.selectAiHelpList(aiHelp);
        return getDataTable(list);
    }

    /**
     * 导出【帮助管理】列表
     */
    @PreAuthorize("@ss.hasPermi('ai:help:export')")
    @Log(title = "【帮助管理】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AiHelp aiHelp)
    {
        List<AiHelp> list = aiHelpService.selectAiHelpList(aiHelp);
        ExcelUtil<AiHelp> util = new ExcelUtil<AiHelp>(AiHelp.class);
        util.exportExcel(response, list, "【帮助管理】数据");
    }

    /**
     * 获取【帮助管理】详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:help:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aiHelpService.selectAiHelpById(id));
    }

    /**
     * 新增【帮助管理】
     */
    @PreAuthorize("@ss.hasPermi('ai:help:add')")
    @Log(title = "【帮助管理】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AiHelp aiHelp)
    {
        return toAjax(aiHelpService.insertAiHelp(aiHelp));
    }

    /**
     * 修改【帮助管理】
     */
    @PreAuthorize("@ss.hasPermi('ai:help:edit')")
    @Log(title = "【帮助管理】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AiHelp aiHelp)
    {
        return toAjax(aiHelpService.updateAiHelp(aiHelp));
    }

    /**
     * 删除【帮助管理】
     */
    @PreAuthorize("@ss.hasPermi('ai:help:remove')")
    @Log(title = "【帮助管理】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aiHelpService.deleteAiHelpByIds(ids));
    }
}
