Auth.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\auth;
  12. use app\service\admin\auth\AuthService;
  13. use app\service\admin\auth\AuthSiteService;
  14. use core\base\BaseAdminController;
  15. use think\db\exception\DataNotFoundException;
  16. use think\db\exception\DbException;
  17. use think\db\exception\ModelNotFoundException;
  18. use think\Response;
  19. class Auth extends BaseAdminController
  20. {
  21. /**
  22. * 登录用户菜单列表的接口
  23. */
  24. public function authMenuList()
  25. {
  26. $data = $this->request->params([
  27. ['addon', 'all'],
  28. ]);
  29. return success((new AuthService())->getAuthMenuList(1, $data['addon']));
  30. }
  31. /**
  32. * 获取当前站点支持的应用
  33. * @return Response
  34. * @throws DataNotFoundException
  35. * @throws DbException
  36. * @throws ModelNotFoundException
  37. */
  38. public function getAuthAddonList(){
  39. return success((new AuthSiteService())->getAuthAddonList());
  40. }
  41. /**
  42. * 获取登录用户信息
  43. * @return Response
  44. */
  45. public function get()
  46. {
  47. return success((new AuthService())->getAuthInfo());
  48. }
  49. /**
  50. * 修改登录用户信息
  51. * @param $field
  52. * @return Response
  53. */
  54. public function modify($field)
  55. {
  56. $data = $this->request->params([
  57. ['value', ''],
  58. ['field', $field]
  59. ]);
  60. // $this->validate($data, 'app\validate\sys\User.modify');
  61. (new AuthService())->modifyAuth($field, $data['value']);
  62. return success('MODIFY_SUCCESS');
  63. }
  64. /**
  65. * 更新用户
  66. */
  67. public function edit()
  68. {
  69. $data = $this->request->params([
  70. ['real_name', ''],
  71. ['head_img', ''],
  72. ['password', ''],
  73. ['original_password', '']
  74. ]);
  75. (new AuthService())->editAuth($data);
  76. return success('MODIFY_SUCCESS');
  77. }
  78. /**
  79. * 获取当前登录站点信息
  80. * @return Response
  81. */
  82. public function site()
  83. {
  84. return success((new AuthSiteService())->getSiteInfo());
  85. }
  86. /**
  87. * 选择可以选择的页面
  88. * @return Response
  89. * @throws DataNotFoundException
  90. * @throws DbException
  91. * @throws ModelNotFoundException
  92. */
  93. public function getShowMenuList()
  94. {
  95. return success((new AuthSiteService())->getShowMenuList());
  96. }
  97. }