Skip to content

Commit

Permalink
update 引用默认路径 && 表名过滤
Browse files Browse the repository at this point in the history
  • Loading branch information
kvnZero committed Nov 16, 2021
1 parent 8113307 commit 9701daa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/ApiJson/Parse/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public function handle(bool $isQueryMany = false, array $extendData = []): array
if (str_ends_with($tableName, '[]')) {
$isQueryMany = true;
}
// if (!preg_match("/^[A-Za-z]+$/", $tableName) || !is_array($condition)) {
// continue; //不满足表名规范 跳出不往下执行
// }
if (!preg_match("/^[A-Z].+/", $tableName) || !is_array($condition)) {
continue; //不满足表名规范 跳出不往下执行
}
$this->tableEntities[$tableName] = new TableEntity($tableName, $this->json, $this->getGlobalArgs(), array_merge($result, $extendData));
foreach ($this->supMethod as $methodClass) {
/** @var AbstractMethod $method */
Expand Down Expand Up @@ -93,6 +93,9 @@ protected function handleArray(array $jsonData, array $extendData = []): array
{
$result = [[]];
foreach ($jsonData as $tableName => $condition) { //可以优化成协程行为(如果没有依赖赋值的前提下)
if (!preg_match("/^[A-Z].+/", $tableName) || !is_array($condition)) {
continue; //不满足表名规范 跳出不往下执行
}
foreach ($result as $key => $item) {
if (in_array($tableName, $this->filterKey())) {
$this->tagColumn[$tableName] = $condition;
Expand Down
3 changes: 3 additions & 0 deletions app/ApiJson/Replace/QuoteReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ protected function process()
}, ARRAY_FILTER_USE_KEY) as $key => $value)
{
$path = str_replace(['/', '[]'], ['.', 'currentItem'], $value);
if (str_starts_with($path, '.')) {
$path = 'currentItem' . $path;
}
$newKey = substr($key, 0, strlen($key) - 1);
$condition[$newKey] = data_get($this->condition->getExtendData(), $path);
unset($condition[$key]);
Expand Down

0 comments on commit 9701daa

Please sign in to comment.