@@ -35,11 +35,10 @@ public function __construct(protected array $json, protected string $method = 'G
3535 {
3636 }
3737
38- public function handle (bool $ isQueryMany = false ): array
38+ public function handle (bool $ isQueryMany = false , array $ extendData = [] ): array
3939 {
4040 $ result = [];
4141 foreach ($ this ->json as $ tableName => $ condition ) { //可以优化成协程行为(如果没有依赖赋值的前提下)
42- $ tableMany = false ;
4342 if (in_array ($ tableName , $ this ->filterKey ())) {
4443 $ this ->tagColumn [$ tableName ] = $ condition ;
4544 continue ;
@@ -50,28 +49,23 @@ public function handle(bool $isQueryMany = false): array
5049 }
5150 if ($ tableName == '[] ' ) {
5251 $ parse = new self ($ condition , $ this ->method , $ condition ['tag ' ] ?? '' );
53- $ result [$ tableName ] = $ parse ->handle (true ); //提供行为
52+ $ result [$ tableName ] = $ parse ->handle (true , array_merge ( $ result , $ extendData ) ); //提供行为
5453 continue ; //跳出不往下执行
5554 }
5655 if (str_ends_with ($ tableName , '[] ' )) {
5756 $ isQueryMany = true ;
58- $ tableMany = true ;
5957 }
6058// if (!preg_match("/^[A-Za-z]+$/", $tableName) || !is_array($condition)) {
6159// continue; //不满足表名规范 跳出不往下执行
6260// }
63- $ this ->tableEntities [$ tableName ] = new TableEntity ($ tableName , $ this ->json , $ this ->getGlobalArgs (), $ result );
61+ $ this ->tableEntities [$ tableName ] = new TableEntity ($ tableName , $ this ->json , $ this ->getGlobalArgs (), array_merge ( $ result, $ extendData ) );
6462 foreach ($ this ->supMethod as $ methodClass ) {
6563 /** @var AbstractMethod $method */
6664 $ method = new $ methodClass ($ this ->tableEntities [$ tableName ], $ this ->method );
6765 $ method ->setQueryMany ($ isQueryMany );
6866 $ response = $ method ->handle ();
6967 if (!is_null ($ response )) {
70- if ($ isQueryMany && $ tableMany == false ) {
71- $ result = $ response ;
72- } else {
73- $ result [$ tableName ] = $ response ;
74- }
68+ $ result [$ tableName ] = $ response ;
7569 break ;
7670 }
7771 }
0 commit comments