forked from kvnZero/hyperf-APIJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableEntity.php
More file actions
60 lines (49 loc) · 1.61 KB
/
TableEntity.php
File metadata and controls
60 lines (49 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace App\ApiJson\Entity;
class TableEntity
{
/** @var ConditionEntity $ConditionEntity */
protected ConditionEntity $conditionEntity;
/** @var string $realTableName 真实表名 */
protected string $realTableName;
/** @var array $content 表名对应的数据 */
protected array $content;
/**
* @param string $tableName 表名
* @param array $jsonContent json源数据
*/
public function __construct(protected string $tableName, protected array $jsonContent, protected array $globalArgs = [], protected array $extendData = [])
{
$sanitizeTableName = str_replace(['[]'], '', $this->tableName);
$this->realTableName = $sanitizeTableName;
$this->content = $this->getContentByTableName();
$this->parseConditionEntity();
}
public function getTableName(): string
{
return $this->tableName;
}
public function getRealTableName(): string
{
return $this->realTableName;
}
public function getContent(): array
{
return $this->content;
}
public function getConditionEntity(): ConditionEntity
{
return $this->conditionEntity;
}
protected function getContentByTableName(): array
{
$content = $this->jsonContent[$this->tableName];
if (isset($content[$this->realTableName])) $content = $content[$this->realTableName];
return $content;
}
protected function parseConditionEntity()
{
$entity = new ConditionEntity(array_merge($this->globalArgs, $this->content), $this->extendData);
$this->conditionEntity = $entity;
}
}