Commit b1ba4950 by feixiang

单元测试 分表处理

parent 8d64b653
......@@ -10,6 +10,7 @@ namespace Hdll\Services\Common\Entity;
use Hdll\Services\Common\Bean\Collector\SplitCollector;
use Hdll\Services\Common\Enum\TestEnum;
use Hdll\Services\Common\Exception\CommonException;
use Swoft\App;
use Swoft\Core\RequestContext;
use Swoft\Db\Bean\Collector\EntityCollector;
use Swoft\Db\QueryBuilder;
......@@ -71,9 +72,9 @@ class Split
private function isTesting()
{
$data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId'];
/**@var User $user**/
$user = App::getBean(User::class);
return intval($storeId) === TestEnum::TEST_STORE_ID;
return $user->getTestFlag() === TestEnum::TEST_STORE_ID;
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@
namespace Hdll\Services\Common\Entity;
use Hdll\Services\Auth\Enum\AuthError;
use Hdll\Services\Common\Enum\TestEnum;
use Hdll\Services\Common\Lib\Redis;
use Swoft\Bean\Annotation\Bean;
use Swoft\Core\RequestContext;
......@@ -35,6 +36,16 @@ class User
return $this->getValue('id');
}
public function setTestFlag()
{
$this->setValue('testFlag', TestEnum::TEST_STORE_ID);
}
public function getTestFlag()
{
return $this->getValue('testFlag');
}
public function getNickname()
{
return $this->getValue('nickname');
......
......@@ -9,7 +9,7 @@ namespace Hdll\Services\Common\Enum;
class TestEnum
{
const TEST_STORE_ID = -3;
const TEST_STORE_ID = true;
}
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