Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bill-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
bill-platform
Commits
d114bca7
Commit
d114bca7
authored
Sep 12, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加菜单资源配置
parent
2e031457
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
0 deletions
+59
-0
bill-manager/src/main/java/com/mortals/xhx/base/system/menu/dao/MenuDao.java
...in/java/com/mortals/xhx/base/system/menu/dao/MenuDao.java
+8
-0
bill-manager/src/main/java/com/mortals/xhx/base/system/menu/dao/ibatis/MenuDaoImpl.java
.../mortals/xhx/base/system/menu/dao/ibatis/MenuDaoImpl.java
+6
-0
bill-manager/src/main/java/com/mortals/xhx/base/system/menu/service/impl/MenuServiceImpl.java
...ls/xhx/base/system/menu/service/impl/MenuServiceImpl.java
+45
-0
No files found.
bill-manager/src/main/java/com/mortals/xhx/base/system/menu/dao/MenuDao.java
View file @
d114bca7
...
...
@@ -27,4 +27,12 @@ import java.util.List;
public
interface
MenuDao
extends
ICRUDDao
<
MenuEntity
,
Long
>
{
List
<
MenuEntity
>
getListByUserId
(
Long
userId
);
/**
* 查询子节点
*
* @param
* @return
*/
List
<
MenuEntity
>
selectChildrenMenuById
(
String
menuId
);
}
\ No newline at end of file
bill-manager/src/main/java/com/mortals/xhx/base/system/menu/dao/ibatis/MenuDaoImpl.java
View file @
d114bca7
...
...
@@ -28,6 +28,12 @@ import java.util.List;
@Repository
(
"menuDao"
)
public
class
MenuDaoImpl
extends
BaseCRUDDaoMybatis
<
MenuEntity
,
Long
>
implements
MenuDao
{
@Override
public
List
<
MenuEntity
>
selectChildrenMenuById
(
String
menuId
)
{
return
getSqlSession
().
selectList
(
getSqlId
(
"selectChildrenMenuById"
),
menuId
);
}
@Override
public
List
<
MenuEntity
>
getListByUserId
(
Long
userId
)
{
ParamDto
param
=
new
ParamDto
();
...
...
bill-manager/src/main/java/com/mortals/xhx/base/system/menu/service/impl/MenuServiceImpl.java
View file @
d114bca7
...
...
@@ -133,6 +133,10 @@ public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity
@Override
protected
void
saveBefore
(
MenuEntity
entity
,
Context
context
)
throws
AppException
{
MenuEntity
parentMenuEntity
=
this
.
get
(
entity
.
getParentId
());
if
(!
ObjectUtils
.
isEmpty
(
parentMenuEntity
))
{
entity
.
setAncestors
(
parentMenuEntity
.
getAncestors
()
+
","
+
entity
.
getParentId
());
}
MenuQuery
query
=
new
MenuQuery
();
query
.
setParentId
(
entity
.
getParentId
());
Comparator
<
Integer
>
comparator
=
Comparator
.
comparing
(
Integer:
:
intValue
);
...
...
@@ -144,6 +148,38 @@ public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity
super
.
saveBefore
(
entity
,
context
);
}
@Override
protected
void
updateBefore
(
MenuEntity
entity
,
Context
context
)
throws
AppException
{
MenuEntity
newParentEntity
=
this
.
get
(
entity
.
getParentId
());
MenuEntity
oldEntity
=
this
.
get
(
entity
.
getId
());
if
(!
ObjectUtils
.
isEmpty
(
newParentEntity
)
&&
!
ObjectUtils
.
isEmpty
(
oldEntity
))
{
String
newAncestors
=
newParentEntity
.
getAncestors
()
+
","
+
newParentEntity
.
getId
();
String
oldAncestors
=
oldEntity
.
getAncestors
();
entity
.
setAncestors
(
newAncestors
);
updateMenuChildren
(
entity
.
getId
(),
newAncestors
,
oldAncestors
,
context
);
}
super
.
updateBefore
(
entity
,
context
);
}
/**
* 修改子元素关系
*
* @param menuId 被修改的菜单信息业务ID
* @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合
*/
public
void
updateMenuChildren
(
Long
menuId
,
String
newAncestors
,
String
oldAncestors
,
Context
context
)
{
List
<
MenuEntity
>
children
=
getDao
().
selectChildrenMenuById
(
menuId
.
toString
());
for
(
MenuEntity
child
:
children
)
{
child
.
setAncestors
(
child
.
getAncestors
().
replace
(
oldAncestors
,
newAncestors
));
}
if
(
children
.
size
()
>
0
)
{
this
.
updateAfter
(
children
,
context
);
}
}
@Override
public
boolean
hasChildByMenuId
(
Long
menuId
)
{
List
<
MenuEntity
>
list
=
this
.
find
(
new
MenuQuery
().
parentId
(
menuId
));
...
...
@@ -223,6 +259,15 @@ public class MenuServiceImpl extends AbstractCRUDServiceImpl<MenuDao, MenuEntity
}
}
@Override
protected
void
removeBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
//有子节点 禁止删除
if
(
hasChildByMenuId
(
ids
[
0
]))
{
throw
new
AppException
(
"存在下级菜单信息业务,不允许删除"
);
}
super
.
removeBefore
(
ids
,
context
);
}
/**
* 判断是否有子节点
*/
...
...
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