Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
2e43830c
Commit
2e43830c
authored
Feb 22, 2018
by
stylefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
1f484cfb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
18 deletions
+25
-18
guns-admin/src/main/java/com/stylefeng/guns/common/annotion/Permission.java
+8
-6
guns-admin/src/main/java/com/stylefeng/guns/common/constant/cache/CacheKey.java
+11
-3
guns-admin/src/main/java/com/stylefeng/guns/common/constant/dictmap/factory/DictFieldWarpperFactory.java
+6
-8
guns-admin/src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
+0
-1
No files found.
guns-admin/src/main/java/com/stylefeng/guns/common/annotion/Permission.java
View file @
2e43830c
package
com
.
stylefeng
.
guns
.
common
.
annotion
;
package
com
.
stylefeng
.
guns
.
common
.
annotion
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.*
;
import
java.lang.annotation.Inherited
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
/**
* 权限注解 用于检查权限 规定访问权限
* 权限注解 用于检查权限 规定访问权限
*
*
* @example @Permission({role
ID1,roleID
2})
* @example @Permission({role
1,role
2})
* @example @Permission
* @example @Permission
*/
*/
@Inherited
@Inherited
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
METHOD
})
@Target
({
ElementType
.
METHOD
})
public
@interface
Permission
{
public
@interface
Permission
{
/**
* <p>角色英文名称</p>
* <p>使用注解时加上这个值表示限制只有某个角色的才可以访问对应的资源</p>
* <p>常用在某些资源限制只有超级管理员角色才可访问</p>
*/
String
[]
value
()
default
{};
String
[]
value
()
default
{};
}
}
guns-admin/src/main/java/com/stylefeng/guns/common/constant/cache/CacheKey.java
View file @
2e43830c
package
com
.
stylefeng
.
guns
.
common
.
constant
.
cache
;
package
com
.
stylefeng
.
guns
.
common
.
constant
.
cache
;
/**
/**
* 缓存
的key集合
* 缓存
标识前缀集合,常用在ConstantFactory类中
*
*
* @author fengshuonan
* @author fengshuonan
* @date 2017-04-25 9:37
* @date 2017-04-25 9:37
...
@@ -9,15 +9,23 @@ package com.stylefeng.guns.common.constant.cache;
...
@@ -9,15 +9,23 @@ package com.stylefeng.guns.common.constant.cache;
public
interface
CacheKey
{
public
interface
CacheKey
{
/**
/**
*
ConstantFactory中的缓存
*
角色名称(多个)
*/
*/
String
ROLES_NAME
=
"roles_name_"
;
String
ROLES_NAME
=
"roles_name_"
;
/**
* 角色名称(单个)
*/
String
SINGLE_ROLE_NAME
=
"single_role_name_"
;
String
SINGLE_ROLE_NAME
=
"single_role_name_"
;
/**
* 角色英文名称
*/
String
SINGLE_ROLE_TIP
=
"single_role_tip_"
;
String
SINGLE_ROLE_TIP
=
"single_role_tip_"
;
/**
* 部门名称
*/
String
DEPT_NAME
=
"dept_name_"
;
String
DEPT_NAME
=
"dept_name_"
;
}
}
guns-admin/src/main/java/com/stylefeng/guns/common/constant/dictmap/factory/DictFieldWarpperFactory.java
View file @
2e43830c
...
@@ -8,24 +8,22 @@ import com.stylefeng.guns.core.exception.GunsException;
...
@@ -8,24 +8,22 @@ import com.stylefeng.guns.core.exception.GunsException;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
/**
/**
* 字
段的包装创建工厂
* 字
典字段的包装器(从ConstantFactory中获取包装值)
*
*
* @author fengshuonan
* @author fengshuonan
* @date 2017-05-06 15:12
* @date 2017-05-06 15:12
*/
*/
public
class
DictFieldWarpperFactory
{
public
class
DictFieldWarpperFactory
{
public
static
Object
createFieldWarpper
(
Object
field
,
String
methodName
)
{
public
static
Object
createFieldWarpper
(
Object
parameter
,
String
methodName
)
{
IConstantFactory
me
=
ConstantFactory
.
me
();
IConstantFactory
constantFactory
=
ConstantFactory
.
me
();
try
{
try
{
Method
method
=
IConstantFactory
.
class
.
getMethod
(
methodName
,
field
.
getClass
());
Method
method
=
IConstantFactory
.
class
.
getMethod
(
methodName
,
parameter
.
getClass
());
Object
result
=
method
.
invoke
(
me
,
field
);
return
method
.
invoke
(
constantFactory
,
parameter
);
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
try
{
try
{
Method
method
=
IConstantFactory
.
class
.
getMethod
(
methodName
,
Integer
.
class
);
Method
method
=
IConstantFactory
.
class
.
getMethod
(
methodName
,
Integer
.
class
);
Object
result
=
method
.
invoke
(
me
,
Integer
.
parseInt
(
field
.
toString
()));
return
method
.
invoke
(
constantFactory
,
Integer
.
parseInt
(
parameter
.
toString
()));
return
result
;
}
catch
(
Exception
e1
)
{
}
catch
(
Exception
e1
)
{
throw
new
GunsException
(
BizExceptionEnum
.
ERROR_WRAPPER_FIELD
);
throw
new
GunsException
(
BizExceptionEnum
.
ERROR_WRAPPER_FIELD
);
}
}
...
...
guns-admin/src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
View file @
2e43830c
...
@@ -16,7 +16,6 @@ public enum BizExceptionEnum implements ServiceExceptionEnum{
...
@@ -16,7 +16,6 @@ public enum BizExceptionEnum implements ServiceExceptionEnum{
ERROR_CREATE_DICT
(
500
,
"创建字典失败"
),
ERROR_CREATE_DICT
(
500
,
"创建字典失败"
),
ERROR_WRAPPER_FIELD
(
500
,
"包装字典属性失败"
),
ERROR_WRAPPER_FIELD
(
500
,
"包装字典属性失败"
),
/**
/**
* 文件上传
* 文件上传
*/
*/
...
...
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