Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
b20ae0d1
Commit
b20ae0d1
authored
Jun 09, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数字
parent
12160ce3
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
2 deletions
+93
-2
CommonConstants.java
...ud.plus.v1/yifu/common/core/constant/CommonConstants.java
+5
-0
ErrorCodes.java
....cloud.plus.v1/yifu/common/core/exception/ErrorCodes.java
+5
-0
messages_zh_CN.properties
...on-core/src/main/resources/i18n/messages_zh_CN.properties
+2
-0
UserDTO.java
...va/com/yifu.cloud.plus.v1/yifu/admin/api/dto/UserDTO.java
+11
-0
MenuController.java
...u.cloud.plus.v1/yifu/admin/controller/MenuController.java
+16
-0
SysMenuService.java
...yifu.cloud.plus.v1/yifu/admin/service/SysMenuService.java
+3
-0
SysMenuServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysMenuServiceImpl.java
+37
-0
SysRoleServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysRoleServiceImpl.java
+14
-2
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/CommonConstants.java
View file @
b20ae0d1
...
...
@@ -67,6 +67,11 @@ public interface CommonConstants {
*/
String
BACK_END_PROJECT
=
"yifu"
;
/**
* 获取一条数据的后缀
*/
String
LAST_ONE_SQL
=
" limit 1"
;
/**
* 成功标记
*/
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/exception/ErrorCodes.java
View file @
b20ae0d1
...
...
@@ -103,6 +103,11 @@ public interface ErrorCodes {
*/
String
SYS_ROLE_DELETE_SYSTEM
=
"sys.role.delete.system"
;
/**
* 该角色下还有关联的用户,请先将用户转移到其他角色!
*/
String
SYS_ROLE_DELETE_EXIST_USER
=
"sys.role.delete.existing.user"
;
/**
* 系统内置角色不能修改
*/
...
...
yifu-common/yifu-common-core/src/main/resources/i18n/messages_zh_CN.properties
View file @
b20ae0d1
...
...
@@ -27,3 +27,5 @@ sys.dict.delete.existing=\u5B57\u5178\u5B58\u5728\u4E0B\u7EA7\u8282\u70B9\u4E0D\
sys.role.delete.system
=
\u
7CFB
\u
7EDF
\u5185\u
7F6E
\u
89D2
\u8272\u
4E0D
\u
80FD
\u5220\u9664
sys.role.update.system
=
\u
7CFB
\u
7EDF
\u5185\u
7F6E
\u
89D2
\u8272\u
4E0D
\u
80FD
\u
4FEE
\u6539
sys.role.delete.existing.user
=
\u
8be5
\u
89d2
\u8272\u
4e0b
\u
8fd8
\u6709\u5173\u8054\u7684\u7528\u6237\u
ff0c
\u
8bf7
\u5148\u
5c06
\u7528\u6237\u
8f6c
\u
79fb
\u5230\u5176\u
4ed6
\u
89d2
\u8272
%21
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/dto/UserDTO.java
View file @
b20ae0d1
...
...
@@ -16,7 +16,9 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
api
.
dto
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -37,6 +39,15 @@ public class UserDTO extends SysUser {
private
Long
deptId
;
/**
* 0-正常,1-删除
*/
private
String
delFlag
;
/**
* 0-系统,1-普通用户
*/
private
String
systemFlag
;
/**
* 新密码
*/
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/MenuController.java
View file @
b20ae0d1
...
...
@@ -17,7 +17,11 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
controller
;
import
cn.hutool.core.lang.tree.Tree
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysMenu
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysMenuService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
...
...
@@ -47,6 +51,18 @@ public class MenuController {
private
final
SysMenuService
sysMenuService
;
/**
* 分页查询用户
* @param page 参数集
* @param sysMenu 查询参数列表
* @return 用户集合
*/
@GetMapping
(
"/page"
)
public
R
<
IPage
<
List
<
SysMenu
>>>
getMenuPage
(
Page
page
,
SysMenu
sysMenu
)
{
return
R
.
ok
(
sysMenuService
.
getMenuPage
(
page
,
sysMenu
));
}
/**
* 返回当前用户的树形菜单集合
* @param parentId 父节点ID
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/SysMenuService.java
View file @
b20ae0d1
...
...
@@ -17,6 +17,8 @@
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
service
;
import
cn.hutool.core.lang.tree.Tree
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysMenu
;
...
...
@@ -75,4 +77,5 @@ public interface SysMenuService extends IService<SysMenu> {
*/
void
clearMenuCache
();
IPage
<
List
<
SysMenu
>>
getMenuPage
(
Page
page
,
SysMenu
sysMenu
);
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysMenuServiceImpl.java
View file @
b20ae0d1
...
...
@@ -20,9 +20,15 @@ import cn.hutool.core.collection.CollUtil;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.TreeNode
;
import
cn.hutool.core.lang.tree.TreeUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.dto.SysLogDTO
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysMenu
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRoleMenu
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysMenuMapper
;
...
...
@@ -142,6 +148,37 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
}
@Override
public
IPage
<
List
<
SysMenu
>>
getMenuPage
(
Page
page
,
SysMenu
sysMenu
)
{
sysMenu
.
setDelFlag
(
CommonConstants
.
STATUS_DEL
);
return
baseMapper
.
selectPage
(
page
,
buildQueryWrapper
(
sysMenu
));
}
/**
* 构建查询的 wrapper
* @param sysMenu 查询条件
* @return LambdaQueryWrapper
*/
private
LambdaQueryWrapper
buildQueryWrapper
(
SysMenu
sysMenu
)
{
LambdaQueryWrapper
<
SysMenu
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
StrUtil
.
isNotBlank
(
sysMenu
.
getFlag
()))
{
wrapper
.
eq
(
SysMenu:
:
getFlag
,
sysMenu
.
getFlag
());
}
if
(
StrUtil
.
isNotBlank
(
sysMenu
.
getName
())){
wrapper
.
eq
(
SysMenu:
:
getName
,
sysMenu
.
getMenuId
());
}
if
(
StrUtil
.
isNotBlank
(
sysMenu
.
getSystemFlag
())){
wrapper
.
eq
(
SysMenu:
:
getSystemFlag
,
sysMenu
.
getSystemFlag
());
}
if
(
StrUtil
.
isNotBlank
(
sysMenu
.
getType
())){
wrapper
.
eq
(
SysMenu:
:
getType
,
sysMenu
.
getType
());
}
if
(
StrUtil
.
isNotBlank
(
sysMenu
.
getDelFlag
())){
wrapper
.
eq
(
SysMenu:
:
getDelFlag
,
sysMenu
.
getDelFlag
());
}
return
wrapper
;
}
@NotNull
private
Function
<
SysMenu
,
TreeNode
<
Long
>>
getNodeFunction
()
{
return
menu
->
{
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysRoleServiceImpl.java
View file @
b20ae0d1
...
...
@@ -27,11 +27,15 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict;
import
com.pig4cloud.plugin.excel.vo.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRoleMenu
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUserRole
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.vo.RoleExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysRoleMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysRoleMenuMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserRoleMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysRoleService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.enums.DictTypeEnum
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
...
...
@@ -63,6 +67,8 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
private
final
SysRoleMenuMapper
sysRoleMenuMapper
;
private
final
SysUserRoleMapper
sysUserRoleMapper
;
/**
* 通过角色ID,删除角色,并清空角色菜单缓存
* @param id
...
...
@@ -73,9 +79,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
@CacheEvict
(
value
=
CacheConstants
.
MENU_DETAILS
,
allEntries
=
true
)
public
Boolean
removeRoleById
(
Long
id
)
{
SysRole
sysRole
=
this
.
getById
(
id
);
String
type
=
"0"
;
if
(
Common
.
isEmpty
(
sysRole
)){
return
false
;
}
SysUserRole
userRole
=
sysUserRoleMapper
.
selectOne
(
Wrappers
.<
SysUserRole
>
query
().
lambda
()
.
eq
(
SysUserRole:
:
getRoleId
,
sysRole
.
getRoleId
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
//已存在用户
Assert
.
state
(!
Common
.
isEmpty
(
userRole
),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_ROLE_DELETE_EXIST_USER
));
//系统内置
Assert
.
state
(!
type
.
equals
(
sysRole
.
getSystemFlag
()),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_ROLE_DELETE_SYSTEM
));
Assert
.
state
(!
CommonConstants
.
ZERO_String
.
equals
(
sysRole
.
getSystemFlag
()),
MsgUtils
.
getMessage
(
ErrorCodes
.
SYS_ROLE_DELETE_SYSTEM
));
sysRoleMenuMapper
.
delete
(
Wrappers
.<
SysRoleMenu
>
update
().
lambda
().
eq
(
SysRoleMenu:
:
getRoleId
,
id
));
return
this
.
removeById
(
id
);
}
...
...
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