AuthSiteService.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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\service\admin\auth;
  12. use app\dict\sys\AppTypeDict;
  13. use app\dict\sys\MenuTypeDict;
  14. use app\model\site\Site;
  15. use app\model\sys\SysMenu;
  16. use app\service\admin\addon\AddonService;
  17. use app\service\admin\site\SiteService;
  18. use core\base\BaseAdminService;
  19. use think\db\exception\DataNotFoundException;
  20. use think\db\exception\DbException;
  21. use think\db\exception\ModelNotFoundException;
  22. /**
  23. * 用户服务层
  24. * Class BaseService
  25. * @package app\service
  26. */
  27. class AuthSiteService extends BaseAdminService
  28. {
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. $this->model = new Site();
  33. }
  34. /**
  35. * 获取授权当前的站点信息
  36. */
  37. public function getSiteInfo(){
  38. //通过用户id获取
  39. return (new SiteService())->getSiteCache($this->site_id);
  40. }
  41. /**
  42. * 通过站点id获取菜单列表
  43. * @param int $is_tree
  44. * @param int|string $status
  45. * @return mixed
  46. */
  47. public function getMenuList(int $is_tree, int|string $status, $addon = 'all', int $is_button = 1){
  48. return (new SiteService())->getMenuList($this->site_id, $is_tree, $status, $addon, $is_button);
  49. }
  50. /**
  51. * 通过站点id获取菜单列表
  52. * @param int|string $status
  53. * @return mixed
  54. */
  55. public function getApiList(int|string $status){
  56. return (new SiteService())->getApiList($this->site_id, $status);
  57. }
  58. /**
  59. * 查询当前站点可以单独显示的菜单(仅支持站点端调用)
  60. * @return array|SysMenu[]
  61. * @throws DataNotFoundException
  62. * @throws DbException
  63. * @throws ModelNotFoundException
  64. */
  65. public function getShowMenuList(){
  66. $menu_keys = (new SiteService())->getMenuIdsBySiteId($this->site_id, 1);
  67. return (new SysMenu())->where([['menu_key', 'in', $menu_keys], ['menu_type', '=', MenuTypeDict::MENU], ['app_type', '=', AppTypeDict::SITE],['is_show', '=', 1]])->select()->toArray();
  68. }
  69. /**
  70. * 获取站点支持
  71. * @return array|mixed|string|null
  72. * @throws DataNotFoundException
  73. * @throws DbException
  74. * @throws ModelNotFoundException
  75. */
  76. public function getAuthAddonList(){
  77. return (new AddonService())->getAddonListBySiteId($this->site_id);
  78. }
  79. }