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.FastGptRoleTag;
import com.fs.fastGpt.service.IFastGptRoleTagService;
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-11-04
 */
@RestController
@RequestMapping("/fastGpt/fastGptRoleTag")
public class FastGptRoleTagController extends BaseController
{
    @Autowired
    private IFastGptRoleTagService fastGptRoleTagService;

    /**
     * 查询AI的标签列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptRoleTag:list')")
    @GetMapping("/list")
    public TableDataInfo list(FastGptRoleTag fastGptRoleTag)
    {
        startPage();
        List<FastGptRoleTag> list = fastGptRoleTagService.selectFastGptRoleTagList(fastGptRoleTag);
        return getDataTable(list);
    }
    /**
     * 查询AI的标签列表根据roleid
     */
    @GetMapping("/getListByRoleId//{roleId}")
    public TableDataInfo getListByRoleId(@PathVariable("roleId") Long roleId)
    {
        startPage();
        List<FastGptRoleTag> list = fastGptRoleTagService.selectFastGptRoleTagListByRoleId(roleId);
        return getDataTable(list);
    }


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

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

    /**
     * 新增AI的标签
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptRoleTag:add')")
    @Log(title = "AI的标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FastGptRoleTag fastGptRoleTag)
    {
        return toAjax(fastGptRoleTagService.insertFastGptRoleTag(fastGptRoleTag));
    }

    /**
     * 修改AI的标签
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptRoleTag:edit')")
    @Log(title = "AI的标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FastGptRoleTag fastGptRoleTag)
    {
        return toAjax(fastGptRoleTagService.updateFastGptRoleTag(fastGptRoleTag));
    }

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