Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9e7b849f
authored
Sep 05, 2023
by
李小龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
组织角色
parent
fa006437
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
523 deletions
server-service/src/main/java/com/makeit/service/platform/auth/PlatUserService.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatOrgServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatRoleServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
server-service/src/main/java/com/makeit/service/saas/impl/PlatTenantServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/auth/PlatUserService.java
View file @
9e7b849f
...
...
@@ -58,14 +58,10 @@ public interface PlatUserService extends IService<PlatUser> {
PlatUserLoginVO
getRoleAndMenuList2
();
// PlatUserLoginVO getWechatMenuList();
PlatUserLoginVO
getUserVO
();
PlatPersonDTOVO
getUserDetail
();
// List<String> getCustomGroupNameList();
List
<
PlatRole
>
getRoleList
(
String
userId
);
...
...
@@ -88,10 +84,6 @@ public interface PlatUserService extends IService<PlatUser> {
PlatPersonDTOVO
viewPerson
(
String
id
);
// void changeDeptMessage(PlatUser tntUser, String oldDeptId, String newDeptId);
//void leaveMessage(PlatUser tntUser);
List
<
PlatRole
>
getRoleListWithTag
(
String
userId
);
PlatRole
getMaxRole
(
String
userId
);
...
...
@@ -116,11 +108,6 @@ public interface PlatUserService extends IService<PlatUser> {
List
<
PlatOrg
>
getCandidateDeptList
();
// List<String> getCustomGroupNameList(String userId);
//
// List<String> getCustomGroupIdList(String userId);
List
<
PlatMenu
>
getMenuListByUserId
(
String
userId
);
/**
...
...
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatOrgServiceImpl.java
View file @
9e7b849f
...
...
@@ -17,8 +17,6 @@ import com.makeit.enums.CommonEnum;
import
com.makeit.enums.id.TreeConst
;
import
com.makeit.global.aspect.tenant.TenantIdUtil
;
import
com.makeit.mapper.platform.auth.PlatOrgMapper
;
import
com.makeit.module.admin.dto.plat.PlatUserQueryDTO
;
import
com.makeit.module.system.service.SysConfigCategoryService
;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.auth.PlatRoleOrgService
;
import
com.makeit.service.platform.auth.PlatRoleService
;
...
...
@@ -29,7 +27,6 @@ import com.makeit.utils.data.convert.StreamUtil;
import
com.makeit.utils.user.plat.PlatUserUtil
;
import
com.makeit.utils.user.plat.PlatUserVO
;
import
com.makeit.vo.platform.auth.PlatOrgQueryDTO
;
import
com.makeit.vo.platform.auth.PlatUserCountVO
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -58,16 +55,11 @@ import java.util.stream.Stream;
@Service
public
class
PlatOrgServiceImpl
extends
ServiceImpl
<
PlatOrgMapper
,
PlatOrg
>
implements
PlatOrgService
{
// @Autowired
// private TntAsyncCommonService tntAsyncCommonService;
@Autowired
private
PlatUserService
platUserService
;
@Autowired
private
SysConfigCategoryService
sysConfigCategoryService
;
@Autowired
private
PlatUserRoleService
platUserRoleService
;
@Autowired
private
PlatRoleOrgService
platRoleOrgService
;
...
...
@@ -98,19 +90,11 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
List
<
PlatOrg
>
deptList
=
list
(
new
QueryWrapper
<
PlatOrg
>().
lambda
()
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getType
()),
PlatOrg:
:
getType
,
dto
.
getType
())
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getType
()),
PlatOrg:
:
getType
,
dto
.
getType
())
);
deptList
.
forEach
(
e
->
{
// e.setCanTap(CommonEnum.YES.getValue());
});
List
<
PlatOrg
>
tntDeptList
=
this
.
getDeptSelfAndChildren
(
dto
.
getOrgId
());
// if (CommonEnum.YES.getValue().equals(dto.getFromHotel())) {
// tntDeptList = StreamUtil.filter(tntDeptList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag()));
// }
List
<
String
>
idList
=
StreamUtil
.
map
(
tntDeptList
,
PlatOrg:
:
getId
);
if
(
StringUtils
.
isNotBlank
(
dto
.
getOrgId
()))
{
//左上方可点击的 和 左下方中的任意
idList
.
add
(
dto
.
getOrgId
());
...
...
@@ -122,9 +106,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
List
<
PlatOrg
>
newList
=
new
ArrayList
<>(
10
);
flat
(
topList
,
newList
);
newList
.
forEach
(
e
->
{
e
.
setChildren
(
null
);
});
newList
.
forEach
(
e
->
e
.
setChildren
(
null
));
tntDeptList
=
newList
;
tntDeptList
=
filter
(
tntDeptList
,
dto
);
...
...
@@ -135,7 +117,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
private
List
<
PlatOrg
>
tree
(
List
<
PlatOrg
>
tntDeptList
,
List
<
String
>
deptIdList
)
{
Map
<
String
,
PlatOrg
>
map
=
StreamUtil
.
toMap
(
tntDeptList
,
PlatOrg:
:
getId
);
List
<
PlatOrg
>
topList
=
deptIdList
.
stream
().
map
(
e
->
map
.
get
(
e
)
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
List
<
PlatOrg
>
topList
=
deptIdList
.
stream
().
map
(
map:
:
get
).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
tntDeptList
.
forEach
(
e
->
{
PlatOrg
parent
=
map
.
get
(
e
.
getParentId
());
if
(
parent
!=
null
)
{
...
...
@@ -156,7 +138,6 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public
List
<
PlatOrg
>
tree
(
List
<
PlatOrg
>
tntDeptList
)
{
Map
<
String
,
PlatOrg
>
map
=
StreamUtil
.
toMap
(
tntDeptList
,
PlatOrg:
:
getId
);
//List<PlatOrg> topList = StreamUtil.filter(tntDeptList, e -> TreeConst.TOP_LEVEL.equals(e.getParentId()));
List
<
PlatOrg
>
topList
=
new
ArrayList
<>(
10
);
tntDeptList
.
forEach
(
e
->
{
PlatOrg
parent
=
map
.
get
(
e
.
getParentId
());
...
...
@@ -245,9 +226,9 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
//获取对应部门名称的部门数据
List
<
PlatOrg
>
tntDepts
=
StreamUtil
.
filter
(
selfAndChildren
,
e
->
deptName
.
equals
(
e
.
getName
()));
if
(
CollectionUtils
.
isNotEmpty
(
tntDepts
))
{
List
<
PlatOrg
>
P
latOrgFilterByName
=
tree
(
selfAndChildren
,
Arrays
.
asList
(
tntDepts
.
get
(
0
).
getId
()));
List
<
PlatOrg
>
p
latOrgFilterByName
=
tree
(
selfAndChildren
,
Arrays
.
asList
(
tntDepts
.
get
(
0
).
getId
()));
List
<
PlatOrg
>
tntDeptArrayList
=
new
ArrayList
<>(
10
);
flat
(
P
latOrgFilterByName
,
tntDeptArrayList
);
flat
(
p
latOrgFilterByName
,
tntDeptArrayList
);
return
tntDeptArrayList
;
}
}
...
...
@@ -263,8 +244,8 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Override
public
Map
<
String
,
List
<
PlatOrg
>>
findSelfAndAllParent
(
List
<
String
>
deptIdList
)
{
List
<
PlatOrg
>
deptList
=
list
(
new
QueryWrapper
<
PlatOrg
>().
lambda
()
.
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
.
orderByAsc
(
PlatOrg:
:
getId
)
.
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
.
orderByAsc
(
PlatOrg:
:
getId
)
);
Map
<
String
,
PlatOrg
>
deptMap
=
StreamUtil
.
toMap
(
deptList
,
PlatOrg:
:
getId
);
...
...
@@ -316,9 +297,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public
void
flat
(
List
<
PlatOrg
>
oldList
,
List
<
PlatOrg
>
newList
)
{
if
(
oldList
!=
null
)
{
newList
.
addAll
(
oldList
);
oldList
.
forEach
(
e
->
{
flat
(
e
.
getChildren
(),
newList
);
});
oldList
.
forEach
(
e
->
flat
(
e
.
getChildren
(),
newList
));
}
}
...
...
@@ -326,9 +305,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public
void
flatChildren
(
PlatOrg
old
,
List
<
PlatOrg
>
newList
)
{
if
(
old
!=
null
&&
old
.
getChildren
()
!=
null
)
{
newList
.
addAll
(
old
.
getChildren
());
old
.
getChildren
().
forEach
(
e
->
{
flatChildren
(
e
,
newList
);
});
old
.
getChildren
().
forEach
(
e
->
flatChildren
(
e
,
newList
));
}
}
...
...
@@ -364,14 +341,6 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
List
<
PlatOrg
>
list
=
list
(
dto
);
List
<
PlatOrg
>
tree
=
tree
(
list
);
// list = new ArrayList<>(10);
// flat(tree,list);
//System.out.println(tntUserService.listCount(new TntUserQueryDTO()));
List
<
PlatUserCountVO
>
countVOList
=
platUserService
.
listCount
(
new
PlatUserQueryDTO
());
Map
<
String
,
Integer
>
countVOMap
=
countVOList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatUserCountVO:
:
getOrgId
,
PlatUserCountVO:
:
getCount
));
Map
<
PlatOrg
,
List
<
PlatOrg
>>
deptMap
=
new
HashMap
<>(
16
);
List
<
PlatOrg
>
deptList
=
new
ArrayList
<>(
tree
);
...
...
@@ -399,23 +368,19 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
return
tree
;
}
private
void
check
(
PlatOrg
dto
)
{
}
@Transactional
@Override
public
String
add
(
PlatOrg
dto
)
{
check
(
dto
);
dto
.
setTenantId
(
TenantIdUtil
.
getTenantId
());
if
(
StringUtils
.
isBlank
(
dto
.
getParentId
()))
{
if
(
StringUtils
.
isBlank
(
dto
.
getParentId
()))
{
String
tenantId
=
TenantIdUtil
.
getTenantId
();
dto
.
setParentId
(
tenantId
);
dto
.
setPath
(
tenantId
);
}
else
{
}
else
{
PlatOrg
parent
=
getById
(
dto
.
getParentId
());
dto
.
setPath
(
parent
.
getPath
()
+
","
+
parent
.
getId
());
dto
.
setPath
(
parent
.
getPath
()
+
","
+
parent
.
getId
());
}
save
(
dto
);
return
dto
.
getId
();
...
...
@@ -424,15 +389,14 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Transactional
@Override
public
void
edit
(
PlatOrg
dto
)
{
check
(
dto
);
if
(
StringUtils
.
isBlank
(
dto
.
getParentId
()))
{
if
(
StringUtils
.
isBlank
(
dto
.
getParentId
()))
{
String
tenantId
=
TenantIdUtil
.
getTenantId
();
dto
.
setParentId
(
tenantId
);
dto
.
setPath
(
tenantId
);
}
else
{
}
else
{
PlatOrg
parent
=
getById
(
dto
.
getParentId
());
dto
.
setPath
(
parent
.
getPath
()
+
","
+
parent
.
getId
());
dto
.
setPath
(
parent
.
getPath
()
+
","
+
parent
.
getId
());
}
updateById
(
dto
);
...
...
@@ -472,13 +436,12 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Override
public
List
<
PlatOrg
>
listWithoutDept
()
{
List
<
PlatOrg
>
deptList
=
list
(
new
QueryWrapper
<
PlatOrg
>().
lambda
()
.
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
.
orderByAsc
(
PlatOrg:
:
getSort
)
.
orderByAsc
(
PlatOrg:
:
getCreateDate
)
);
return
deptList
;
return
list
(
new
QueryWrapper
<
PlatOrg
>().
lambda
()
.
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
.
orderByAsc
(
PlatOrg:
:
getSort
)
.
orderByAsc
(
PlatOrg:
:
getCreateDate
)
);
}
...
...
@@ -490,11 +453,10 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
@Override
public
List
<
PlatOrg
>
getDeptSelfAndChildren
(
String
deptId
)
{
//给筛选列表用 包含自己
List
<
PlatOrg
>
newList
=
platUserService
.
getDeptList
();
List
<
PlatOrg
>
newList
=
platUserService
.
getDeptList
();
if
(
StringUtils
.
isBlank
(
deptId
))
{
return
newList
;
}
else
{
List
<
PlatOrg
>
treeList
=
this
.
tree
(
newList
);
List
<
PlatOrg
>
deptList
=
StreamUtil
.
filter
(
newList
,
e
->
e
.
getId
().
equals
(
deptId
));
if
(!
deptList
.
isEmpty
())
{
this
.
flat
(
deptList
.
get
(
0
).
getChildren
(),
deptList
);
...
...
@@ -507,6 +469,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
/**
* 获取权限范围树
* 当前账号所属角色的权限级别,可查看某一级或者某一级及其下级
*
* @return
*/
@Override
...
...
@@ -514,15 +477,15 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
PlatUserVO
userVO
=
PlatUserUtil
.
getUserVO
();
String
isTenant
=
userVO
.
getIsTenant
();
//如果是租户账号 则有所有权限
if
(
StringUtils
.
equals
(
isTenant
,
CommonEnum
.
YES
.
getValue
()))
{
List
<
PlatOrg
>
orgList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatOrg
>().
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
()));
if
(
StringUtils
.
equals
(
isTenant
,
CommonEnum
.
YES
.
getValue
()))
{
List
<
PlatOrg
>
orgList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatOrg
>().
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
()));
return
getOrgTree
(
orgList
);
}
//平台账号
Set
<
String
>
orgIdList
=
getOrgIdListByUserId
(
userVO
.
getId
());
List
<
PlatOrg
>
orgList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatOrg
>().
in
(
BaseEntity:
:
getId
,
orgIdList
).
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
()));
if
(
CollectionUtils
.
isEmpty
(
orgList
))
{
List
<
PlatOrg
>
orgList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatOrg
>().
in
(
BaseEntity:
:
getId
,
orgIdList
).
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
()));
if
(
CollectionUtils
.
isEmpty
(
orgList
))
{
return
new
ArrayList
<>();
}
Set
<
String
>
allOrgIdSet
=
orgList
.
stream
().
flatMap
(
vo
->
{
...
...
@@ -530,7 +493,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
String
[]
split
=
StringUtils
.
split
(
path
,
","
);
return
Stream
.
of
(
split
);
}).
collect
(
Collectors
.
toSet
());
List
<
PlatOrg
>
allOrgList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatOrg
>().
in
(
BaseEntity:
:
getId
,
allOrgIdSet
).
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
()));
List
<
PlatOrg
>
allOrgList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatOrg
>().
in
(
BaseEntity:
:
getId
,
allOrgIdSet
).
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
()));
orgList
.
addAll
(
allOrgList
);
return
getOrgTree
(
orgList
);
}
...
...
@@ -543,25 +506,30 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
*/
@Override
public
Set
<
String
>
getOrgIdListByUserId
(
String
userId
)
{
List
<
PlatUserRole
>
userRoleList
=
platUserRoleService
.
getByUserId
(
userId
);
if
(
CollectionUtils
.
isEmpty
(
userRoleList
))
{
List
<
PlatUserRole
>
userRoleList
=
platUserRoleService
.
getByUserId
(
userId
);
if
(
CollectionUtils
.
isEmpty
(
userRoleList
))
{
return
new
HashSet
<>();
}
List
<
PlatRoleOrg
>
roleOrgList
=
platRoleOrgService
.
getByRoleIds
(
userRoleList
.
stream
().
map
(
PlatUserRole:
:
getRoleId
).
collect
(
Collectors
.
toSet
()));
if
(
CollectionUtils
.
isEmpty
(
roleOrgList
))
{
if
(
CollectionUtils
.
isEmpty
(
roleOrgList
))
{
return
new
HashSet
<>();
}
List
<
PlatRole
>
roleList
=
platRoleService
.
listByIds
(
roleOrgList
.
stream
().
map
(
PlatRoleOrg:
:
getRoleId
).
collect
(
Collectors
.
toList
()));
return
roleList
.
stream
().
flatMap
(
vo
->
Stream
.
of
(
vo
.
getDataScope
().
split
(
","
))).
collect
(
Collectors
.
toSet
());
return
roleList
.
stream
().
flatMap
(
vo
->
Stream
.
of
(
vo
.
getDataScope
().
split
(
","
))).
collect
(
Collectors
.
toSet
());
}
/**
* 从租户开始的组织树
* @param orgList
* @return
*/
private
List
<
PlatOrg
>
getOrgTree
(
List
<
PlatOrg
>
orgList
)
{
Map
<
String
,
List
<
PlatOrg
>>
parentIdMap
=
orgList
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatOrg:
:
getParentId
));
orgList
.
forEach
(
vo
->
{
orgList
.
forEach
(
vo
->
{
List
<
PlatOrg
>
childList
=
parentIdMap
.
get
(
vo
.
getId
());
vo
.
setChildren
(
childList
);
});
return
orgList
.
stream
().
filter
(
vo
->
StringUtils
.
equals
(
vo
.
getTenantId
(),
vo
.
get
Parent
Id
())).
collect
(
Collectors
.
toList
());
return
orgList
.
stream
().
filter
(
vo
->
StringUtils
.
equals
(
vo
.
getTenantId
(),
vo
.
getId
())).
collect
(
Collectors
.
toList
());
}
/**
...
...
@@ -585,10 +553,10 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
Page
<
PlatOrg
>
p
=
PageUtil
.
toMpPage
(
pageReqDTO
);
LambdaQueryWrapper
<
PlatOrg
>
queryWrapper
=
getLambdaQueryWrapper
(
dto
);
queryWrapper
.
eq
(
BaseEntity:
:
getId
,
tenantId
);
queryWrapper
.
eq
(
BaseEntity:
:
getId
,
tenantId
);
Page
<
PlatOrg
>
pageList
=
page
(
p
,
queryWrapper
);
List
<
PlatOrg
>
records
=
pageList
.
getRecords
();
records
.
forEach
(
vo
->
{
records
.
forEach
(
vo
->
{
dto
.
setParentId
(
tenantId
);
List
<
PlatOrg
>
subOrgList
=
subOrgList
(
dto
);
vo
.
setChildren
(
subOrgList
);
...
...
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatRoleServiceImpl.java
View file @
9e7b849f
...
...
@@ -68,9 +68,6 @@ implements PlatRoleService {
@Autowired
private
PlatMenuService
platMenuService
;
// @Autowired
// private PlatRoleWechatMenuService tntRoleWechatMenuService;
@Autowired
private
PlatRoleOrgService
platRoleOrgService
;
...
...
@@ -90,9 +87,7 @@ implements PlatRoleService {
List
<
PlatRole
>
tntRoleList
=
list
(
listWrapper
(
dto
));
List
<
PlatRoleDTOVO
>
rolVOList
=
BeanDtoVoUtils
.
listVo
(
tntRoleList
,
PlatRoleDTOVO
.
class
);
JoinUtil
.
join
(
rolVOList
,
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
{
r
.
setDeptName
(
e
.
getName
());
});
JoinUtil
.
join
(
rolVOList
,
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
r
.
setDeptName
(
e
.
getName
()));
return
BeanDtoVoUtils
.
listVo
(
tntRoleList
,
PlatRoleDTOVO
.
class
);
}
...
...
@@ -107,9 +102,7 @@ implements PlatRoleService {
List
<
PlatRoleDTOVO
>
tntUserVOList
=
BeanDtoVoUtils
.
listVo
(
pageList
.
getRecords
(),
PlatRoleDTOVO
.
class
);
JoinUtil
.
join
(
tntUserVOList
,
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
{
r
.
setDeptName
(
e
.
getName
());
});
JoinUtil
.
join
(
tntUserVOList
,
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
r
.
setDeptName
(
e
.
getName
()));
return
PageUtil
.
toPageVO
(
tntUserVOList
,
pageList
);
...
...
@@ -184,9 +177,7 @@ implements PlatRoleService {
PlatRoleDTOVO
vo
=
BeanDtoVoUtils
.
convert
(
getById
(
id
),
PlatRoleDTOVO
.
class
);
JoinUtil
.
join
(
Arrays
.
asList
(
vo
),
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
{
r
.
setDeptName
(
e
.
getName
());
});
JoinUtil
.
join
(
Arrays
.
asList
(
vo
),
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
r
.
setDeptName
(
e
.
getName
()));
return
vo
;
}
...
...
@@ -238,152 +229,9 @@ implements PlatRoleService {
});
}
// @Override
// public void exportTemplate(HttpServletResponse response) {
// ExcelUtil.exportTemplate(response, "用户角色关联.xls", "用户角色关联\n以英文逗号分割多个角色名称", PlatUserRoleImportDTO.class);
// }
// @Override
// public ExcelImportVo importExcel(String deptId, String hotelId, MultipartFile excelFile) throws Exception{
// return ExcelUtil.importExcel(deptId, excelFile, PlatUserRoleImportDTO.class, c -> {
//
// List<PlatUserRoleImportDTO> l = c.getList();
//
// List<ExcelErrorVo> excelErrorVoList = new ArrayList<>(10);
//
// List<String> accountList = new ArrayList<>(10);
//
// List<String> roleNameList = new ArrayList<>(10);
//
// Map<String, Set<Integer>> userAccountIndexMap = new HashMap<>(16);
// for (int i = 0; i < l.size(); i++) {
// PlatUserRoleImportDTO userRoleImportDTO = l.get(i);
//
// userAccountIndexMap.computeIfAbsent(userRoleImportDTO.getUserAccount(), k -> new HashSet<>(10)).add(i + 1);
//
// accountList.add(userRoleImportDTO.getUserAccount());
//
// roleNameList.addAll(Arrays.asList(userRoleImportDTO.getRoleName().split(",")));
// }
//
// accountList.add(-1 + "");
//
// PlatUserQueryDTO userQueryDTO = new PlatUserQueryDTO();
// userQueryDTO.setOrgId(deptId);
// userQueryDTO.setAccountList(accountList);
// List<PlatPersonDTOVO> userList = tntUserService.list(userQueryDTO);
// Map<String, PlatPersonDTOVO> userMap = StreamUtil.toMap(userList, PlatPersonDTOVO::getAccount);
//
// roleNameList = StreamUtil.filter(roleNameList, StringUtils::isNotBlank);
// roleNameList.add(-1 + "");
//
// PlatRoleDTOVO tntRoleDTOVO = new PlatRoleDTOVO();
// tntRoleDTOVO.setOrgId(deptId);
// tntRoleDTOVO.setNameList(roleNameList);
// List<PlatRoleDTOVO> roleList = list(tntRoleDTOVO);
//
// Map<String, PlatRoleDTOVO> roleMap = StreamUtil.toMap(roleList, PlatRoleDTOVO::getName);
//
// int start = 3;
//
// int successCount = 0;
//
// for (int i = 0; i < l.size(); i++) {
// PlatUserRoleImportDTO userRoleImportDTO = l.get(i);
//
// boolean isImport = true;
//
// if (StringUtils.isBlank(userRoleImportDTO.getUserAccount())) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "用户工号", "用户工号为空"));
// isImport = false;
// } else {
//
// Set<Integer> set = userAccountIndexMap.get(userRoleImportDTO.getUserAccount());
// if (set.size() != 1) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "用户工号", "导入的数据存在重复的用户工号"));
// isImport = false;
// }
//
// PlatPersonDTOVO p = userMap.get(userRoleImportDTO.getUserAccount());
// if (p == null) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "用户工号", "数据库不存在该工号的用户"));
// isImport = false;
// }
// }
//
// if (StringUtils.isBlank(userRoleImportDTO.getRoleName())) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "角色名称", "角色名称为空"));
// isImport = false;
// } else {
// List<String> rList = StreamUtil.filter(Arrays.asList(userRoleImportDTO.getRoleName().split(",")), StringUtils::isNotBlank);
// Set<String> rSet = new HashSet<>(rList);
// if (rSet.size() < rList.size()) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "角色名称", "角色名称存在重复值"));
// isImport = false;
// }
//
// for (String e : rSet) {
// PlatRoleDTOVO r = roleMap.get(e);
// if (r == null) {
// excelErrorVoList.add(new ExcelErrorVo(i + start, "角色名称", e + "数据库不存在"));
// isImport = false;
// }
// }
// }
//
// if (isImport) {
// successCount++;
// }
//
// }
//
// if (excelErrorVoList.size() == 0) {
// List<PlatUserRole> userRoleList = new ArrayList<>(10);
//
// List<String> userIdList = new ArrayList<>(10);
// l.forEach(e -> {
// PlatPersonDTOVO p = userMap.get(e.getUserAccount());
//
// userIdList.add(p.getId());
//
// List<String> rList = StreamUtil.filter(Arrays.asList(e.getRoleName().split(",")), StringUtils::isNotBlank);
// List<PlatRoleDTOVO> r = StreamUtil.map(rList, roleMap::get);
// userRoleList.addAll(StreamUtil.map(r, rr -> {
// PlatUserRole tntUserRole = new PlatUserRole();
// tntUserRole.setUserId(p.getId());
// tntUserRole.setRoleId(rr.getId());
//
// return tntUserRole;
// }));
// });
//
// tntUserRoleService.remove(new QueryWrapper<PlatUserRole>().lambda()
// .in(PlatUserRole::getUserId, userIdList));
//
// tntUserRoleService.saveBatch(userRoleList);
// }
//
// //return excelErrorVoList;
//
// ExcelImportVo excelImportVo = new ExcelImportVo();
// excelImportVo.setTotalCount(l.size());
// excelImportVo.setErrorCount(excelErrorVoList.size());
// //excelImportVo.setSuccessCount(list.size() - excelErrorVoList.size());
// excelImportVo.setSuccessCount(successCount);
// excelImportVo.setList(excelErrorVoList);
//
// return excelImportVo;
//
//
// }, c -> {
//
// });
// }
@Transactional
@Override
public
void
assignMenuList
(
PlatRoleMenuDTO
roleMenuDTO
)
{
//removeAssignMenuList(roleMenuDTOList);
adminRoleCantDo
(
roleMenuDTO
.
getRoleId
());
...
...
@@ -427,41 +275,9 @@ implements PlatRoleService {
return
newList
;
}
// @Transactional
// @Override
// public void assignWechatMenuList(PlatRoleMenuDTO roleMenuDTO) {
// //removeAssignWechatMenuList(roleMenuDTOList);
//
// adminRoleCantDo(roleMenuDTO.getRoleId());
//
// tntRoleWechatMenuService.remove(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleMenuDTO.getRoleId()));
//
// List<PlatRoleWechatMenu> roleMenuList = StreamUtil.map(roleMenuDTO.getMenuIdList(), e -> {
// PlatRoleWechatMenu tntRoleMenu = new PlatRoleWechatMenu();
// tntRoleMenu.setRoleId(roleMenuDTO.getRoleId());
// tntRoleMenu.setMenuId(e);
// tntRoleMenu.setTenantId(roleMenuDTO.getTenantId());
//
// return tntRoleMenu;
// });
//
// tntRoleWechatMenuService.saveBatch(roleMenuList);
// }
// @Override
// public List<PlatRoleWechatMenu> getWechatMenuListByRoleId(String roleId) {
// List<PlatRoleWechatMenu> roleWechatMenuList = tntRoleWechatMenuService.list(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleId));
// return roleWechatMenuList;
// }
@Transactional
@Override
public
void
assignDeptList
(
PlatRoleDeptDTOVO
tntRoleDeptDTO
)
{
//removeAssignDeptList(roleDeptDTOList);
adminRoleCantDo
(
tntRoleDeptDTO
.
getRoleId
());
...
...
@@ -482,9 +298,8 @@ implements PlatRoleService {
@Override
public
List
<
PlatRoleOrg
>
getDeptListByRoleId
(
String
roleId
)
{
List
<
PlatRoleOrg
>
roleDeptList
=
platRoleOrgService
.
list
(
new
QueryWrapper
<
PlatRoleOrg
>().
lambda
()
return
platRoleOrgService
.
list
(
new
QueryWrapper
<
PlatRoleOrg
>().
lambda
()
.
eq
(
PlatRoleOrg:
:
getRoleId
,
roleId
));
return
roleDeptList
;
}
public
static
String
getNewName
(
String
name
)
{
...
...
@@ -497,7 +312,6 @@ implements PlatRoleService {
PlatRole
newRole
=
BeanDtoVoUtils
.
convert
(
tntRole
,
PlatRole
.
class
);
newRole
.
setName
(
getNewName
(
tntRole
.
getName
()));
newRole
.
setId
(
null
);
// newRole.setIsAdmin(CommonEnum.NO.getValue());
save
(
newRole
);
...
...
@@ -519,15 +333,6 @@ implements PlatRoleService {
});
platRoleMenuService
.
saveBatch
(
roleMenuListNew
);
// List<PlatRoleWechatMenu> wechatMenuList = tntRoleWechatMenuService.list(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .eq(PlatRoleWechatMenu::getRoleId, roleId));
// wechatMenuList.forEach(e -> {
// e.setId(null);
// e.setRoleId(newRole.getId());
// });
// tntRoleWechatMenuService.saveBatch(wechatMenuList);
List
<
PlatRoleOrg
>
roleDeptList
=
platRoleOrgService
.
list
(
new
QueryWrapper
<
PlatRoleOrg
>().
lambda
()
.
eq
(
PlatRoleOrg:
:
getRoleId
,
roleId
));
roleDeptList
.
forEach
(
e
->
{
...
...
@@ -545,9 +350,7 @@ implements PlatRoleService {
queryWrapper
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getOrgId
()),
PlatRole:
:
getOrgId
,
dto
.
getOrgId
());
List
<
PlatRole
>
platRoleList
=
list
(
queryWrapper
);
List
<
PlatRoleDTOVO
>
rolVOList
=
BeanDtoVoUtils
.
listVo
(
platRoleList
,
PlatRoleDTOVO
.
class
);
JoinUtil
.
join
(
rolVOList
,
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
{
r
.
setDeptName
(
e
.
getName
());
});
JoinUtil
.
join
(
rolVOList
,
platOrgService
,
PlatRoleDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
r
,
e
)
->
r
.
setDeptName
(
e
.
getName
()));
return
BeanDtoVoUtils
.
listVo
(
platRoleList
,
PlatRoleDTOVO
.
class
);
}
...
...
@@ -563,9 +366,8 @@ implements PlatRoleService {
public
List
<
PlatRole
>
belongTo
(
BaseIdDTO
baseIdDTO
)
{
PlatUserVO
userVO
=
PlatUserUtil
.
getUserVO
();
if
(
StringUtils
.
equals
(
userVO
.
getIsTenant
(),
CommonEnum
.
YES
.
getValue
())){
List
<
PlatRole
>
roleList
=
this
.
list
(
new
LambdaQueryWrapper
<
PlatRole
>().
orderByDesc
(
BaseEntity:
:
getUpdateDate
));
return
roleList
;
return
this
.
list
(
new
LambdaQueryWrapper
<
PlatRole
>().
orderByDesc
(
BaseEntity:
:
getUpdateDate
));
}
return
n
ull
;
return
n
ew
ArrayList
<>()
;
}
}
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
View file @
9e7b849f
...
...
@@ -29,7 +29,6 @@ import com.makeit.enums.CodeMessageEnum;
import
com.makeit.enums.CommonEnum
;
import
com.makeit.enums.IsTenantAccountEnum
;
import
com.makeit.enums.biz.auth.SysEnum
;
import
com.makeit.enums.biz.sys.SysDictCategoryConst
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.global.aspect.tenant.TenantIdUtil
;
import
com.makeit.mapper.platform.auth.PlatUserMapper
;
...
...
@@ -125,10 +124,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PlatUserServiceImpl
.
class
);
// @Lazy
// @Autowired
// private TntAsyncMessageService tntAsyncMessageService;
private
LambdaQueryWrapper
<
PlatUser
>
listTenantLambdaQueryWrapper
(
PlatUserQueryDTO
dto
,
Consumer
<
LambdaQueryWrapper
<
PlatUser
>>
consumer
)
{
LambdaQueryWrapper
<
PlatUser
>
lambdaQueryWrapper
=
new
QueryWrapper
<
PlatUser
>().
lambda
()
...
...
@@ -169,9 +164,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
Page
<
PlatUser
>
p
=
PageUtil
.
toMpPage
(
page
);
Page
<
PlatUser
>
pageList
=
page
(
p
,
listTenantLambdaQueryWrapper
(
dto
,
qw
->
{
qw
.
eq
(
PlatUser:
:
getIsTenant
,
IsTenantAccountEnum
.
YES
.
getValue
());
}));
Page
<
PlatUser
>
pageList
=
page
(
p
,
listTenantLambdaQueryWrapper
(
dto
,
qw
->
qw
.
eq
(
PlatUser:
:
getIsTenant
,
IsTenantAccountEnum
.
YES
.
getValue
())));
List
<
PlatUserDTOVO
>
tntUserDTOVOList
=
BeanDtoVoUtils
.
listVo
(
pageList
.
getRecords
(),
PlatUserDTOVO
.
class
);
fillTenant
(
tntUserDTOVOList
);
...
...
@@ -182,9 +175,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Override
public
List
<
PlatUserDTOVO
>
listTenant
(
PlatUserQueryDTO
dto
)
{
return
BeanDtoVoUtils
.
listVo
(
list
(
listTenantLambdaQueryWrapper
(
dto
,
qw
->
{
qw
.
eq
(
PlatUser:
:
getIsTenant
,
IsTenantAccountEnum
.
YES
.
getValue
());
})),
list
(
listTenantLambdaQueryWrapper
(
dto
,
qw
->
qw
.
eq
(
PlatUser:
:
getIsTenant
,
IsTenantAccountEnum
.
YES
.
getValue
()))),
PlatUserDTOVO
.
class
);
}
...
...
@@ -192,11 +183,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
PlatUser
>
userList
=
list
(
new
QueryWrapper
<
PlatUser
>().
lambda
()
//.eq(TntUser::getIsTenant, IsTenantAccountEnum.YES.getValue())
.
and
(
qw
->
{
qw
.
eq
(
PlatUser:
:
getAccount
,
dto
.
getAccount
())
.
or
()
.
eq
(
PlatUser:
:
getMobile
,
dto
.
getMobile
());
})
.
and
(
qw
->
qw
.
eq
(
PlatUser:
:
getAccount
,
dto
.
getAccount
())
.
or
()
.
eq
(
PlatUser:
:
getMobile
,
dto
.
getMobile
()))
);
...
...
@@ -215,11 +204,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
PlatUser
>
userList
=
list
(
new
QueryWrapper
<
PlatUser
>().
lambda
()
.
eq
(
PlatUser:
:
getIsTenant
,
IsTenantAccountEnum
.
NO
.
getValue
())
.
and
(
qw
->
{
qw
.
eq
(
PlatUser:
:
getAccount
,
dto
.
getAccount
())
.
or
()
.
eq
(
PlatUser:
:
getMobile
,
dto
.
getMobile
());
})
.
and
(
qw
->
qw
.
eq
(
PlatUser:
:
getAccount
,
dto
.
getAccount
())
.
or
()
.
eq
(
PlatUser:
:
getMobile
,
dto
.
getMobile
()))
);
...
...
@@ -284,8 +271,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Override
public
PlatUserDTOVO
view
(
String
id
)
{
PlatUserDTOVO
userVO
=
BeanDtoVoUtils
.
convert
(
getById
(
id
),
PlatUserDTOVO
.
class
);
return
userVO
;
return
BeanDtoVoUtils
.
convert
(
getById
(
id
),
PlatUserDTOVO
.
class
);
}
@Transactional
...
...
@@ -338,14 +324,13 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Override
public
List
<
PlatTenant
>
setTenantList
(
PlatUser
tntUser
)
{
if
(
IsTenantAccountEnum
.
YES
.
getValue
().
equals
(
tntUser
.
getIsTenant
()))
{
List
<
PlatTenant
>
tntTenantList
=
platTenantService
.
list
(
new
QueryWrapper
<
PlatTenant
>().
lambda
()
return
platTenantService
.
list
(
new
QueryWrapper
<
PlatTenant
>().
lambda
()
.
eq
(
PlatTenant:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
.
eq
(
PlatTenant:
:
getPlatUserId
,
tntUser
.
getId
())
.
orderByAsc
(
PlatTenant:
:
getCreateDate
)
);
return
tntTenantList
;
}
return
n
ull
;
return
n
ew
ArrayList
<>()
;
}
@Override
...
...
@@ -417,10 +402,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
private
void
fillMenuList
(
List
<
PlatMenu
>
menuList
,
PlatUserLoginVO
userLoginVO
)
{
// List<TntMenu> buttonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.BUTTON.getValue().equals(e.getCategory()));
//
// List<TntMenu> nonButtonList = StreamUtil.filter(menuList, e -> SysEnum.MenuTypeEnum.CATALOGUE.getValue().equals(e.getCategory()) || SysEnum.MenuTypeEnum.MENU.getValue().equals(e.getCategory()));
List
<
PlatMenu
>
buttonList
=
new
ArrayList
<>(
10
);
List
<
PlatMenu
>
nonButtonList
=
new
ArrayList
<>(
10
);
...
...
@@ -459,14 +440,12 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
String
>
menuIdList
=
StreamUtil
.
map
(
tntTenantMenuList
,
PlatTenantMenu:
:
getMenuId
);
menuIdList
.
add
(-
1
+
""
);
List
<
PlatMenu
>
menuList
=
platMenuService
.
list
(
new
QueryWrapper
<
PlatMenu
>().
lambda
()
return
platMenuService
.
list
(
new
QueryWrapper
<
PlatMenu
>().
lambda
()
.
in
(
PlatMenu:
:
getId
,
menuIdList
)
.
eq
(
PlatMenu:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
.
orderByAsc
(
PlatMenu:
:
getSort
)
.
orderByAsc
(
PlatMenu:
:
getCreateDate
)
);
return
menuList
;
}
private
void
supperRoleMenuList
(
PlatUserLoginVO
userLoginVO
)
{
...
...
@@ -504,11 +483,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return
tntPersonDTOVO
;
}
// @Override
// public List<String> getCustomGroupNameList() {
// return getCustomGroupNameList(PlatUserUtil.getUserId());
// }
@Override
public
List
<
PlatRole
>
getRoleList
(
String
userId
)
{
List
<
PlatUserRole
>
userRoleList
=
platUserRoleService
.
list
(
new
QueryWrapper
<
PlatUserRole
>().
lambda
()
...
...
@@ -516,11 +490,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
String
>
roleIdList
=
StreamUtil
.
map
(
userRoleList
,
PlatUserRole:
:
getRoleId
);
roleIdList
.
add
(-
1
+
""
);
List
<
PlatRole
>
roleList
=
platRoleService
.
list
(
new
QueryWrapper
<
PlatRole
>().
lambda
()
return
platRoleService
.
list
(
new
QueryWrapper
<
PlatRole
>().
lambda
()
.
in
(
PlatRole:
:
getId
,
roleIdList
)
);
return
roleList
;
}
private
List
<
PlatMenu
>
getMenuListByUserId
(
PlatUserLoginVO
userLoginVO
)
{
...
...
@@ -542,9 +514,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.
orderByAsc
(
PlatMenu:
:
getCreateDate
)
);
// List<TntMenu> menuList = getMenuListByUserId(userLoginVO.getId());
// menuList = new ArrayList<>(new HashSet<>(menuList));
userLoginVO
.
setRoleList
(
BeanDtoVoUtils
.
listVo
(
roleList
,
PlatRoleDTOVO
.
class
));
if
(
StringUtils
.
isNotBlank
(
userLoginVO
.
getTenantId
()))
{
...
...
@@ -559,8 +528,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
public
PlatUserLoginVO
getRoleAndMenuList
()
{
//TODO 用join做
//TODO 只返回必要字段 菜单和角色
long
s
=
System
.
currentTimeMillis
();
String
tenantId
=
TenantIdUtil
.
getTenantId
();
if
(
StringUtils
.
isBlank
(
tenantId
))
{
throw
new
BusinessException
(
CodeMessageEnum
.
SYSTEM_ERROR_TENANT_ID_NOT_BLANK
);
...
...
@@ -572,8 +539,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
PlatUserLoginVO
userLoginVO
=
BeanDtoVoUtils
.
convert
(
tntUserVO
,
PlatUserLoginVO
.
class
);
//tntLoginLogService.addTenant(null, null);
if
(
IsTenantAccountEnum
.
YES
.
getValue
().
equals
(
tntUserVO
.
getIsTenant
()))
{
userLoginVO
.
setTenantId
(
tenantId
);
...
...
@@ -616,38 +581,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return
userLoginVO
;
}
private
void
supperWechatMenuList
(
PlatUserLoginVO
userLoginVO
)
{
userLoginVO
.
setWechatMenuCodeList
(
sysDictionaryCategoryService
.
getCodeListByPrefix
(
SysDictCategoryConst
.
WECHAT_MENU_PREFIX
));
}
// @Override
// public PlatUserLoginVO getWechatMenuList() {
// //TODO 用join做
// //TODO 只返回必要字段 菜单和角色
//
// PlatUserVO tntUserVO = PlatUserUtil.getUserVO();
//
// PlatUserLoginVO userLoginVO = BeanDtoVoUtils.convert(tntUserVO, PlatUserLoginVO.class);
//
// if (IsTenantAccountEnum.YES.getValue().equals(userLoginVO.getIsTenant())) {
//
// supperWechatMenuList(userLoginVO);
// return userLoginVO;
// }
//
// List<PlatRole> roleList = getRoleList(userLoginVO.getId());
// List<String> roleIdList = StreamUtil.map(roleList, PlatRole::getId);
// roleIdList.add(-1 + "");
//
// List<PlatRoleWechatMenu> roleWechatMenuList = tntRoleWechatMenuService.list(new QueryWrapper<PlatRoleWechatMenu>().lambda()
// .in(PlatRoleWechatMenu::getRoleId, roleIdList));
//
// userLoginVO.setWechatMenuCodeList(StreamUtil.map(roleWechatMenuList, PlatRoleWechatMenu::getMenuId));
//
//
// return userLoginVO;
// }
@Override
public
void
logout
()
{
...
...
@@ -711,9 +644,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
private
void
fillDept
(
List
<
PlatPersonDTOVO
>
tntUserDTOVOList
)
{
JoinUtil
.
join
(
tntUserDTOVOList
,
platOrgService
,
PlatPersonDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
p
,
d
)
->
{
p
.
setOrgName
(
d
.
getName
());
});
JoinUtil
.
join
(
tntUserDTOVOList
,
platOrgService
,
PlatPersonDTOVO:
:
getOrgId
,
PlatOrg:
:
getId
,
(
p
,
d
)
->
p
.
setOrgName
(
d
.
getName
()));
}
...
...
@@ -754,10 +685,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.
groupBy
(
PlatUser
.
Fields
.
orgId
)
);
List
<
PlatUserCountVO
>
voList
=
JsonUtil
.
mapToBean
(
tntUserList
,
new
TypeReference
<
List
<
PlatUserCountVO
>>()
{
return
JsonUtil
.
mapToBean
(
tntUserList
,
new
TypeReference
<
List
<
PlatUserCountVO
>>()
{
});
return
voList
;
}
@Override
...
...
@@ -783,25 +712,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return
PageUtil
.
toPageVO
(
tntUserDTOVOList
,
pageList
);
}
// private void frequentUser(LambdaQueryWrapper<PlatUser> lambdaQueryWrapper, PlatUserQueryDTO dto) {
// if (CommonEnum.YES.getValue().equals(dto.getIsFrequent())) {
//
// List<String> frequentUserIdList = new ArrayList<>(10);
// frequentUserIdList.add(-1 + "");
//
//// frequentUserIdList.addAll(
//// StreamUtil.map(
//// tntFrequentUserService.list(new QueryWrapper<PlatFrequentUser>().lambda()
//// .eq(PlatFrequentUser::getPlatUserId, PlatUserUtil.getUserId())
//// ),
//// PlatFrequentUser::getFrequentUserId)
//// );
//
// lambdaQueryWrapper.in(CommonEnum.YES.getValue().equals(dto.getIsFrequent()), PlatUser::getId, frequentUserIdList);
//
// }
// }
private
void
roleIdList
(
LambdaQueryWrapper
<
PlatUser
>
lambdaQueryWrapper
,
PlatUserQueryDTO
dto
)
{
if
(
CollectionUtils
.
isNotEmpty
(
dto
.
getRoleIdList
()))
{
dto
.
getRoleIdList
().
add
(-
1
+
""
);
...
...
@@ -824,11 +734,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.
like
(
StringUtils
.
isNotBlank
(
dto
.
getUsername
()),
PlatUser:
:
getUsername
,
dto
.
getUsername
())
.
like
(
StringUtils
.
isNotBlank
(
dto
.
getMobile
()),
PlatUser:
:
getMobile
,
dto
.
getMobile
())
.
eq
(
StringUtils
.
isNotBlank
(
dto
.
getStatus
()),
PlatUser:
:
getStatus
,
dto
.
getStatus
())
//.eq(dto.getPostLevel() != null, PlatUser::getPostLevel, dto.getPostLevel())
.
eq
(
PlatUser:
:
getTenantId
,
TenantIdUtil
.
getTenantId
());
//frequentUser(lambdaQueryWrapper, dto);
roleIdList
(
lambdaQueryWrapper
,
dto
);
lambdaQueryWrapper
.
orderByDesc
(
PlatUser:
:
getCreateDate
);
...
...
@@ -871,7 +778,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
user
.
setStatus
(
CommonEnum
.
YES
.
getValue
());
//user.setEmpStatus(CommonEnum.YES.getValue());
user
.
setAccount
(
dto
.
getMobile
());
save
(
user
);
dto
.
setId
(
user
.
getId
());
...
...
@@ -884,25 +790,11 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Transactional
@Override
public
void
editPerson
(
PlatPersonDTOVO
dto
)
{
//dto.setAccount(null);
checkPerson
(
BeanDtoVoUtils
.
convert
(
dto
,
PlatUserDTOVO
.
class
));
PlatUser
tntUser
=
getById
(
dto
.
getId
());
// if (StringUtils.isNotBlank(tntUser.getOrgId()) && StringUtils.isNotBlank(dto.getDeptId()) && !tntUser.getOrgId().equals(dto.getDeptId())) {
// changeDeptMessage(tntUser, tntUser.getOrgId(), dto.getDeptId());
// }
// if (CommonEnum.YES.getValue().equals(tntUser.getEmpStatus()) && CommonEnum.NO.getValue().equals(dto.getEmpStatus())) {
// leaveMessage(tntUser);
// }
PlatUser
user
=
BeanDtoVoUtils
.
convert
(
dto
,
PlatUser
.
class
);
user
.
setIsTenant
(
CommonEnum
.
NO
.
getValue
());
// if (!CommonEnum.YES.getValue().equals(user.getEmpStatus())) {
// user.setStatus(CommonEnum.NO.getValue());
// }
setPassword
(
user
);
updateById
(
user
);
...
...
@@ -940,58 +832,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return
userVO
;
}
// @Override
// public void changeDeptMessage(PlatUser tntUser, String oldDeptId, String newDeptId) {
// PlatOrg oldDept = platOrgService.getById(oldDeptId);
// PlatOrg newDept = platOrgService.getById(newDeptId);
//
// List<PlatCustomGroup> groupList = CustomGroupUtil.getGroupByUserId(tntUser.getId());
//
// PlatDept hotel = DeptUtil.getHotel(tntUser.getDeptId());
//
// List<ChangeDeptMessageDTO> dtoList = StreamUtil.map(groupList, e -> {
// ChangeDeptMessageDTO changeDeptMessageDTO = new ChangeDeptMessageDTO();
//
// changeDeptMessageDTO.setGroupId(e.getId());
//
// changeDeptMessageDTO.setUserName(tntUser.getName());
// if (oldDept != null) {
// changeDeptMessageDTO.setOldDeptName(oldDept.getName());
// } else {
// changeDeptMessageDTO.setOldDeptName("");
// }
// changeDeptMessageDTO.setNewDeptName(newDept.getName());
// changeDeptMessageDTO.setGroupAdminUserId(e.getTntUserId());
//
// return changeDeptMessageDTO;
// });
//
// tntAsyncMessageService.addChangeDeptMessage(hotel, dtoList);
//
// }
// @Override
// public void leaveMessage(TntUser tntUser) {
//
// List<TntCustomGroup> groupList = CustomGroupUtil.getGroupByUserId(tntUser.getId());
//
// TntDept hotel = DeptUtil.getHotel(tntUser.getDeptId());
//
// List<ChangeDeptMessageDTO> dtoList = StreamUtil.map(groupList, e -> {
// ChangeDeptMessageDTO changeDeptMessageDTO = new ChangeDeptMessageDTO();
//
// changeDeptMessageDTO.setGroupId(e.getId());
//
// changeDeptMessageDTO.setUserName(tntUser.getName());
// changeDeptMessageDTO.setGroupAdminUserId(e.getTntUserId());
//
// return changeDeptMessageDTO;
// });
//
// tntAsyncMessageService.addLeaveMessage(hotel, dtoList);
//
// }
@Override
public
List
<
PlatRole
>
getRoleListWithTag
(
String
userId
)
{
...
...
@@ -1004,14 +844,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.
eq
(
PlatOrg:
:
getStatus
,
CommonEnum
.
YES
.
getValue
())
);
Map
<
String
,
PlatOrg
>
deptMap
=
StreamUtil
.
toMap
(
deptList
,
PlatOrg:
:
getId
);
// roleList.forEach(e -> {
// PlatOrg dept = deptMap.get(e.PlatOrg());
// if (dept != null) {
// e.setTag(dept.getTag());
// }
// });
return
roleList
;
}
...
...
@@ -1036,9 +868,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
if
(
IsTenantAccountEnum
.
YES
.
getValue
().
equals
(
PlatUserUtil
.
getUserVO
().
getIsTenant
()))
{
newList
.
addAll
(
tntDeptList
);
// newList.forEach(e -> {
// e.setCanTap(CommonEnum.YES.getValue());
// });
}
else
{
...
...
@@ -1051,21 +880,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.
in
(
PlatRoleOrg:
:
getRoleId
,
roleIdList
));
newList
=
roleDeptList
.
stream
().
map
(
e
->
map
.
get
(
e
.
getOrgId
())).
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
// newList.forEach(e -> {
// e.setCanTap(CommonEnum.YES.getValue());
// });
// tntRoleList.forEach(e -> {
// TntDept tntDept = map.get(e.getDeptId());
// if (tntDept != null) {
// tntDept.setCanTap(CommonEnum.YES.getValue());
// }
// });
PlatOrg
userDept
=
map
.
get
(
PlatUserUtil
.
getUserVO
().
getOrgId
());
// if (userDept != null) {
// userDept.setCanTap(CommonEnum.YES.getValue());
// }
Set
<
PlatOrg
>
set
=
new
HashSet
<>(
newList
);
...
...
@@ -1130,7 +944,6 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Override
public
List
<
PlatOrg
>
getDeptSelfAndChildrenCanTap
(
String
deptId
)
{
//给筛选列表用 包含自己
// return StreamUtil.filter(platOrgService.getDeptSelfAndChildren(deptId), e -> CommonEnum.YES.getValue().equals(e.getCanTap()));
return
platOrgService
.
getDeptSelfAndChildren
(
deptId
);
}
...
...
@@ -1139,9 +952,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
PlatOrg
>
newList
=
getDeptList
();
if
(
StringUtils
.
isBlank
(
deptId
))
{
return
newList
;
//return newList;
}
else
{
List
<
PlatOrg
>
treeList
=
platOrgService
.
tree
(
newList
);
List
<
PlatOrg
>
matchList
=
StreamUtil
.
filter
(
newList
,
e
->
e
.
getId
().
equals
(
deptId
));
if
(
matchList
.
isEmpty
())
{
...
...
@@ -1150,15 +961,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List
<
PlatOrg
>
deptList
=
new
ArrayList
<>(
10
);
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(matchList.get(0).getTag())) {
// deptList.add(matchList.get(0));
// }
platOrgService
.
flat
(
matchList
.
get
(
0
).
getChildren
(),
matchList
);
deptList
.
forEach
(
e
->
{
e
.
setChildren
(
null
);
});
//return StreamUtil.filter(deptList, e -> DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag()));
deptList
.
forEach
(
e
->
e
.
setChildren
(
null
));
return
matchList
;
}
}
...
...
@@ -1166,29 +970,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
@Override
public
List
<
PlatOrg
>
getCandidateDeptList
()
{
//新增编辑角色 那边的管理范围 //不包含自己
List
<
PlatOrg
>
newList
=
getDeptList
();
// newList.forEach(e -> {
// e.setCanTap(null);
// });
// newList.forEach(e -> {
// if (DeptEnum.DeptTagEnum.HOTEL.getValue().equals(e.getTag())) {
// e.setCanTap(CommonEnum.YES.getValue());
// }
// });
return
platOrgService
.
tree
(
newList
);
}
// @Override
// public List<String> getCustomGroupNameList(String userId) {
// List<TntCustomGroup> customGroupList = CustomGroupUtil.getGroupByUserId(userId);
// return StreamUtil.map(customGroupList, TntCustomGroup::getName);
// }
//
// @Override
// public List<String> getCustomGroupIdList(String userId) {
// List<TntCustomGroup> customGroupList = CustomGroupUtil.getGroupByUserId(userId);
// return StreamUtil.map(customGroupList, TntCustomGroup::getId);
// }
@Override
public
List
<
PlatMenu
>
getMenuListByUserId
(
String
userId
)
{
return
getBaseMapper
().
getMenuListByUserId
(
userId
);
...
...
server-service/src/main/java/com/makeit/service/saas/impl/PlatTenantServiceImpl.java
View file @
9e7b849f
...
...
@@ -202,7 +202,7 @@ implements PlatTenantService {
//组织表增加一条数据
PlatOrg
platOrg
=
convertToPlatOrg
(
tntTenant
);
platOrgService
.
add
(
platOrg
);
platOrgService
.
save
(
platOrg
);
return
tntTenant
.
getId
();
}
...
...
@@ -236,6 +236,8 @@ implements PlatTenantService {
platOrg
.
setName
(
platTenant
.
getName
());
platOrg
.
setStatus
(
platTenant
.
getStatus
());
platOrg
.
setId
(
platTenant
.
getId
());
//租户没有父级
platOrg
.
setParentId
(
"1"
);
return
platOrg
;
}
...
...
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