Update: 2026-05-08 04:58:23
This commit is contained in:
29
app/modules_app/chatbot/history.php
Normal file
29
app/modules_app/chatbot/history.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Chatbot History
|
||||
* GET /v1/chatbot/history
|
||||
* Returns user's recent chatbot conversations.
|
||||
*/
|
||||
|
||||
use App\Core\Database;
|
||||
use App\Middleware\AuthMiddleware;
|
||||
|
||||
$decoded = AuthMiddleware::check();
|
||||
$db = Database::getInstance();
|
||||
|
||||
$pagination = paginate_params(20, 50);
|
||||
|
||||
$countStmt = $db->prepare("SELECT COUNT(*) FROM chatbot_history WHERE user_id = ?");
|
||||
$countStmt->execute([$decoded['user_id']]);
|
||||
$total = (int)$countStmt->fetchColumn();
|
||||
|
||||
$stmt = $db->prepare("
|
||||
SELECT id, question, answer, created_at
|
||||
FROM chatbot_history
|
||||
WHERE user_id = ?
|
||||
ORDER BY created_at DESC
|
||||
LIMIT {$pagination['limit']} OFFSET {$pagination['offset']}
|
||||
");
|
||||
$stmt->execute([$decoded['user_id']]);
|
||||
|
||||
json_paginated($stmt->fetchAll(), $total, $pagination);
|
||||
Reference in New Issue
Block a user