ChatController.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @remark :
* @name :ChatController.php
* @author :lyh
* @method :post
* @time :2025/4/1 14:33
*/
namespace App\Http\Controllers\Bside\Gpt;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Gpt\ChatLogic;
use App\Models\Gpt\Chat;
use App\Models\Gpt\ChatItem;
class ChatController extends BaseController
{
/**
* @remark :获取消息列表
* @name :list
* @author :lyh
* @method :post
* @time :2025/4/2 15:51
*/
public function list(Chat $chat){
$list = $chat->lists(['user_id'=>$this->user['id'],'status'=>1],$this->page,$this->row);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :获取所有子消息
* @name :itemList
* @author :lyh
* @method :post
* @time :2025/4/2 15:55
*/
public function itemList(ChatItem $chatItem){
$this->request->validate([
'chat_id'=>['required'],
],[
'chat_id.required' => 'chat_id不能为空',
]);
$list = $chatItem->list(['user_id'=>$this->user['id'],'chat_id'=>$this->map['chat_id'],'status'=>1]);
$this->response('success',Code::SUCCESS,$list);
}
/**
* @remark :发送消息
* @name :sendMessage
* @author :lyh
* @method :post
* @time :2025/4/1 14:35
*/
public function sendMessage(ChatLogic $logic){
$this->request->validate([
'message'=>['required'],
],[
'message.required' => '消息内容不能为空',
]);
$data = $logic->sendMessage();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :删除消息
* @name :del
* @author :lyh
* @method :post
* @time :2025/4/2 15:54
*/
public function del(Chat $chat){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => 'id不能为空',
]);
$data = $chat->edit(['status'=>0],['id'=>$this->param['id']]);
$this->response('success',Code::SUCCESS,$data);
}
}