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
68116221
Commit
68116221
authored
Jun 07, 2022
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hyc 用户菜单字典调整
parent
5e84da90
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
161 additions
and
25 deletions
+161
-25
UserDTO.java
...va/com/yifu.cloud.plus.v1/yifu/admin/api/dto/UserDTO.java
+0
-5
SysDictItem.java
...yifu.cloud.plus.v1/yifu/admin/api/entity/SysDictItem.java
+9
-0
SysMenu.java
...com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysMenu.java
+6
-0
SysUser.java
...com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysUser.java
+22
-0
UserVO.java
...java/com/yifu.cloud.plus.v1/yifu/admin/api/vo/UserVO.java
+14
-0
DictController.java
...u.cloud.plus.v1/yifu/admin/controller/DictController.java
+12
-0
SysDictItemService.java
....cloud.plus.v1/yifu/admin/service/SysDictItemService.java
+10
-0
SysDictItemServiceImpl.java
...us.v1/yifu/admin/service/impl/SysDictItemServiceImpl.java
+58
-0
SysUserServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
+10
-17
SysMenuMapper.xml
...yifu-upms-biz/src/main/resources/mapper/SysMenuMapper.xml
+2
-0
SysUserMapper.xml
...yifu-upms-biz/src/main/resources/mapper/SysUserMapper.xml
+18
-3
No files found.
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/dto/UserDTO.java
View file @
68116221
...
...
@@ -37,11 +37,6 @@ public class UserDTO extends SysUser {
private
Long
deptId
;
/**
* 岗位ID
*/
private
List
<
Long
>
post
;
/**
* 新密码
*/
...
...
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysDictItem.java
View file @
68116221
...
...
@@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.NotNull
;
/**
* 字典项
*
...
...
@@ -85,6 +87,13 @@ public class SysDictItem extends BaseEntity {
@Schema
(
description
=
"备注信息"
)
private
String
remark
;
/**
* 父节点ID
*/
@NotNull
(
message
=
"字典父节点ID不能为空"
)
@Schema
(
description
=
"字典父节点id"
)
private
Long
parentId
;
/**
* 删除标记
*/
...
...
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysMenu.java
View file @
68116221
...
...
@@ -104,4 +104,10 @@ public class SysMenu extends BaseEntity {
@TableLogic
private
String
delFlag
;
/**
* 是否支持数据权限设置 (0是 1否)
*/
@Schema
(
description
=
"是否支持数据权限标识"
)
private
String
flag
;
}
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysUser.java
View file @
68116221
...
...
@@ -25,6 +25,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.validation.constraints.NotNull
;
/**
* <p>
* 用户表
...
...
@@ -95,6 +97,26 @@ public class SysUser extends BaseEntity {
@Schema
(
description
=
"用户所属部门id"
)
private
Long
deptId
;
/**
* 用户分组
*/
@NotNull
(
message
=
"用户分组不能为空"
)
@Schema
(
description
=
"用户分组"
)
private
String
userGroup
;
/**
* 职务
*/
@Schema
(
description
=
"职务"
)
private
String
post
;
/**
* 邮箱
*/
@NotNull
(
message
=
"邮箱不能为空"
)
@Schema
(
description
=
"邮箱"
)
private
String
email
;
/**
* 0-正常,1-删除
*/
...
...
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/vo/UserVO.java
View file @
68116221
...
...
@@ -108,4 +108,18 @@ public class UserVO implements Serializable {
*/
private
List
<
SysPost
>
postList
;
/**
* 用户分组
*/
private
String
userGroup
;
/**
* 职务
*/
private
String
post
;
/**
* 邮箱
*/
private
String
email
;
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/DictController.java
View file @
68116221
...
...
@@ -16,6 +16,7 @@
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.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -191,4 +192,15 @@ public class DictController {
return
R
.
ok
();
}
/**
* 返回树形字典集合
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return 树形菜单
*/
@GetMapping
(
value
=
"/tree"
)
public
R
<
List
<
Tree
<
Long
>>>
getTree
(
boolean
lazy
,
Long
parentId
)
{
return
R
.
ok
(
sysDictItemService
.
treeMenu
(
lazy
,
parentId
));
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/SysDictItemService.java
View file @
68116221
...
...
@@ -15,9 +15,12 @@
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
service
;
import
cn.hutool.core.lang.tree.Tree
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem
;
import
java.util.List
;
/**
* 字典项
*
...
...
@@ -40,4 +43,11 @@ public interface SysDictItemService extends IService<SysDictItem> {
*/
void
updateDictItem
(
SysDictItem
item
);
/**
* 构建树
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return
*/
List
<
Tree
<
Long
>>
treeMenu
(
boolean
lazy
,
Long
parentId
);
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysDictItemServiceImpl.java
View file @
68116221
...
...
@@ -15,6 +15,10 @@
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
admin
.
service
.
impl
;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.TreeNode
;
import
cn.hutool.core.lang.tree.TreeUtil
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem
;
...
...
@@ -22,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService
;
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.MsgUtils
;
...
...
@@ -30,6 +35,13 @@ import org.springframework.cache.annotation.CacheEvict;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
javax.validation.constraints.NotNull
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* 字典项
*
...
...
@@ -75,4 +87,50 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
this
.
updateById
(
item
);
}
/**
* 构建树查询 1. 不是懒加载情况,查询全部 2. 是懒加载,根据parentId 查询 2.1 父节点为空,则查询ID -1
* @param lazy 是否是懒加载
* @param parentId 父节点ID
* @return
*/
@Override
public
List
<
Tree
<
Long
>>
treeMenu
(
boolean
lazy
,
Long
parentId
)
{
if
(!
lazy
)
{
List
<
TreeNode
<
Long
>>
collect
=
baseMapper
.
selectList
(
Wrappers
.<
SysDictItem
>
lambdaQuery
().
orderByAsc
(
SysDictItem:
:
getSortOrder
)).
stream
()
.
map
(
getNodeFunction
()).
collect
(
Collectors
.
toList
());
return
TreeUtil
.
build
(
collect
,
CommonConstants
.
MENU_TREE_ROOT_ID
);
}
Long
parent
=
parentId
==
null
?
CommonConstants
.
MENU_TREE_ROOT_ID
:
parentId
;
List
<
TreeNode
<
Long
>>
collect
=
baseMapper
.
selectList
(
Wrappers
.<
SysDictItem
>
lambdaQuery
().
eq
(
SysDictItem:
:
getParentId
,
parent
)
.
orderByAsc
(
SysDictItem:
:
getSortOrder
))
.
stream
().
map
(
getNodeFunction
()).
collect
(
Collectors
.
toList
());
return
TreeUtil
.
build
(
collect
,
parent
);
}
@NotNull
private
Function
<
SysDictItem
,
TreeNode
<
Long
>>
getNodeFunction
()
{
return
sysDictItem
->
{
TreeNode
<
Long
>
node
=
new
TreeNode
<>();
node
.
setId
(
sysDictItem
.
getId
());
node
.
setName
(
sysDictItem
.
getLabel
());
node
.
setParentId
(
sysDictItem
.
getParentId
());
node
.
setWeight
(
sysDictItem
.
getSortOrder
());
// 扩展属性
Map
<
String
,
Object
>
extra
=
new
HashMap
<>();
extra
.
put
(
"value"
,
sysDictItem
.
getValue
());
extra
.
put
(
"dictId"
,
sysDictItem
.
getDictId
());
extra
.
put
(
"type"
,
sysDictItem
.
getType
());
extra
.
put
(
"label"
,
sysDictItem
.
getLabel
());
extra
.
put
(
"sortOrder"
,
sysDictItem
.
getSortOrder
());
node
.
setExtra
(
extra
);
return
node
;
};
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
View file @
68116221
...
...
@@ -97,14 +97,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return
userRole
;
}).
forEach
(
sysUserRoleMapper:
:
insert
);
// 保存用户岗位信息
Optional
.
ofNullable
(
userDto
.
getPost
()).
ifPresent
(
posts
->
{
posts
.
stream
().
map
(
postId
->
{
SysUserPost
userPost
=
new
SysUserPost
();
userPost
.
setUserId
(
sysUser
.
getUserId
());
userPost
.
setPostId
(
postId
);
return
userPost
;
}).
forEach
(
sysUserPostMapper:
:
insert
);
});
//
Optional.ofNullable(userDto.getPost()).ifPresent(posts -> {
//
posts.stream().map(postId -> {
//
SysUserPost userPost = new SysUserPost();
//
userPost.setUserId(sysUser.getUserId());
//
userPost.setPostId(postId);
//
return userPost;
//
}).forEach(sysUserPostMapper::insert);
//
});
return
Boolean
.
TRUE
;
}
...
...
@@ -215,13 +215,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userRole
.
setRoleId
(
roleId
);
userRole
.
insert
();
});
sysUserPostMapper
.
delete
(
Wrappers
.<
SysUserPost
>
lambdaQuery
().
eq
(
SysUserPost:
:
getUserId
,
userDto
.
getUserId
()));
userDto
.
getPost
().
forEach
(
postId
->
{
SysUserPost
userPost
=
new
SysUserPost
();
userPost
.
setUserId
(
sysUser
.
getUserId
());
userPost
.
setPostId
(
postId
);
userPost
.
insert
();
});
return
Boolean
.
TRUE
;
}
...
...
@@ -361,8 +354,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 根据角色名称查询角色ID
List
<
Long
>
roleIdList
=
roleCollList
.
stream
().
map
(
SysRole:
:
getRoleId
).
collect
(
Collectors
.
toList
());
userDTO
.
setRole
(
roleIdList
);
List
<
Long
>
postIdList
=
postCollList
.
stream
().
map
(
SysPost:
:
getPostId
).
collect
(
Collectors
.
toList
());
userDTO
.
setPost
(
postIdList
);
//
List<Long> postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList());
//
userDTO.setPost(postIdList);
// 插入用户
this
.
saveUser
(
userDTO
);
}
...
...
yifu-upms/yifu-upms-biz/src/main/resources/mapper/SysMenuMapper.xml
View file @
68116221
...
...
@@ -33,6 +33,7 @@
<result
column=
"update_by"
property=
"updateBy"
/>
<result
column=
"update_time"
property=
"updateTime"
/>
<result
column=
"del_flag"
property=
"delFlag"
/>
<result
column=
"flag"
property=
"flag"
/>
</resultMap>
<!--通过角色查询菜单信息-->
...
...
@@ -47,6 +48,7 @@
sys_menu.keep_alive,
sys_menu.type,
sys_menu.del_flag,
sys_menu.flag,
sys_menu.create_by,
sys_menu.create_time,
sys_menu.update_by,
...
...
yifu-upms/yifu-upms-biz/src/main/resources/mapper/SysUserMapper.xml
View file @
68116221
...
...
@@ -32,12 +32,12 @@
<result
column=
"deptId"
property=
"deptId"
/>
<result
column=
"deptName"
property=
"deptName"
/>
<result
column=
"nickname"
property=
"nickname"
/>
<result
column=
"user_group"
property=
"userGroup"
/>
<result
column=
"post"
property=
"post"
/>
<result
column=
"email"
property=
"email"
/>
<collection
property=
"roleList"
ofType=
"com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole"
select=
"com.yifu.cloud.plus.v1.yifu.admin.mapper.SysRoleMapper.listRolesByUserId"
column=
"user_id"
>
</collection>
<collection
property=
"postList"
ofType=
"com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysPost"
select=
"com.yifu.cloud.plus.v1.yifu.admin.mapper.SysPostMapper.listPostsByUserId"
column=
"user_id"
>
</collection>
</resultMap>
<!-- userVo结果集 -->
...
...
@@ -55,6 +55,9 @@
<result
column=
"deptId"
property=
"deptId"
/>
<result
column=
"deptName"
property=
"deptName"
/>
<result
column=
"nickname"
property=
"nickname"
/>
<result
column=
"user_group"
property=
"userGroup"
/>
<result
column=
"post"
property=
"post"
/>
<result
column=
"email"
property=
"email"
/>
<collection
property=
"roleList"
ofType=
"com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole"
>
<id
column=
"role_id"
property=
"roleId"
/>
<result
column=
"role_name"
property=
"roleName"
/>
...
...
@@ -79,6 +82,9 @@
sys_user.del_flag AS udel_flag,
sys_user.lock_flag AS lock_flag,
sys_user.dept_id AS deptId,
sys_user.user_group AS userGroup,
sys_user.post,
sys_user.email,
r.role_id,
r.role_name,
r.role_code,
...
...
@@ -99,6 +105,9 @@
sys_user.update_time AS uupdate_time,
sys_user.del_flag AS udel_flag,
sys_user.lock_flag AS lock_flag,
sys_user.user_group AS userGroup,
sys_user.post,
sys_user.email,
r.role_id,
r.role_name,
r.role_code,
...
...
@@ -141,6 +150,9 @@
sys_user.del_flag AS udel_flag,
sys_user.lock_flag AS lock_flag,
sys_user.dept_id AS deptId,
sys_user.user_group AS userGroup,
sys_user.post,
sys_user.email,
sys_dept.name AS deptName
FROM sys_user
LEFT JOIN sys_dept ON sys_dept.dept_id = sys_user.dept_id
...
...
@@ -167,6 +179,9 @@
u.update_time uupdate_time,
u.del_flag,
u.lock_flag,
u.group,
u.user_group userGroup,
u.email,
d.name AS deptName
FROM sys_user u
LEFT JOIN sys_dept d ON d.dept_id = u.dept_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