Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a70ba9

Browse files
authored
Merge pull requestkvnZero#13 from kvnZero/feat/测试中修改
Feat/测试中修改
2 parents8113307 +d0ca14c commit1a70ba9

File tree

8 files changed

+289
-232
lines changed

8 files changed

+289
-232
lines changed

‎app/ApiJson/Entity/ConditionEntity.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class ConditionEntity
1111
*/
1212
protectedarray$where = [];
1313

14-
protectedint$limit =0;
14+
protectedint$limit =10;
1515
protectedint$offset =0;
16-
protectedarray$column =['*'];
16+
protectedstring$column ='*';
1717
protectedarray$group = [];
1818
protectedarray$order = [];
1919
protectedarray$having = [];
@@ -60,9 +60,9 @@ public function addQueryWhere(string $key, string $sql, array $bindArgs = [])
6060
}
6161

6262
/**
63-
* @paramarray|string[] $column
63+
* @param string $column
6464
*/
65-
publicfunctionsetColumn(array$column):void
65+
publicfunctionsetColumn(string$column):void
6666
{
6767
$this->column =$column;
6868
}
@@ -108,9 +108,9 @@ public function setOrder(array $order): void
108108
}
109109

110110
/**
111-
* @returnarray
111+
* @returnstring
112112
*/
113-
publicfunctiongetColumn():array
113+
publicfunctiongetColumn():string
114114
{
115115
return$this->column;
116116
}

‎app/ApiJson/Handle/AbstractHandle.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ protected function subTableQuery(array $data): QueryInterface
6565
{
6666
$tableName =$data['from'];
6767
$tableEntity =newTableEntity($tableName,$data);
68-
$handle =newHandle($tableEntity->getConditionEntity(),$tableEntity);
68+
$conditionEntity =$tableEntity->getConditionEntity();
69+
$conditionEntity->setLimit(0);
70+
$handle =newHandle($conditionEntity,$tableEntity);
6971
$handle->build();
7072
/** @var QueryInterface $query */
7173
returnnew (ApplicationContext::getContainer()->get(ConfigInterface::class)->get(QueryInterface::class))($tableEntity->getRealTableName(),$tableEntity->getConditionEntity());

‎app/ApiJson/Handle/FunctionColumnHandle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function buildModel()
1616
},ARRAY_FILTER_USE_KEY)as$key =>$value)
1717
{
1818
$value =str_replace([';',':'], [',',' AS'],$value);
19-
$this->condition->setColumn(explode(',',$value));
19+
$this->condition->setColumn($value);
2020
$this->unsetKey[] =$this->keyWord;
2121
}
2222
}

‎app/ApiJson/Handle/WhereSubQueryHandle.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ protected function buildModel()
1212
{
1313
$query =$this->subTableQuery($value);
1414

15-
$op ='=';
15+
$op =' =';
1616
if(str_ends_with($key,'>=@')) {
17-
$op ='>=';
17+
$op =' >=';
1818
}elseif(str_ends_with($key,'<=@')) {
19-
$op ='<=';
19+
$op =' <=';
2020
}elseif(str_ends_with($key,'>@')) {
21-
$op ='>';
21+
$op =' >';
2222
}elseif(str_ends_with($key,'<@')) {
23-
$op ='<';
23+
$op =' <';
24+
}elseif(str_ends_with($key,'{}@')) {
25+
$op =' IN';
2426
}
2527
$sql =sprintf('`%s`%s(%s)',$this->sanitizeKey($key),$op,$query->toSql());
2628
$this->condition->addQueryWhere($key,$sql,$query->getBindings());

‎app/ApiJson/Model/MysqlQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function buildQuery(bool $query = true)
102102
}
103103
if (!$query)return;//下面不再非查询操作
104104

105-
$this->db->select($this->conditionEntity->getColumn());
105+
$this->db->select(Db::raw($this->conditionEntity->getColumn()));
106106
$limit =$this->conditionEntity->getLimit();
107107
if ($limit >0) {
108108
$this->db->limit($limit);

‎app/ApiJson/Parse/Parse.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ public function __construct(protected array $json, protected string $method = 'G
3939

4040
publicfunctionhandle(bool$isQueryMany =false,array$extendData = []):array
4141
{
42+
if (empty($extendData)) {
43+
$extendData =$this->json;//引入原json
44+
}
4245
$result = [];
4346
foreach ($this->jsonas$tableName =>$condition) {//可以优化成协程行为(如果没有依赖赋值的前提下)
47+
if (is_null($condition))continue;
4448
if (in_array($tableName,$this->filterKey())) {
4549
$this->tagColumn[$tableName] =$condition;
4650
continue;
@@ -56,9 +60,9 @@ public function handle(bool $isQueryMany = false, array $extendData = []): array
5660
if (str_ends_with($tableName,'[]')) {
5761
$isQueryMany =true;
5862
}
59-
// if (!preg_match("/^[A-Za-z]+$/", $tableName) || !is_array($condition)) {
60-
// continue; //不满足表名规范 跳出不往下执行
61-
// }
63+
if (!preg_match("/^[A-Z].+/",$tableName) || !is_array($condition)) {
64+
continue;//不满足表名规范 跳出不往下执行
65+
}
6266
$this->tableEntities[$tableName] =newTableEntity($tableName,$this->json,$this->getGlobalArgs(),array_merge($result,$extendData));
6367
foreach ($this->supMethodas$methodClass) {
6468
/** @var AbstractMethod $method */
@@ -93,6 +97,10 @@ protected function handleArray(array $jsonData, array $extendData = []): array
9397
{
9498
$result = [[]];
9599
foreach ($jsonDataas$tableName =>$condition) {//可以优化成协程行为(如果没有依赖赋值的前提下)
100+
if (is_null($condition))continue;
101+
if (!preg_match("/^[A-Z].+/",$tableName) || !is_array($condition)) {
102+
continue;//不满足表名规范 跳出不往下执行
103+
}
96104
foreach ($resultas$key =>$item) {
97105
if (in_array($tableName,$this->filterKey())) {
98106
$this->tagColumn[$tableName] =$condition;

‎app/ApiJson/Replace/QuoteReplace.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ protected function process()
99
$condition =$this->condition->getCondition();
1010

1111
foreach (array_filter($condition,function($key){
12-
returnstr_ends_with($key,'@') && !str_ends_with($key,'}{@');
12+
returnstr_ends_with($key,'@');
1313
},ARRAY_FILTER_USE_KEY)as$key =>$value)
1414
{
15+
if (!is_string($value))continue;
1516
$path =str_replace(['/','[]'], ['.','currentItem'],$value);
16-
$newKey =substr($key,0,strlen($key) -1);
17-
$condition[$newKey] =data_get($this->condition->getExtendData(),$path);
18-
unset($condition[$key]);
17+
if (str_starts_with($path,'.')) {
18+
$path ='currentItem' .$path;
19+
}
20+
$value =data_get($this->condition->getExtendData(),$path);
21+
if (!is_null($value)) {//常规情况下的引用
22+
$newKey =substr($key,0,strlen($key) -1);
23+
$condition[$newKey] =$value;
24+
unset($condition[$key]);
25+
}else {//非常规情况下引入 比如引入子查询等
26+
$path .='@';
27+
$value =data_get($this->condition->getExtendData(),$path);
28+
$condition[$key] =$value;
29+
}
1930
$this->condition->setCondition($condition);
2031
}
2132
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp