mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 02:22:48 +08:00
feat: 发布智能体版
This commit is contained in:
@@ -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}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user