Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
1
Merge Requests
1
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
haoban3.0
haoban-manage3.0
Commits
bc75b5e0
Commit
bc75b5e0
authored
Apr 12, 2023
by
songyinghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 好办权限初始化
parent
b91368ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
44 deletions
+49
-44
HaobanRoleApiServiceImpl.java
...rvice/service/out/impl/role/HaobanRoleApiServiceImpl.java
+49
-44
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/role/HaobanRoleApiServiceImpl.java
View file @
bc75b5e0
...
...
@@ -510,55 +510,60 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
for
(
TabHaobanWxEnterprise
wxEnterpris
:
tabHaobanWxEnterprises
)
{
// 查询企微下 导购、店长、区经 的role_id
String
wxEnterpriseId
=
wxEnterpris
.
getWxEnterpriseId
();
// 只取好办后台
List
<
HaobanRoleBO
>
haobanRoleBOS
=
haobanRoleService
.
getListByWxEnterpriseId
(
wxEnterpriseId
,
1
);
if
(
CollectionUtils
.
isEmpty
(
haobanRoleBOS
))
{
logger
.
info
(
"企业{} 企微 {} 下没有角色 "
,
contentMaterialROleInitQDTO
.
getEnterpriseId
(),
wxEnterpriseId
);
// 处理商户权限
handlerMaterchant
(
contentMaterialROleInitQDTO
,
wxEnterpriseId
);
}
return
ServiceResponse
.
success
();
}
private
void
handlerMaterchant
(
ContentMaterialROleInitQDTO
contentMaterialROleInitQDTO
,
String
wxEnterpriseId
)
{
// 运维 + 好办后台
List
<
HaobanRoleBO
>
haobanRoleBOS
=
haobanRoleService
.
getListByWxEnterpriseId
(
wxEnterpriseId
,
null
);
if
(
CollectionUtils
.
isEmpty
(
haobanRoleBOS
))
{
logger
.
info
(
"企业{} 企微 {} 下没有角色 "
,
contentMaterialROleInitQDTO
.
getEnterpriseId
(),
wxEnterpriseId
);
return
;
}
// 为role 添加菜单
List
<
TabHaobanRoleMenu
>
haobanRoleMenus
=
new
ArrayList
<>();
for
(
HaobanRoleBO
haobanRoleBO
:
haobanRoleBOS
)
{
List
<
String
>
menuCodes
=
menuCodeMap
.
get
(
haobanRoleBO
.
getClerkType
()
+
""
+
contentMaterialROleInitQDTO
.
getVersion
());
if
(
CollectionUtils
.
isEmpty
(
menuCodes
))
{
continue
;
}
// 为role 添加菜单
List
<
TabHaobanRoleMenu
>
haobanRoleMenus
=
new
ArrayList
<>();
for
(
HaobanRoleBO
haobanRoleBO
:
haobanRoleBOS
)
{
List
<
String
>
menuCodes
=
menuCodeMap
.
get
(
haobanRoleBO
.
getClerkType
()
+
""
+
contentMaterialROleInitQDTO
.
getVersion
());
if
(
CollectionUtils
.
isEmpty
(
menuCodes
))
{
continue
;
}
logger
.
info
(
"本次对应的menuCode:{}"
,
JSON
.
toJSONString
(
menuCodes
));
List
<
String
>
hasExistMenuCodes
=
haobanRoleMenuService
.
getByWxEnterpriseIdAndRoleId
(
wxEnterpriseId
,
haobanRoleBO
.
getRoleId
());
if
(
CollectionUtils
.
isEmpty
(
hasExistMenuCodes
))
{
hasExistMenuCodes
=
new
ArrayList
<>();
}
List
<
String
>
excludeMenuCodes
=
hasExistMenuCodes
;
if
(!
hasExistMenuCodes
.
contains
(
"commodityCenter"
))
{
// 如果该角色原来没有【商品中心权限】 不勾选发圈素材和素材数量
logger
.
info
(
"roleId:{} 原本没有商品中心权限 "
,
haobanRoleBO
.
getRoleId
());
excludeMenuCodes
.
add
(
"goodsDetail_material"
);
excludeMenuCodes
.
add
(
"goodsCenter_Count"
);
}
List
<
TabHaobanRoleMenu
>
tabHaobanRoleMenus
=
menuCodes
.
stream
()
.
filter
(
item
->
!
excludeMenuCodes
.
contains
(
item
))
.
map
(
item
->
{
TabHaobanRoleMenu
temp
=
new
TabHaobanRoleMenu
();
temp
.
setRoleMenuId
(
UniqueIdUtils
.
uniqueLong
());
temp
.
setRoleId
(
haobanRoleBO
.
getRoleId
());
temp
.
setWxEnterpriseId
(
wxEnterpriseId
);
temp
.
setStatusFlag
(
1
);
temp
.
setMenuCode
(
item
);
temp
.
setCreateTime
(
new
Date
());
temp
.
setUpdateTime
(
new
Date
());
return
temp
;
})
.
collect
(
Collectors
.
toList
());
logger
.
info
(
"企微:{} roleId:{} 新增权限code: {}"
,
wxEnterpriseId
,
haobanRoleBO
.
getRoleId
(),
JSON
.
toJSONString
(
tabHaobanRoleMenus
));
haobanRoleMenus
.
addAll
(
tabHaobanRoleMenus
);
logger
.
info
(
"本次对应的menuCode:{}"
,
JSON
.
toJSONString
(
menuCodes
));
List
<
String
>
hasExistMenuCodes
=
haobanRoleMenuService
.
getByWxEnterpriseIdAndRoleId
(
wxEnterpriseId
,
haobanRoleBO
.
getRoleId
());
if
(
CollectionUtils
.
isEmpty
(
hasExistMenuCodes
))
{
hasExistMenuCodes
=
new
ArrayList
<>();
}
logger
.
info
(
"企微:{} 新增权限code: {}"
,
wxEnterpriseId
,
JSON
.
toJSONString
(
haobanRoleMenus
));
if
(
CollectionUtils
.
isNotEmpty
(
haobanRoleMenus
))
{
haobanRoleMenuService
.
insertBatch
(
haobanRoleMenus
);
List
<
String
>
excludeMenuCodes
=
hasExistMenuCodes
;
if
(!
hasExistMenuCodes
.
contains
(
"commodityCenter"
))
{
// 如果该角色原来没有【商品中心权限】 不勾选发圈素材和素材数量
logger
.
info
(
"roleId:{} 原本没有商品中心权限 "
,
haobanRoleBO
.
getRoleId
());
excludeMenuCodes
.
add
(
"goodsDetail_material"
);
excludeMenuCodes
.
add
(
"goodsCenter_Count"
);
}
List
<
TabHaobanRoleMenu
>
tabHaobanRoleMenus
=
menuCodes
.
stream
()
.
filter
(
item
->
!
excludeMenuCodes
.
contains
(
item
))
.
map
(
item
->
{
TabHaobanRoleMenu
temp
=
new
TabHaobanRoleMenu
();
temp
.
setRoleMenuId
(
UniqueIdUtils
.
uniqueLong
());
temp
.
setRoleId
(
haobanRoleBO
.
getRoleId
());
temp
.
setWxEnterpriseId
(
wxEnterpriseId
);
temp
.
setStatusFlag
(
1
);
temp
.
setMenuCode
(
item
);
temp
.
setCreateTime
(
new
Date
());
temp
.
setUpdateTime
(
new
Date
());
return
temp
;
})
.
collect
(
Collectors
.
toList
());
logger
.
info
(
"企微:{} roleId:{} 新增权限code: {}"
,
wxEnterpriseId
,
haobanRoleBO
.
getRoleId
(),
JSON
.
toJSONString
(
tabHaobanRoleMenus
));
haobanRoleMenus
.
addAll
(
tabHaobanRoleMenus
);
}
logger
.
info
(
"企微:{} 新增权限code: {}"
,
wxEnterpriseId
,
JSON
.
toJSONString
(
haobanRoleMenus
));
if
(
CollectionUtils
.
isNotEmpty
(
haobanRoleMenus
))
{
haobanRoleMenuService
.
insertBatch
(
haobanRoleMenus
);
}
return
ServiceResponse
.
success
();
}
private
static
final
Map
<
String
,
List
<
String
>
>
menuCodeMap
=
new
HashMap
<>();
...
...
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