chore(addon/aikefu): 调整config的配置内容
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* 智能客服配置模型
|
||||
* 用于存储和管理智能客服的配置信息
|
||||
* 版本:1.0.0
|
||||
*/
|
||||
|
||||
namespace addon\aikefu\model;
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* 智能客服控制器
|
||||
*/
|
||||
|
||||
namespace addon\aikefu\shop\controller;
|
||||
|
||||
@@ -8,6 +11,9 @@ use addon\aikefu\model\Message as KefuMessageModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\facade\View;
|
||||
|
||||
/**
|
||||
* 智能客服 控制器
|
||||
*/
|
||||
class Kefu extends BaseShop
|
||||
{
|
||||
/**
|
||||
@@ -18,24 +24,24 @@ class Kefu extends BaseShop
|
||||
{
|
||||
$kefu_config_model = new KefuConfigModel();
|
||||
|
||||
if ($this->request->isJson()) {
|
||||
// 保存配置
|
||||
$params = $this->request->post();
|
||||
if (request()->isJson()) {
|
||||
$api_key = input("api_key", "");//Dify API密钥
|
||||
$base_url = input("base_url", "https://api.dify.ai/v1");//API基础地址
|
||||
$chat_endpoint = input("chat_endpoint", "/chat-messages");//聊天接口端点
|
||||
$status = input("status", 0);//状态
|
||||
|
||||
$data = [
|
||||
'api_key' => $params['api_key'] ?? '',
|
||||
'base_url' => $params['base_url'] ?? 'https://api.dify.ai/v1',
|
||||
'chat_endpoint' => $params['chat_endpoint'] ?? '/chat-messages',
|
||||
'status' => $params['status'] ?? 0,
|
||||
];
|
||||
|
||||
$result = $kefu_config_model->setConfig($data, $this->site_id);
|
||||
$data = array(
|
||||
"api_key" => $api_key,
|
||||
"base_url" => $base_url,
|
||||
"chat_endpoint" => $chat_endpoint,
|
||||
"status" => $status
|
||||
);
|
||||
$result = $kefu_config_model->setConfig($data, $this->site_id, $this->app_module);
|
||||
return $result;
|
||||
} else {
|
||||
// 获取配置
|
||||
$config_info = $kefu_config_model->getConfig($this->site_id, $this->app_module)['data']['value'] ?? [];
|
||||
$this->assign('config_info', $config_info);
|
||||
return $this->fetch('kefu/config');
|
||||
$this->assign("config_info", $config_info);
|
||||
return $this->fetch("kefu/config");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +51,7 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function conversation()
|
||||
{
|
||||
return View::fetch('kefu/conversation');
|
||||
return View::fetch("kefu/conversation");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,11 +60,10 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function getConversationList()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$page = $params['page'] ?? 1;
|
||||
$limit = $params['limit'] ?? 10;
|
||||
$user_id = $params['user_id'] ?? '';
|
||||
$status = $params['status'] ?? '';
|
||||
$page = input("page", 1);
|
||||
$limit = input("limit", 10);
|
||||
$user_id = input("user_id", "");
|
||||
$status = input("status", "");
|
||||
|
||||
$kefu_conversation_model = new KefuConversationModel();
|
||||
$condition = [['site_id', '=', $this->site_id]];
|
||||
@@ -82,8 +87,7 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function getConversationInfo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$conversation_id = $params['conversation_id'] ?? '';
|
||||
$conversation_id = input("conversation_id", "");
|
||||
|
||||
if (empty($conversation_id)) {
|
||||
return $this->error('会话ID不能为空');
|
||||
@@ -108,8 +112,7 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function endConversation()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$id = $params['id'] ?? '';
|
||||
$id = input("id", "");
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error('会话ID不能为空');
|
||||
@@ -133,8 +136,7 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function deleteConversation()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$id = $params['id'] ?? '';
|
||||
$id = input("id", "");
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->error('会话ID不能为空');
|
||||
@@ -183,9 +185,9 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
$conversation_id = $this->request->param('conversation_id') ?? '';
|
||||
View::assign('conversation_id', $conversation_id);
|
||||
return View::fetch('kefu/message');
|
||||
$conversation_id = input("conversation_id", "");
|
||||
View::assign("conversation_id", $conversation_id);
|
||||
return View::fetch("kefu/message");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,10 +196,9 @@ class Kefu extends BaseShop
|
||||
*/
|
||||
public function getMessageList()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$page = $params['page'] ?? 1;
|
||||
$limit = $params['limit'] ?? 50;
|
||||
$conversation_id = $params['conversation_id'] ?? '';
|
||||
$page = input("page", 1);
|
||||
$limit = input("limit", 50);
|
||||
$conversation_id = input("conversation_id", "");
|
||||
|
||||
if (empty($conversation_id)) {
|
||||
return $this->error('会话ID不能为空');
|
||||
|
||||
Reference in New Issue
Block a user