Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tencent
services
Commits
f1d74d8a
Commit
f1d74d8a
authored
Sep 25, 2018
by
feixiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单元测试 分表处理
parent
c090b428
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
src/Common/Entity/Split.php
+14
-0
src/Common/Enum/TestEnum.php
+15
-0
No files found.
src/Common/Entity/Split.php
View file @
f1d74d8a
...
...
@@ -8,6 +8,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\Core\RequestContext
;
use
Swoft\Db\Bean\Collector\EntityCollector
;
...
...
@@ -23,6 +24,7 @@ class Split
$map
=
array_flip
(
$collector
[
'map'
]);
}
if
(
!
self
::
isTesting
()
)
{
//如果是实体且为分表实体
if
(
strpos
(
$tableName
,
'\\'
)
!==
false
&&
isset
(
$collector
[
$tableName
]))
{
$className
=
$tableName
;
...
...
@@ -49,6 +51,9 @@ class Split
}
}
return
$tableName
;
}
...
...
@@ -63,4 +68,12 @@ class Split
}
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
src/Common/Enum/TestEnum.php
0 → 100644
View file @
f1d74d8a
<?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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment