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.CmcChat;
import com.ruoyi.llm.service.ICmcChatService;
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/chat")
public class CmcChatController extends BaseController
{
    @Autowired
    private ICmcChatService cmcChatService;

    /**
     * 查询cmc聊天记录列表
     */
    @PreAuthorize("@ss.hasPermi('llm:chat:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmcChat cmcChat)
    {
        startPage();
        List<CmcChat> list = cmcChatService.selectCmcChatList(cmcChat);
        return getDataTable(list);
    }

    /**
     * 导出cmc聊天记录列表
     */
    @PreAuthorize("@ss.hasPermi('llm:chat:export')")
    @Log(title = "cmc聊天记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmcChat cmcChat)
    {
        List<CmcChat> list = cmcChatService.selectCmcChatList(cmcChat);
        ExcelUtil<CmcChat> util = new ExcelUtil<CmcChat>(CmcChat.class);
        util.exportExcel(response, list, "cmc聊天记录数据");
    }

    /**
     * 获取cmc聊天记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('llm:chat:query')")
    @GetMapping(value = "/{chatId}")
    public AjaxResult getInfo(@PathVariable("chatId") String chatId)
    {
        return success(cmcChatService.selectCmcChatByChatId(chatId));
    }

    /**
     * 新增cmc聊天记录
     */
    @PreAuthorize("@ss.hasPermi('llm:chat:add')")
    @Log(title = "cmc聊天记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmcChat cmcChat)
    {
        return toAjax(cmcChatService.insertCmcChat(cmcChat));
    }

    /**
     * 修改cmc聊天记录
     */
    @PreAuthorize("@ss.hasPermi('llm:chat:edit')")
    @Log(title = "cmc聊天记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmcChat cmcChat)
    {
        return toAjax(cmcChatService.updateCmcChat(cmcChat));
    }

    /**
     * 删除cmc聊天记录
     */
    @PreAuthorize("@ss.hasPermi('llm:chat:remove')")
    @Log(title = "cmc聊天记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chatIds}")
    public AjaxResult remove(@PathVariable String[] chatIds)
    {
        return toAjax(cmcChatService.deleteCmcChatByChatIds(chatIds));
    }
}
