Commit 54ff1e59 by songyinghui

feat: 权限初始化

parent e5626c08
......@@ -495,6 +495,7 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
@Override
public ServiceResponse<Void> contentMaterialRoleInit(ContentMaterialROleInitQDTO contentMaterialROleInitQDTO) {
logger.info("好办权限初始化 {}", JSON.toJSONString(contentMaterialROleInitQDTO));
if (contentMaterialROleInitQDTO.getVersion() == null) {
return ServiceResponse.success();
}
......@@ -509,8 +510,8 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
for (TabHaobanWxEnterprise wxEnterpris : tabHaobanWxEnterprises) {
// 查询企微下 导购、店长、区经 的role_id
String wxEnterpriseId = wxEnterpris.getWxEnterpriseId();
// 运维后台 + 好办后台
List<HaobanRoleBO> haobanRoleBOS = haobanRoleService.getListByWxEnterpriseId(wxEnterpriseId, null);
// 只取好办后台
List<HaobanRoleBO> haobanRoleBOS = haobanRoleService.getListByWxEnterpriseId(wxEnterpriseId, 1);
if (CollectionUtils.isEmpty(haobanRoleBOS)) {
logger.info("企业{} 企微 {} 下没有角色 ", contentMaterialROleInitQDTO.getEnterpriseId(), wxEnterpriseId);
continue;
......@@ -523,7 +524,14 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
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> finalHasExistMenuCodes = hasExistMenuCodes;
List<TabHaobanRoleMenu> tabHaobanRoleMenus = menuCodes.stream()
.filter(item -> !finalHasExistMenuCodes.contains(item))
.map(item -> {
TabHaobanRoleMenu temp = new TabHaobanRoleMenu();
temp.setRoleId(haobanRoleBO.getRoleId());
......@@ -537,8 +545,10 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
.collect(Collectors.toList());
haobanRoleMenus.addAll(tabHaobanRoleMenus);
}
haobanRoleMenuService.insertBatch(haobanRoleMenus);
logger.info("新增权限code: {}", JSON.toJSONString(haobanRoleMenus));
if (CollectionUtils.isNotEmpty(haobanRoleMenus)) {
haobanRoleMenuService.insertBatch(haobanRoleMenus);
}
}
return ServiceResponse.success();
}
......@@ -547,15 +557,15 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
static {
// 导购
menuCodeMap.put("0" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialCenter", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
menuCodeMap.put("0" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("goodsDetail_material", "goodsCenter_Count", "materialManage", "salesClue", "customerDetail_interact"));
menuCodeMap.put("0" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialMain", "goodsDetail_material", "goodsCenter_Count"));
menuCodeMap.put("0" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("materialMain","goodsDetail_material", "goodsCenter_Count", "salesClue", "customerDetail_interact"));
// 店长
menuCodeMap.put("1" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialCenter", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
menuCodeMap.put("1" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("materialCenter", "goodsDetail_material", "goodsCenter_Count", "materialManage","salesClue", "customerDetail_interact"));
menuCodeMap.put("1" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialMain", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
menuCodeMap.put("1" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("materialMain", "goodsDetail_material", "goodsCenter_Count", "materialManage", "salesClue", "customerDetail_interact"));
// 区经
menuCodeMap.put("2" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialCenter", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
menuCodeMap.put("2" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("materialCenter", "goodsDetail_material", "goodsCenter_Count", "materialManage", "salesClue", "customerDetail_interact"));
menuCodeMap.put("2" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialMain", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
menuCodeMap.put("2" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("materialMain", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment