package com.ruoyi.web.controller.llm;

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.llm.domain.CmcTopic;
import com.ruoyi.llm.service.ICmcTopicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cmc聊天主题Controller
 * 
 * @author cmc
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/llm/topic")
public class CmcTopicController extends BaseController
{
    @Autowired
    private ICmcTopicService cmcTopicService;

    /**
     * 查询cmc聊天主题列表
     */
    @PreAuthorize("@ss.hasPermi('llm:topic:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmcTopic cmcTopic)
    {
        startPage();
        List<CmcTopic> list = cmcTopicService.selectCmcTopicList(cmcTopic);
        return getDataTable(list);
    }

    /**
     * 导出cmc聊天主题列表
     */
    @PreAuthorize("@ss.hasPermi('llm:topic:export')")
    @Log(title = "cmc聊天主题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcTopic cmcTopic)
    {
        List<CmcTopic> list = cmcTopicService.selectCmcTopicList(cmcTopic);
        ExcelUtil<CmcTopic> util = new ExcelUtil<CmcTopic>(CmcTopic.class);
        util.exportExcel(response, list, "cmc聊天主题数据");
    }

    /**
     * 获取cmc聊天主题详细信息
     */
    @PreAuthorize("@ss.hasPermi('llm:topic:query')")
    @GetMapping(value = "/{topicId}")
    public AjaxResult getInfo(@PathVariable("topicId") String topicId)
    {
        return success(cmcTopicService.selectCmcTopicByTopicId(topicId));
    }

    /**
     * 新增cmc聊天主题
     */
    @PreAuthorize("@ss.hasPermi('llm:topic:add')")
    @Log(title = "cmc聊天主题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcTopic cmcTopic)
    {
        return toAjax(cmcTopicService.insertCmcTopic(cmcTopic));
    }

    /**
     * 修改cmc聊天主题
     */
    @PreAuthorize("@ss.hasPermi('llm:topic:edit')")
    @Log(title = "cmc聊天主题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcTopic cmcTopic)
    {
        return toAjax(cmcTopicService.updateCmcTopic(cmcTopic));
    }

    /**
     * 删除cmc聊天主题
     */
    @PreAuthorize("@ss.hasPermi('llm:topic:remove')")
    @Log(title = "cmc聊天主题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{topicIds}")
    public AjaxResult remove(@PathVariable String[] topicIds)
    {
        return toAjax(cmcTopicService.deleteCmcTopicByTopicIds(topicIds));
    }
}
