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
342d2488
Commit
342d2488
authored
May 16, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构角色管理的日志记录
parent
b6daaa43
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
26 deletions
+83
-26
src/main/java/com/stylefeng/guns/common/constant/Dict.java
+10
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/DeleteDict.java
+22
-0
src/main/java/com/stylefeng/guns/common/constant/dictmap/RoleDict.java
+5
-3
src/main/java/com/stylefeng/guns/common/constant/factory/ConstantFactory.java
+37
-19
src/main/java/com/stylefeng/guns/modular/system/controller/RoleController.java
+9
-4
No files found.
src/main/java/com/stylefeng/guns/common/constant/Dict.java
View file @
342d2488
...
@@ -13,4 +13,14 @@ public interface Dict {
...
@@ -13,4 +13,14 @@ public interface Dict {
*/
*/
String
UserDict
=
"UserDict"
;
String
UserDict
=
"UserDict"
;
/**
* 角色管理员字典
*/
String
RoleDict
=
"RoleDict"
;
/**
* 删除业务的字典
*/
String
DeleteDict
=
"DeleteDict"
;
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/DeleteDict.java
0 → 100644
View file @
342d2488
package
com
.
stylefeng
.
guns
.
common
.
constant
.
dictmap
;
import
com.stylefeng.guns.common.constant.dictmap.base.AbstractDictMap
;
/**
* 用于删除业务的字典
*
* @author fengshuonan
* @date 2017-05-06 15:01
*/
public
class
DeleteDict
extends
AbstractDictMap
{
@Override
public
void
init
()
{
put
(
"roleId"
,
"角色名称"
);
}
@Override
protected
void
initBeWrapped
()
{
putFieldWrapperMethodName
(
"roleId"
,
"getCacheObject"
);
}
}
src/main/java/com/stylefeng/guns/common/constant/dictmap/RoleDict.java
View file @
342d2488
...
@@ -12,18 +12,20 @@ public class RoleDict extends AbstractDictMap {
...
@@ -12,18 +12,20 @@ public class RoleDict extends AbstractDictMap {
@Override
@Override
public
void
init
()
{
public
void
init
()
{
put
(
"roleId"
,
"角色id"
);
put
(
"roleId"
,
"角色名称"
);
put
(
"id"
,
"角色id"
);
put
(
"num"
,
"角色排序"
);
put
(
"num"
,
"角色排序"
);
put
(
"pid"
,
"角色的父级"
);
put
(
"pid"
,
"角色的父级"
);
put
(
"name"
,
"角色名称"
);
put
(
"name"
,
"角色名称"
);
put
(
"deptid"
,
"部门
id
"
);
put
(
"deptid"
,
"部门
名称
"
);
put
(
"tips"
,
"备注"
);
put
(
"tips"
,
"备注"
);
put
(
"ids"
,
"资源名称"
);
}
}
@Override
@Override
protected
void
initBeWrapped
()
{
protected
void
initBeWrapped
()
{
putFieldWrapperMethodName
(
"pid"
,
"getSingleRoleName"
);
putFieldWrapperMethodName
(
"pid"
,
"getSingleRoleName"
);
putFieldWrapperMethodName
(
"deptid"
,
"getDeptName"
);
putFieldWrapperMethodName
(
"deptid"
,
"getDeptName"
);
putFieldWrapperMethodName
(
"roleId"
,
"getSingleRoleName"
);
putFieldWrapperMethodName
(
"ids"
,
"getMenuNames"
);
}
}
}
}
src/main/java/com/stylefeng/guns/common/constant/factory/ConstantFactory.java
View file @
342d2488
...
@@ -6,18 +6,13 @@ import com.stylefeng.guns.common.constant.cache.CacheKey;
...
@@ -6,18 +6,13 @@ import com.stylefeng.guns.common.constant.cache.CacheKey;
import
com.stylefeng.guns.common.constant.state.ManagerStatus
;
import
com.stylefeng.guns.common.constant.state.ManagerStatus
;
import
com.stylefeng.guns.common.constant.state.MenuStatus
;
import
com.stylefeng.guns.common.constant.state.MenuStatus
;
import
com.stylefeng.guns.common.constant.state.Sex
;
import
com.stylefeng.guns.common.constant.state.Sex
;
import
com.stylefeng.guns.core.log.LogObjectHolder
;
import
com.stylefeng.guns.core.support.StrKit
;
import
com.stylefeng.guns.core.support.StrKit
;
import
com.stylefeng.guns.core.util.Convert
;
import
com.stylefeng.guns.core.util.Convert
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
com.stylefeng.guns.persistence.dao.DeptMapper
;
import
com.stylefeng.guns.persistence.dao.*
;
import
com.stylefeng.guns.persistence.dao.DictMapper
;
import
com.stylefeng.guns.persistence.model.*
;
import
com.stylefeng.guns.persistence.dao.RoleMapper
;
import
com.stylefeng.guns.persistence.dao.UserMapper
;
import
com.stylefeng.guns.persistence.model.Dept
;
import
com.stylefeng.guns.persistence.model.Dict
;
import
com.stylefeng.guns.persistence.model.Role
;
import
com.stylefeng.guns.persistence.model.User
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.context.annotation.DependsOn
;
import
org.springframework.context.annotation.DependsOn
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -38,6 +33,7 @@ public class ConstantFactory {
...
@@ -38,6 +33,7 @@ public class ConstantFactory {
private
DeptMapper
deptMapper
=
SpringContextHolder
.
getBean
(
DeptMapper
.
class
);
private
DeptMapper
deptMapper
=
SpringContextHolder
.
getBean
(
DeptMapper
.
class
);
private
DictMapper
dictMapper
=
SpringContextHolder
.
getBean
(
DictMapper
.
class
);
private
DictMapper
dictMapper
=
SpringContextHolder
.
getBean
(
DictMapper
.
class
);
private
UserMapper
userMapper
=
SpringContextHolder
.
getBean
(
UserMapper
.
class
);
private
UserMapper
userMapper
=
SpringContextHolder
.
getBean
(
UserMapper
.
class
);
private
MenuMapper
menuMapper
=
SpringContextHolder
.
getBean
(
MenuMapper
.
class
);
public
static
ConstantFactory
me
()
{
public
static
ConstantFactory
me
()
{
return
SpringContextHolder
.
getBean
(
"constantFactory"
);
return
SpringContextHolder
.
getBean
(
"constantFactory"
);
...
@@ -49,11 +45,11 @@ public class ConstantFactory {
...
@@ -49,11 +45,11 @@ public class ConstantFactory {
* @author stylefeng
* @author stylefeng
* @Date 2017/5/9 23:41
* @Date 2017/5/9 23:41
*/
*/
public
String
getUserNameById
(
Integer
userId
){
public
String
getUserNameById
(
Integer
userId
)
{
User
user
=
userMapper
.
selectById
(
userId
);
User
user
=
userMapper
.
selectById
(
userId
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
return
user
.
getName
();
return
user
.
getName
();
}
else
{
}
else
{
return
"--"
;
return
"--"
;
}
}
}
}
...
@@ -64,11 +60,11 @@ public class ConstantFactory {
...
@@ -64,11 +60,11 @@ public class ConstantFactory {
* @author stylefeng
* @author stylefeng
* @date 2017年5月16日21:55:371
* @date 2017年5月16日21:55:371
*/
*/
public
String
getUserAccountById
(
Integer
userId
){
public
String
getUserAccountById
(
Integer
userId
)
{
User
user
=
userMapper
.
selectById
(
userId
);
User
user
=
userMapper
.
selectById
(
userId
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
return
user
.
getAccount
();
return
user
.
getAccount
();
}
else
{
}
else
{
return
"--"
;
return
"--"
;
}
}
}
}
...
@@ -132,6 +128,21 @@ public class ConstantFactory {
...
@@ -132,6 +128,21 @@ public class ConstantFactory {
}
}
/**
/**
* 获取菜单的名称们(多个)
*/
public
String
getMenuNames
(
String
menuIds
)
{
Integer
[]
menus
=
Convert
.
toIntArray
(
menuIds
);
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
menu
:
menus
)
{
Menu
menuObj
=
menuMapper
.
selectById
(
menu
);
if
(
ToolUtil
.
isNotEmpty
(
menuObj
)
&&
ToolUtil
.
isNotEmpty
(
menuObj
.
getName
()))
{
sb
.
append
(
menuObj
.
getName
()).
append
(
","
);
}
}
return
StrKit
.
removeSuffix
(
sb
.
toString
(),
","
);
}
/**
* 获取性别名称
* 获取性别名称
*/
*/
public
String
getSexName
(
Integer
sex
)
{
public
String
getSexName
(
Integer
sex
)
{
...
@@ -155,18 +166,25 @@ public class ConstantFactory {
...
@@ -155,18 +166,25 @@ public class ConstantFactory {
/**
/**
* 查询字典
* 查询字典
*/
*/
public
List
<
Dict
>
findInDict
(
Integer
id
){
public
List
<
Dict
>
findInDict
(
Integer
id
)
{
if
(
ToolUtil
.
isEmpty
(
id
))
{
if
(
ToolUtil
.
isEmpty
(
id
))
{
return
null
;
return
null
;
}
else
{
}
else
{
EntityWrapper
<
Dict
>
wrapper
=
new
EntityWrapper
<>();
EntityWrapper
<
Dict
>
wrapper
=
new
EntityWrapper
<>();
List
<
Dict
>
dicts
=
dictMapper
.
selectList
(
wrapper
.
eq
(
"pid"
,
id
));
List
<
Dict
>
dicts
=
dictMapper
.
selectList
(
wrapper
.
eq
(
"pid"
,
id
));
if
(
dicts
==
null
||
dicts
.
size
()
==
0
)
{
if
(
dicts
==
null
||
dicts
.
size
()
==
0
)
{
return
null
;
return
null
;
}
else
{
}
else
{
return
dicts
;
return
dicts
;
}
}
}
}
}
}
/**
* 获取被缓存的对象(用户删除业务)
*/
public
String
getCacheObject
(
String
para
)
{
return
LogObjectHolder
.
me
().
get
().
toString
();
}
}
}
src/main/java/com/stylefeng/guns/modular/system/controller/RoleController.java
View file @
342d2488
...
@@ -3,6 +3,7 @@ package com.stylefeng.guns.modular.system.controller;
...
@@ -3,6 +3,7 @@ package com.stylefeng.guns.modular.system.controller;
import
com.stylefeng.guns.common.annotion.Permission
;
import
com.stylefeng.guns.common.annotion.Permission
;
import
com.stylefeng.guns.common.annotion.log.BussinessLog
;
import
com.stylefeng.guns.common.annotion.log.BussinessLog
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.Dict
;
import
com.stylefeng.guns.common.constant.cache.Cache
;
import
com.stylefeng.guns.common.constant.cache.Cache
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
...
@@ -117,7 +118,7 @@ public class RoleController extends BaseController {
...
@@ -117,7 +118,7 @@ public class RoleController extends BaseController {
* 角色新增
* 角色新增
*/
*/
@RequestMapping
(
value
=
"/add"
)
@RequestMapping
(
value
=
"/add"
)
@BussinessLog
(
value
=
"添加角色"
,
key
=
"name"
,
dict
=
"RoleDict"
)
@BussinessLog
(
value
=
"添加角色"
,
key
=
"name"
,
dict
=
Dict
.
RoleDict
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
@ResponseBody
public
Tip
add
(
@Valid
Role
role
,
BindingResult
result
)
{
public
Tip
add
(
@Valid
Role
role
,
BindingResult
result
)
{
...
@@ -133,7 +134,7 @@ public class RoleController extends BaseController {
...
@@ -133,7 +134,7 @@ public class RoleController extends BaseController {
* 角色修改
* 角色修改
*/
*/
@RequestMapping
(
value
=
"/edit"
)
@RequestMapping
(
value
=
"/edit"
)
@BussinessLog
(
value
=
"修改角色"
,
key
=
"name"
,
dict
=
"RoleDict"
)
@BussinessLog
(
value
=
"修改角色"
,
key
=
"name"
,
dict
=
Dict
.
RoleDict
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
@ResponseBody
public
Tip
edit
(
@Valid
Role
role
,
BindingResult
result
)
{
public
Tip
edit
(
@Valid
Role
role
,
BindingResult
result
)
{
...
@@ -151,13 +152,17 @@ public class RoleController extends BaseController {
...
@@ -151,13 +152,17 @@ public class RoleController extends BaseController {
* 删除角色
* 删除角色
*/
*/
@RequestMapping
(
value
=
"/remove"
)
@RequestMapping
(
value
=
"/remove"
)
@BussinessLog
(
value
=
"删除角色"
,
key
=
"roleId"
,
dict
=
"RoleDict"
)
@BussinessLog
(
value
=
"删除角色"
,
key
=
"roleId"
,
dict
=
Dict
.
DeleteDict
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
@ResponseBody
public
Tip
remove
(
@RequestParam
Integer
roleId
)
{
public
Tip
remove
(
@RequestParam
Integer
roleId
)
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
//缓存被删除的角色名称
LogObjectHolder
.
me
().
set
(
ConstantFactory
.
me
().
getSingleRoleName
(
roleId
));
this
.
roleService
.
delRoleById
(
roleId
);
this
.
roleService
.
delRoleById
(
roleId
);
//删除缓存
//删除缓存
...
@@ -182,7 +187,7 @@ public class RoleController extends BaseController {
...
@@ -182,7 +187,7 @@ public class RoleController extends BaseController {
* 配置权限
* 配置权限
*/
*/
@RequestMapping
(
"/setAuthority"
)
@RequestMapping
(
"/setAuthority"
)
@BussinessLog
(
value
=
"配置权限"
,
key
=
"roleId
"
,
dict
=
"RoleDict"
)
@BussinessLog
(
value
=
"配置权限"
,
key
=
"roleId
,ids"
,
dict
=
Dict
.
RoleDict
)
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@ResponseBody
@ResponseBody
public
Tip
setAuthority
(
@RequestParam
(
"roleId"
)
Integer
roleId
,
@RequestParam
(
"ids"
)
String
ids
)
{
public
Tip
setAuthority
(
@RequestParam
(
"roleId"
)
Integer
roleId
,
@RequestParam
(
"ids"
)
String
ids
)
{
...
...
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