Commit f1d74d8a by feixiang

单元测试 分表处理

parent c090b428
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Hdll\Services\Common\Entity; namespace Hdll\Services\Common\Entity;
use Hdll\Services\Common\Bean\Collector\SplitCollector; use Hdll\Services\Common\Bean\Collector\SplitCollector;
use Hdll\Services\Common\Enum\TestEnum;
use Hdll\Services\Common\Exception\CommonException; use Hdll\Services\Common\Exception\CommonException;
use Swoft\Core\RequestContext; use Swoft\Core\RequestContext;
use Swoft\Db\Bean\Collector\EntityCollector; use Swoft\Db\Bean\Collector\EntityCollector;
...@@ -23,6 +24,7 @@ class Split ...@@ -23,6 +24,7 @@ class Split
$map = array_flip($collector['map']); $map = array_flip($collector['map']);
} }
if ( ! self::isTesting() ) {
//如果是实体且为分表实体 //如果是实体且为分表实体
if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) { if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$className = $tableName; $className = $tableName;
...@@ -49,6 +51,9 @@ class Split ...@@ -49,6 +51,9 @@ class Split
} }
}
return $tableName; return $tableName;
} }
...@@ -63,4 +68,12 @@ class Split ...@@ -63,4 +68,12 @@ class Split
} }
return $storeId % $splitNum; return $storeId % $splitNum;
} }
private function isTesting()
{
$data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId'];
return intval($storeId) === TestEnum::TEST_STORE_ID;
}
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/25
* Time: 13:22
*/
namespace Hdll\Services\Common\Enum;
class TestEnum
{
const TEST_STORE_ID = -3;
}
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