Commit 83380e85 by songyinghui

feature: 好办权限刷新

parent 93dc42c2
......@@ -611,16 +611,69 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
if (StringUtils.isNotBlank(params) && !StringUtils.equals("-1", params)) {
enterpriseId = params;
}
List<String> menuCodes = new ArrayList<>();
menuCodes.add("publishMaterial");
menuCodes.add("userCenter_createCenter");
for (String tempId : enterpriseIds) {
if (StringUtils.isNotBlank(enterpriseId) && !StringUtils.equalsIgnoreCase(enterpriseId, tempId)) {
logger.info("当前企业:{} 不是目标企业:{}, 忽略", tempId, enterpriseId);
logger.info("【flushRightOneTime】当前企业:{} 不是目标企业:{}, 忽略", tempId, enterpriseId);
continue;
}
ContentMaterialROleInitQDTO contentMaterialROleInitQDTO = new ContentMaterialROleInitQDTO();
contentMaterialROleInitQDTO.setEnterpriseId(tempId);
contentMaterialROleInitQDTO.setVersion(MaterialEnterpriseAdaptor.MaterialLevel.HIGH.getCode());
logger.info("添加企业素材纬度权限: {}", JSON.toJSONString(contentMaterialROleInitQDTO));
this.contentMaterialRoleInit(contentMaterialROleInitQDTO);
logger.info("【flushRightOneTime】添加企业素材纬度权限: {}", JSON.toJSONString(contentMaterialROleInitQDTO));
// 查询企业下所有的微信企业id
List<TabHaobanWxEnterprise> tabHaobanWxEnterprises = wxEnterpriseRelatedService.listByEnterpriseId(contentMaterialROleInitQDTO.getEnterpriseId());
if (CollectionUtils.isEmpty(tabHaobanWxEnterprises)) {
logger.info("【flushRightOneTime】企业 {} 未关联企微 ", contentMaterialROleInitQDTO.getEnterpriseId());
return ServiceResponse.success();
}
for (TabHaobanWxEnterprise wxEnterpris : tabHaobanWxEnterprises) {
// 查询企微下 导购、店长、区经 的role_id
String wxEnterpriseId = wxEnterpris.getWxEnterpriseId();
// 处理商户权限
// 运维 + 好办后台
List<HaobanRoleBO> haobanRoleBOS = haobanRoleService.getListByWxEnterpriseId(wxEnterpriseId, null);
if (CollectionUtils.isEmpty(haobanRoleBOS)) {
logger.info("【flushRightOneTime】企业{} 企微 {} 下没有角色 ", contentMaterialROleInitQDTO.getEnterpriseId(), wxEnterpriseId);
continue;
}
logger.info("【flushRightOneTime】企业 {} 企微 {} 下角色个数: {}", enterpriseId, wxEnterpriseId, haobanRoleBOS.size());
// 为role 添加菜单
List<TabHaobanRoleMenu> haobanRoleMenus = new ArrayList<>();
for (HaobanRoleBO haobanRoleBO : haobanRoleBOS) {
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;
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("【flushRightOneTime】企微:{} roleId:{} 新增权限code: {}", wxEnterpriseId, haobanRoleBO.getRoleId(), JSON.toJSONString(tabHaobanRoleMenus));
haobanRoleMenus.addAll(tabHaobanRoleMenus);
}
logger.info("【flushRightOneTime】企微:{} 新增权限code: {}", wxEnterpriseId, JSON.toJSONString(haobanRoleMenus));
if (CollectionUtils.isNotEmpty(haobanRoleMenus)) {
haobanRoleMenuService.insertBatch(haobanRoleMenus);
}
}
}
return ServiceResponse.success();
}
......
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