Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-rpc
Commits
d2e7c2c4
Commit
d2e7c2c4
authored
Jun 11, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限注解去除命名空间
parent
0a5c03a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
README.md
README.md
+3
-3
PermAnnotationAspect.php
src/Aspect/PermAnnotationAspect.php
+3
-2
No files found.
README.md
View file @
d2e7c2c4
...
...
@@ -26,7 +26,7 @@ composer require meibuyu/micro @dev
> 权限名会拼接env文件中的APP_NAME属性,请注意唯一性
> 所有权限必须存在于用户服务的权限表中,若不存在,请联系管理员添加权限
##### 1、@AutoPerm
在控制器头部添加@AutoPerm注解,为该控制器下所有的方法添加鉴权功能,生成的权限名为
`蛇形
命名空间_蛇形
控制名_蛇形方法名`
在控制器头部添加@AutoPerm注解,为该控制器下所有的方法添加鉴权功能,生成的权限名为
`蛇形控制名_蛇形方法名`
```
/**
* @AutoPerm()
...
...
@@ -34,7 +34,7 @@ composer require meibuyu/micro @dev
class UserInfoController {}
```
参数:
> 1. prefix, 前缀(字符串),默认为蛇形
命名空间_蛇形
控制名(user_info)
> 1. prefix, 前缀(字符串),默认为蛇形控制名(user_info)
> 2. exclude, 要排除的方法名(字符串数组),默认为空
```
/**
...
...
@@ -44,7 +44,7 @@ class UserInfoController {}
```
##### 2、@Perm
在控制器中的方法头部添加@Perm注解,为当前方法添加鉴权功能,生成权限名为
`蛇形
命名空间_蛇形
控制名_蛇形方法名`
在控制器中的方法头部添加@Perm注解,为当前方法添加鉴权功能,生成权限名为
`蛇形控制名_蛇形方法名`
```
/**
* @Perm()
...
...
src/Aspect/PermAnnotationAspect.php
View file @
d2e7c2c4
...
...
@@ -91,8 +91,9 @@ class PermAnnotationAspect extends AbstractAspect
protected
function
genPrefix
(
string
$className
)
:
string
{
$handledNamespace
=
Str
::
replaceFirst
(
'Controller'
,
''
,
Str
::
after
(
$className
,
'\\Controller\\'
));
$handledNamespace
=
str_replace
(
'\\'
,
'_'
,
$handledNamespace
);
$prefix
=
Str
::
snake
(
$handledNamespace
);
$namespaceLength
=
strrpos
(
$handledNamespace
,
'\\'
);
$prefix
=
$namespaceLength
?
substr
(
$handledNamespace
,
$namespaceLength
+
1
)
:
$handledNamespace
;
$prefix
=
Str
::
snake
(
$prefix
);
$prefix
=
str_replace
(
'__'
,
'_'
,
$prefix
);
return
$prefix
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment