Index.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018-2020 rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | [ 首页管理 ]
  8. // +----------------------------------------------------------------------
  9. // | Date: 2020-08-31 20:43
  10. // +----------------------------------------------------------------------
  11. namespace app\system\controller;
  12. use app\BaseController;
  13. use app\model\api\EducationModel;
  14. use app\model\system\AdminMenu;
  15. use app\model\api\Sys as SysModel;
  16. use app\Request;
  17. use app\system\controller\AuthController;
  18. use library\services\UtilService;
  19. use think\Cache;
  20. use think\db\exception\DataNotFoundException;
  21. use think\db\exception\DbException;
  22. use think\db\exception\ModelNotFoundException;
  23. class Index extends AuthController
  24. {
  25. /**
  26. * 基本数据
  27. * @return mixed
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. */
  32. public function init()
  33. {
  34. $menuMenu = new AdminMenu;
  35. [$menus, $paths] = $menuMenu->getRoute($this->adminInfo['role_id']);
  36. return app('json')->success([
  37. 'menus' => $menus,
  38. 'paths' => $paths,
  39. 'user_info' => [
  40. 'id' => $this->adminInfo['id'],
  41. 'username' => $this->adminInfo['username'],
  42. 'name' => $this->adminInfo['name'],
  43. 'avatar' => $this->adminInfo['avatar'],
  44. ],
  45. ]);
  46. }
  47. //获取所有分类列表
  48. public function getCateList()
  49. {
  50. try {
  51. $cateList = (new \app\model\api\EducationModel)->select();
  52. } catch (DataNotFoundException $e) {
  53. } catch (ModelNotFoundException $e) {
  54. } catch (DbException $e) {
  55. }
  56. return json($cateList);
  57. }
  58. }