feat: 发布智能体版

This commit is contained in:
augushong
2026-03-26 20:22:34 +08:00
parent 7ee9e102a5
commit 8cc08bcb8c
138 changed files with 7964 additions and 660 deletions

View File

@@ -263,6 +263,11 @@ class BuildCurdServiceBase
{
$this->table = $table;
// 自动检测并处理表前缀
// 支持用户输入带前缀ul_daka_record或不带前缀daka_record两种方式
// 注意tablePrefix 可能已包含下划线(如 'ul_'),需要先检测
$this->table = $this->stripTablePrefix($this->table);
$schemeClass = 'app\\admin\\scheme\\' . Str::studly($this->table);
if (!class_exists($schemeClass)) {
throw new TableException("未找到 {$schemeClass}请先执行php think scheme:make -t {$this->table} 或手动创建 Scheme");
@@ -352,6 +357,28 @@ class BuildCurdServiceBase
return $controllerFilename;
}
/**
* 去除表前缀.
* @param string $tableName
* @return string
*/
protected function stripTablePrefix($tableName)
{
$prefixToStrip = $this->tablePrefix;
// 如果 tablePrefix 不以 _ 结尾,加上下划线
if (!str_ends_with($prefixToStrip, '_')) {
$prefixToStrip .= '_';
}
if (str_starts_with($tableName, $prefixToStrip)) {
// 用户输入了带前缀的表名,自动去除前缀
return substr($tableName, strlen($prefixToStrip));
}
return $tableName;
}
/**
* 设置关联表.
* @param $relationTable
@@ -365,6 +392,9 @@ class BuildCurdServiceBase
*/
public function setRelation($relationTable, $foreignKey, $primaryKey = null, $modelFilename = null, $onlyShowFileds = [], $bindSelectField = null)
{
// 自动检测并处理关联表前缀(与 setTable 保持一致)
$relationTable = $this->stripTablePrefix($relationTable);
if (!isset($this->tableColumns[$foreignKey])) {
throw new TableException("主表不存在外键字段:{$foreignKey}");
}