AuthLogic.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\logic\auth;
  20. use think\facade\Cache;
  21. use think\facade\Config;
  22. /**
  23. * 权限功能类
  24. * Class AuthLogic
  25. * @package app\adminapi\logic\auth
  26. */
  27. class AuthLogic
  28. {
  29. /**
  30. * @notes 获取菜单
  31. * @return array
  32. * @author cjhao
  33. * @date 2021/8/25 17:37
  34. */
  35. public static function getMenu():array
  36. {
  37. $menu = Config::get('menu');
  38. return $menu;
  39. }
  40. /**
  41. * @notes 获取权限
  42. * @param array $authKeys array-返回指定权限
  43. * @return array
  44. * @author cjhao
  45. * @date 2021/8/26 11:09
  46. */
  47. public static function getAuth(array $authKeys = []):array
  48. {
  49. $authConfigList = Config::get('auth');
  50. //获取指定权限
  51. if(!empty($authKeys)){
  52. $authList = [];
  53. foreach ($authKeys as $keys){
  54. $keyList = explode('/',$keys);
  55. $authConfig = $authConfigList[$keyList[0]] ?? [];
  56. if(empty($authConfig)){
  57. continue;
  58. }
  59. $keyList = explode('.',$keyList[1]);
  60. $buttonAuth = $authConfig[$keyList[0]][$keyList[1]]['button_auth'] ?? [];
  61. $actionAuth = $authConfig[$keyList[0]][$keyList[1]]['action_auth'] ?? [];
  62. $authList = [
  63. 'button_auth' => array_merge($authList['button_auth'] ?? [],$buttonAuth),
  64. 'action_auth' => array_merge($authList['action_auth'] ?? [],$actionAuth),
  65. ];
  66. }
  67. return $authList;
  68. }
  69. return $authConfigList;
  70. }
  71. }