|
|
@@ -13,6 +13,7 @@ namespace app\adminapi\controller\v1\setting;
|
|
|
|
|
|
use app\adminapi\controller\AuthController;
|
|
|
use app\services\system\SystemMenusServices;
|
|
|
+use app\services\system\SystemRouteServices;
|
|
|
use think\facade\App;
|
|
|
use think\facade\Route;
|
|
|
|
|
|
@@ -254,25 +255,14 @@ class SystemMenus extends AuthController
|
|
|
public function ruleList()
|
|
|
{
|
|
|
//获取所有的路由
|
|
|
- $this->app = app();
|
|
|
- $this->app->route->setTestMode(true);
|
|
|
- $this->app->route->clear();
|
|
|
- $path = $this->app->getRootPath() . 'app' . DS . 'adminapi' . DS . 'route' . DS;
|
|
|
- $files = is_dir($path) ? scandir($path) : [];
|
|
|
- foreach ($files as $file) {
|
|
|
- if (strpos($file, '.php')) {
|
|
|
- include $path . $file;
|
|
|
- }
|
|
|
- }
|
|
|
- $ruleList = $this->app->route->getRuleList();
|
|
|
+ $ruleList = app()->make(SystemRouteServices::class)->selectList(['app_name' => 'adminapi'], 'name,path,method,type');
|
|
|
$menuApiList = $this->services->getColumn(['auth_type' => 2, 'is_del' => 0], "concat(`api_url`,'_',lower(`methods`)) as rule");
|
|
|
if ($menuApiList) $menuApiList = array_column($menuApiList, 'rule');
|
|
|
$list = [];
|
|
|
foreach ($ruleList as $item) {
|
|
|
- $item['rule'] = str_replace('adminapi/', '', $item['rule']);
|
|
|
- if (!in_array($item['rule'] . '_' . $item['method'], $menuApiList)) {
|
|
|
- $item['real_name'] = $item['option']['real_name'] ?? '';
|
|
|
- unset($item['option']);
|
|
|
+ $item['path'] = str_replace('adminapi/', '', $item['path']);
|
|
|
+ if (!in_array($item['path'] . '_' . $item['method'], $menuApiList)) {
|
|
|
+ $item['real_name'] = $item['name'] ?? '';
|
|
|
$item['method'] = strtoupper($item['method']);
|
|
|
$list[] = $item;
|
|
|
}
|