Commit 47edf098 by feixiang

对照分表处理

parent 8c9fb173
......@@ -103,13 +103,39 @@ class CommonEntity extends Model
$dbNum = self::getDbNum();
$tableName = self::getTableName($commentString).'_'.$dbNum;
//self::setTableName($tableName);
return $tableName;
} else {
return self::getTableName($commentString);
$tableName = self::getTableName($commentString);
}
$newTableName = self::newTableName();
if ( $tableName != $newTableName ) { //校验新的分表规则
App::error("[新分表异常][对比失败]oldFunction".$tableName.'new function'.$newTableName);
}
return $tableName;
}
private static function newTableName()
{
if ( empty(RequestContext::getContextData()) ) {//初始化不做处理
return;
}
$entityCollector = EntityCollector::getCollector();
$splitCollector = SplitCollector::getCollector();//分表搜集器
$className = static::class;
$tableName = $entityCollector[$className]['table']['name'];
if ( isset($splitCollector[$className]) ) { //分表
$dbNum = (new Split())->getDbNum($className);
$tableName = $tableName.'_'.$dbNum;
}
return $tableName;
}
/**
......
......@@ -58,7 +58,7 @@ class Split
return $tableName;
}
private function getDbNum($className)
public function getDbNum($className)
{
$splitCollector = SplitCollector::getCollector();
$splitNum = $splitCollector[$className]['num'];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment