package com.easyproject.web.controller.aichat;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.easyproject.service.domain.aichat.BotConversationChat;
import com.easyproject.system.service.aichat.IBotConversationChatService;
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.easyproject.common.annotation.Log;
import com.easyproject.common.core.controller.BaseController;
import com.easyproject.common.core.domain.AjaxResult;
import com.easyproject.common.enums.BusinessType;
import com.easyproject.common.core.page.TableDataInfo;

/**
 * 对话列表Controller
 *
 * @author easyproject
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/system/conversationChat")
public class BotConversationChatController extends BaseController {
    @Autowired
    private IBotConversationChatService botConversationChatService;

    /**
     * 查询对话列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:conversationChat:list')")
    @GetMapping("/list")
    public TableDataInfo list(BotConversationChat botConversationChat) {
        startPage();
        List<BotConversationChat> list = botConversationChatService.selectBotConversationChatList(botConversationChat);
        return getDataTable(list);
    }

    /**
     * 获取对话列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:conversationChat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(botConversationChatService.selectBotConversationChatById(id));
    }

    /**
     * 详情
     */
    @PreAuthorize("@ss.hasPermi('system:conversationChat:query')")
    @GetMapping(value = "/getConversationChatMsg/{id}")
    public AjaxResult getConversationChatMsg(@PathVariable("id") Long id) {
        return botConversationChatService.getConversationChatMsg(id);
    }

    /**
     * 设为知识库文件
     */
    @PreAuthorize("@ss.hasPermi('system:conversationChat:edit')")
    @Log(title = "设为知识库", businessType = BusinessType.UPDATE)
    @PutMapping("/setknowledgeFile")
    public AjaxResult setknowledgeFile(@RequestBody BotConversationChat botConversationChat)
    {
        return botConversationChatService.setknowledgeFile(botConversationChat);
    }
}
