package com.easyproject.web.controller.aichat;

import java.util.List;

import com.easyproject.common.annotation.Log;
import com.easyproject.common.enums.BusinessType;
import com.easyproject.service.domain.aichat.BotConversation;
import com.easyproject.system.service.aichat.IBotConversationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.easyproject.common.core.controller.BaseController;
import com.easyproject.common.core.domain.AjaxResult;
import com.easyproject.common.core.page.TableDataInfo;

/**
 * 会话列表Controller
 *
 * @author easyproject
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/system/conversation")
public class BotConversationController extends BaseController {
    @Autowired
    private IBotConversationService botConversationService;

    /**
     * 查询会话列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:conversation:list')")
    @GetMapping("/list")
    public TableDataInfo list(BotConversation botConversation) {
        startPage();
        List<BotConversation> list = botConversationService.selectBotConversationList(botConversation);
        return getDataTable(list);
    }

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

    /**
     * 设置备注
     */
    @PreAuthorize("@ss.hasPermi('system:conversation:edit')")
    @Log(title = "设置备注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BotConversation botConversation) {
        return botConversationService.updateBotConversation(botConversation);
    }

    /**
     * 查询会话的对话列表（对话详情）
     */
    @PreAuthorize("@ss.hasPermi('system:conversation:query')")
    @GetMapping(value = "/getConversationChatList/{conversationId}")
    public AjaxResult getConversationChatList(@PathVariable("conversationId") Long conversationId) {
        return botConversationService.getConversationChatList(conversationId);
    }

}
