package com.fs.company.controller.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.FastgptTag;
import com.fs.fastGpt.service.IFastgptTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ai标签Controller
 *
 * @author fs
 * @date 2024-12-20
 */
@RestController
@RequestMapping("/fastGpt/FastgptTag")
public class FastgptTagController extends BaseController
{
    @Autowired
    private IFastgptTagService fastgptTagService;

    /**
     * 查询ai标签列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:FastgptTag:list')")
    @GetMapping("/list")
    public TableDataInfo list(FastgptTag fastgptTag)
    {
        startPage();
        List<FastgptTag> list = fastgptTagService.selectFastgptTagList(fastgptTag);
        return getDataTable(list);
    }

    /**
     * 导出ai标签列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:FastgptTag:export')")
    @Log(title = "ai标签", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FastgptTag fastgptTag)
    {
        List<FastgptTag> list = fastgptTagService.selectFastgptTagList(fastgptTag);
        ExcelUtil<FastgptTag> util = new ExcelUtil<FastgptTag>(FastgptTag.class);
        return util.exportExcel(list, "ai标签数据");
    }

    /**
     * 获取ai标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:FastgptTag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fastgptTagService.selectFastgptTagById(id));
    }

    /**
     * 新增ai标签
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:FastgptTag:add')")
    @Log(title = "ai标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FastgptTag fastgptTag)
    {
        return toAjax(fastgptTagService.insertFastgptTag(fastgptTag));
    }

    /**
     * 修改ai标签
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:FastgptTag:edit')")
    @Log(title = "ai标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FastgptTag fastgptTag)
    {
        return toAjax(fastgptTagService.updateFastgptTag(fastgptTag));
    }

    /**
     * 删除ai标签
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:FastgptTag:remove')")
    @Log(title = "ai标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fastgptTagService.deleteFastgptTagByIds(ids));
    }
}
