crud.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * +----------------------------------------------------------------------
  4. * | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  5. * +----------------------------------------------------------------------
  6. * | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  7. * +----------------------------------------------------------------------
  8. * | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  9. * +----------------------------------------------------------------------
  10. * | Author: CRMEB Team <admin@crmeb.com>
  11. * +----------------------------------------------------------------------
  12. */
  13. use think\facade\Route;
  14. /**
  15. * crud 自动加载路由
  16. * 自动加载crud目录下的所有路由文件
  17. */
  18. Route::group(function () {
  19. $path = $this->app->getRootPath() . 'app' . DS . 'adminapi' . DS . 'route' . DS . 'crud';
  20. if (is_dir($path)) {
  21. $files = scandir($path);
  22. foreach ($files as $file) {
  23. if ($file != '.' && $file != '..') {
  24. include $path . DS . $file;
  25. }
  26. }
  27. }
  28. })->middleware([
  29. \app\http\middleware\AllowOriginMiddleware::class,
  30. \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
  31. \app\adminapi\middleware\AdminCheckRoleMiddleware::class,
  32. \app\adminapi\middleware\AdminLogMiddleware::class
  33. ])->option(['mark' => 'crud', 'mark_name' => '生成代码路由']);