Skip to content

Commit d647d1c

Browse files
committed
修正使用tp路由注解,分组注解自动添加到url的问题
1 parent 2c761e7 commit d647d1c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
}
4141
}
4242
},
43-
"minimum-stability": "stable"
43+
"minimum-stability": "dev"
4444
}

src/parseApi/ParseAnnotation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ protected function parseApiMethod($refClass,$refMethod,$routeGroup){
370370
// 无url,自动生成
371371
if (empty($methodItem['url'])) {
372372
$methodItem['url'] = $this->autoCreateUrl($refClass->name,$refMethod);
373-
} else if (!empty($routeGroup->value)) {
373+
} else if (!empty($methodItem['url']) && $methodItem['isAnnotationUrl']===false && !empty($routeGroup->value)) {
374374
// 路由分组,url加上分组
375375
$methodItem['url'] = '/' . $routeGroup->value . '/' . $methodItem['url'];
376376
}else if (!empty($methodItem['url']) && substr($methodItem['url'], 0, 1) != "/") {
@@ -541,6 +541,7 @@ protected function parseAnnotation($refMethod, bool $enableRefService = true,$so
541541
$returns = [];
542542
$before = [];
543543
$after = [];
544+
$isAnnotationUrl = false;
544545

545546
foreach ($annotations as $annotation) {
546547
switch (true) {
@@ -610,6 +611,7 @@ protected function parseAnnotation($refMethod, bool $enableRefService = true,$so
610611
break;
611612
case $annotation instanceof Url:
612613
$data['url'] = $annotation->value;
614+
$isAnnotationUrl=true;
613615
break;
614616
case $annotation instanceof Method:
615617
$data['method'] = $annotation->value;
@@ -637,6 +639,7 @@ protected function parseAnnotation($refMethod, bool $enableRefService = true,$so
637639
$data['return'] = $returns;
638640
$data['before'] = $before;
639641
$data['after'] = $after;
642+
$data['isAnnotationUrl'] = $isAnnotationUrl;
640643
}
641644
return $data;
642645
}

0 commit comments

Comments
 (0)