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
2ba4f510
Commit
2ba4f510
authored
Jun 13, 2017
by
naan1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除菜单可以删除子菜单
parent
8a4d1579
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
6 deletions
+37
-6
sql/guns.sql
+2
-2
src/main/java/com/stylefeng/guns/modular/system/controller/MenuController.java
+1
-1
src/main/java/com/stylefeng/guns/modular/system/dao/mapping/MenuDao.xml
+1
-1
src/main/java/com/stylefeng/guns/modular/system/service/IMenuService.java
+8
-0
src/main/java/com/stylefeng/guns/modular/system/service/impl/MenuServiceImpl.java
+24
-0
src/test/java/com/stylefeng/guns/base/BaseJunit.java
+1
-2
No files found.
sql/guns.sql
View file @
2ba4f510
...
...
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50621
File Encoding : 65001
Date: 2017-06-13 2
1:58:58
Date: 2017-06-13 2
2:26:27
*/
SET
FOREIGN_KEY_CHECKS
=
0
;
...
...
@@ -164,7 +164,7 @@ INSERT INTO `menu` VALUES ('161', 'login_log_list', 'loginLog', '[0],[system],[l
INSERT
INTO
`menu`
VALUES
(
'162'
,
'to_role_edit'
,
'role'
,
'[0],[system],[role],'
,
'修改角色跳转'
,
''
,
'/role/role_edit'
,
'5'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
INSERT
INTO
`menu`
VALUES
(
'163'
,
'to_role_assign'
,
'role'
,
'[0],[system],[role],'
,
'角色分配跳转'
,
''
,
'/role/role_assign'
,
'6'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
INSERT
INTO
`menu`
VALUES
(
'164'
,
'role_list'
,
'role'
,
'[0],[system],[role],'
,
'角色列表'
,
''
,
'/role/list'
,
'7'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
INSERT
INTO
`menu`
VALUES
(
'165'
,
'to_
role_assign'
,
'mgr'
,
'[0],[system],[role
],'
,
'分配角色跳转'
,
''
,
'/mgr/role_assign'
,
'8'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
INSERT
INTO
`menu`
VALUES
(
'165'
,
'to_
assign_role'
,
'mgr'
,
'[0],[system],[mgr
],'
,
'分配角色跳转'
,
''
,
'/mgr/role_assign'
,
'8'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
INSERT
INTO
`menu`
VALUES
(
'166'
,
'to_user_edit'
,
'mgr'
,
'[0],[system],[mgr],'
,
'编辑用户跳转'
,
''
,
'/mgr/user_edit'
,
'9'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
INSERT
INTO
`menu`
VALUES
(
'167'
,
'mgr_list'
,
'mgr'
,
'[0],[system],[mgr],'
,
'用户列表'
,
''
,
'/mgr/list'
,
'10'
,
'3'
,
'0'
,
null
,
'1'
,
null
);
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/MenuController.java
View file @
2ba4f510
...
...
@@ -163,7 +163,7 @@ public class MenuController extends BaseController {
//缓存菜单的名称
LogObjectHolder
.
me
().
set
(
ConstantFactory
.
me
().
getMenuName
(
menuId
));
this
.
menuService
.
delMenu
(
menuId
);
this
.
menuService
.
delMenu
ContainSubMenus
(
menuId
);
return
SUCCESS_TIP
;
}
...
...
src/main/java/com/stylefeng/guns/modular/system/dao/mapping/MenuDao.xml
View file @
2ba4f510
...
...
@@ -4,7 +4,7 @@
<sql
id=
"Base_Column_List"
>
id, code, pcode, name, icon, url, num, levels,
id, code, pcode, name, icon, url, num, levels,
pcodes,
tips, status,isopen,ismenu
</sql>
...
...
src/main/java/com/stylefeng/guns/modular/system/service/IMenuService.java
View file @
2ba4f510
...
...
@@ -15,4 +15,12 @@ public interface IMenuService {
* @Date 2017/5/5 22:20
*/
void
delMenu
(
Integer
menuId
);
/**
* 删除菜单包含所有子菜单
*
* @author stylefeng
* @Date 2017/6/13 22:02
*/
void
delMenuContainSubMenus
(
Integer
menuId
);
}
src/main/java/com/stylefeng/guns/modular/system/service/impl/MenuServiceImpl.java
View file @
2ba4f510
package
com
.
stylefeng
.
guns
.
modular
.
system
.
service
.
impl
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.Wrapper
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.persistence.model.Menu
;
import
com.stylefeng.guns.modular.system.dao.MenuDao
;
import
com.stylefeng.guns.modular.system.service.IMenuService
;
import
com.stylefeng.guns.common.persistence.dao.MenuMapper
;
import
com.sun.xml.internal.bind.v2.ContextFactory
;
import
net.sf.ehcache.util.MergedEnumeration
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* 菜单服务
...
...
@@ -31,4 +38,21 @@ public class MenuServiceImpl implements IMenuService {
//删除关联的relation
this
.
menuDao
.
deleteRelationByMenu
(
menuId
);
}
@Override
public
void
delMenuContainSubMenus
(
Integer
menuId
)
{
Menu
menu
=
menuMapper
.
selectById
(
menuId
);
//删除当前菜单
delMenu
(
menuId
);
//删除所有子菜单
Wrapper
<
Menu
>
wrapper
=
new
EntityWrapper
<>();
wrapper
=
wrapper
.
like
(
"pcodes"
,
"%["
+
menu
.
getCode
()
+
"]%"
);
List
<
Menu
>
menus
=
menuMapper
.
selectList
(
wrapper
);
for
(
Menu
temp
:
menus
)
{
delMenu
(
temp
.
getId
());
}
}
}
src/test/java/com/stylefeng/guns/base/BaseJunit.java
View file @
2ba4f510
...
...
@@ -9,7 +9,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.context.WebApplicationContext
;
...
...
@@ -22,7 +21,7 @@ import org.springframework.web.context.WebApplicationContext;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
GunsApplication
.
class
)
@WebAppConfiguration
@Transactional
//测试之后数据可
回滚
//@Transactional //打开的话测试之后数据可自动
回滚
public
class
BaseJunit
{
@Autowired
...
...
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