coze部分接口
This commit is contained in:
60
Server/application/cozeai/model/Conversation.php
Normal file
60
Server/application/cozeai/model/Conversation.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\cozeai\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* Coze AI 对话模型
|
||||
*/
|
||||
class Conversation extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'coze_conversation';
|
||||
|
||||
// 设置主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 设置字段
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'conversation_id' => 'string',
|
||||
'workspace_id' => 'string',
|
||||
'bot_id' => 'string',
|
||||
'title' => 'string',
|
||||
'create_time' => 'datetime',
|
||||
'update_time' => 'datetime'
|
||||
];
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
/**
|
||||
* 根据对话ID获取对话信息
|
||||
*/
|
||||
public function getByConversationId($conversationId)
|
||||
{
|
||||
return $this->where('conversation_id', $conversationId)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存对话信息
|
||||
*/
|
||||
public function saveConversation($data)
|
||||
{
|
||||
$conversation = $this->getByConversationId($data['conversation_id']);
|
||||
if ($conversation) {
|
||||
return $this->where('conversation_id', $data['conversation_id'])->update($data);
|
||||
} else {
|
||||
return $this->save($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除对话
|
||||
*/
|
||||
public function deleteConversation($conversationId)
|
||||
{
|
||||
return $this->where('conversation_id', $conversationId)->delete();
|
||||
}
|
||||
}
|
||||
64
Server/application/cozeai/model/Workspace.php
Normal file
64
Server/application/cozeai/model/Workspace.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\cozeai\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* Coze AI 工作区模型
|
||||
*/
|
||||
class Workspace extends Model
|
||||
{
|
||||
// 设置当前模型对应的完整数据表名称
|
||||
protected $name = 'coze_workspace';
|
||||
|
||||
// 设置主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 设置字段信息
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'workspace_id' => 'string',
|
||||
'name' => 'string',
|
||||
'description' => 'string',
|
||||
'create_time' => 'datetime',
|
||||
'update_time' => 'datetime'
|
||||
];
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_time';
|
||||
protected $updateTime = 'update_time';
|
||||
|
||||
/**
|
||||
* 根据工作区ID获取工作区信息
|
||||
*/
|
||||
public function getByWorkspaceId($workspaceId)
|
||||
{
|
||||
return $this->where('workspace_id', $workspaceId)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存工作区信息
|
||||
*/
|
||||
public function saveWorkspace($data)
|
||||
{
|
||||
$workspace = $this->getByWorkspaceId($data['workspace_id']);
|
||||
|
||||
if ($workspace) {
|
||||
// 更新
|
||||
return $this->where('workspace_id', $data['workspace_id'])->update($data);
|
||||
} else {
|
||||
// 新增
|
||||
return $this->save($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工作区
|
||||
*/
|
||||
public function deleteWorkspace($workspaceId)
|
||||
{
|
||||
return $this->where('workspace_id', $workspaceId)->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user