package com.fs.fastGpt;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.fastGpt.domain.FastGptChatReplaceText;
import com.fs.fastGpt.service.IFastGptChatReplaceTextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 易错词语Controller
 *
 * @author fs
 * @date 2025-01-18
 */
@RestController
@RequestMapping("/fastGpt/fastGptChatReplaceText")
public class FastGptChatReplaceTextController extends BaseController
{
    @Autowired
    private IFastGptChatReplaceTextService fastGptChatReplaceTextService;

    /**
     * 查询易错词语列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatReplaceText:list')")
    @GetMapping("/list")
    public TableDataInfo list(FastGptChatReplaceText fastGptChatReplaceText)
    {
        startPage();
        List<FastGptChatReplaceText> list = fastGptChatReplaceTextService.selectFastGptChatReplaceTextList(fastGptChatReplaceText);
        return getDataTable(list);
    }

    /**
     * 导出易错词语列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatReplaceText:export')")
    @Log(title = "易错词语", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FastGptChatReplaceText fastGptChatReplaceText)
    {
        List<FastGptChatReplaceText> list = fastGptChatReplaceTextService.selectFastGptChatReplaceTextList(fastGptChatReplaceText);
        ExcelUtil<FastGptChatReplaceText> util = new ExcelUtil<FastGptChatReplaceText>(FastGptChatReplaceText.class);
        return util.exportExcel(list, "易错词语数据");
    }

    /**
     * 获取易错词语详细信息
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatReplaceText:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fastGptChatReplaceTextService.selectFastGptChatReplaceTextById(id));
    }

    /**
     * 新增易错词语
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatReplaceText:add')")
    @Log(title = "易错词语", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FastGptChatReplaceText fastGptChatReplaceText)
    {
        return toAjax(fastGptChatReplaceTextService.insertFastGptChatReplaceText(fastGptChatReplaceText));
    }

    /**
     * 修改易错词语
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatReplaceText:edit')")
    @Log(title = "易错词语", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FastGptChatReplaceText fastGptChatReplaceText)
    {
        return toAjax(fastGptChatReplaceTextService.updateFastGptChatReplaceText(fastGptChatReplaceText));
    }

    /**
     * 删除易错词语
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatReplaceText:remove')")
    @Log(title = "易错词语", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fastGptChatReplaceTextService.deleteFastGptChatReplaceTextByIds(ids));
    }
}
