* check AI assistant name is duplicated or not.

This commit is contained in:
Chenjianyu
2024-04-02 15:06:20 +08:00
parent d4552152ab
commit 40e10fbd4e
6 changed files with 24 additions and 0 deletions
+6
View File
@@ -358,6 +358,9 @@ class ai extends control
}
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$exists = $this->ai->checkAssistantDuplicate($assistant->name, $assistant->modelId);
if($exists) return $this->send(array('result' => 'fail', 'message' => array('name' => $this->lang->ai->assistants->duplicateTip)));
if(empty($assistant->publish))
{
$this->ai->createAssistant($assistant);
@@ -405,6 +408,9 @@ class ai extends control
}
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$exists = $this->ai->checkAssistantDuplicate($assistant->name, $assistant->modelId);
if($exists) return $this->send(array('result' => 'fail', 'message' => array('name' => $this->lang->ai->assistants->duplicateTip)));
$assistant->id = $assistantId;
$this->ai->updateAssistant($assistant);
+1
View File
@@ -987,6 +987,7 @@ $lang->ai->assistants->publish = 'Publish';
$lang->ai->assistants->withdraw = 'Disable';
$lang->ai->assistants->confirmPublishTip = 'After publishing, it will be displayed in the AI dialogue and client dialogue in the lower right corner of ZenTao. Do you want to confirm the publication? ';
$lang->ai->assistants->confirmWithdrawTip = 'After deactivation, front-end users will not be able to see this AI assistant. Do you confirm the deactivation? ';
$lang->ai->assistants->duplicateTip = 'Assistant names in the same language model cannot be same.';
$lang->ai->assistants->statusList = array();
$lang->ai->assistants->statusList['0'] = 'Unpublished';
+1
View File
@@ -987,6 +987,7 @@ $lang->ai->assistants->publish = 'Publish';
$lang->ai->assistants->withdraw = 'Disable';
$lang->ai->assistants->confirmPublishTip = 'After publishing, it will be displayed in the AI dialogue and client dialogue in the lower right corner of ZenTao. Do you want to confirm the publication? ';
$lang->ai->assistants->confirmWithdrawTip = 'After deactivation, front-end users will not be able to see this AI assistant. Do you confirm the deactivation? ';
$lang->ai->assistants->duplicateTip = 'Assistant names in the same language model cannot be same.';
$lang->ai->assistants->statusList = array();
$lang->ai->assistants->statusList['0'] = 'Unpublished';
+1
View File
@@ -987,6 +987,7 @@ $lang->ai->assistants->publish = 'Publish';
$lang->ai->assistants->withdraw = 'Disable';
$lang->ai->assistants->confirmPublishTip = 'After publishing, it will be displayed in the AI dialogue and client dialogue in the lower right corner of ZenTao. Do you want to confirm the publication? ';
$lang->ai->assistants->confirmWithdrawTip = 'After deactivation, front-end users will not be able to see this AI assistant. Do you confirm the deactivation? ';
$lang->ai->assistants->duplicateTip = 'Assistant names in the same language model cannot be same.';
$lang->ai->assistants->statusList = array();
$lang->ai->assistants->statusList['0'] = 'Unpublished';
+1
View File
@@ -987,6 +987,7 @@ $lang->ai->assistants->publish = '发布';
$lang->ai->assistants->withdraw = '停用';
$lang->ai->assistants->confirmPublishTip = '发布后将显示在禅道右下角AI对话和客户端对话中,是否确认发布?';
$lang->ai->assistants->confirmWithdrawTip = '停用后前台用户将无法看到此AI助手,是否确认停用?';
$lang->ai->assistants->duplicateTip = '同一语言模型下的助手名称不可重复。';
$lang->ai->assistants->statusList = array();
$lang->ai->assistants->statusList['0'] = '未发布';
+14
View File
@@ -2825,6 +2825,20 @@ class aiModel extends model
return true;
}
/**
* Find assistants name is duplicate.
* @param string $AssistantName
* @param int $modelId
* @access public
* @return bool
*/
public function checkAssistantDuplicate($AssistantName, $modelId)
{
return $this->dao->select('*')->from(TABLE_AI_ASSISTANT)
->where('name')->eq($AssistantName)
->andWhere('modelId')->eq($modelId)
->fetch();
}
}
/**