Commit d0d9a45f by songyinghui

feature: 好办权限初始化

parent 5f3af5de
......@@ -526,19 +526,17 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
// 查询企微下 导购、店长、区经 的role_id
String wxEnterpriseId = wxEnterpris.getWxEnterpriseId();
// 处理商户权限
handlerMaterchant(contentMaterialROleInitQDTO, wxEnterpriseId);
handlerMerchant(contentMaterialROleInitQDTO, wxEnterpriseId);
}
return ServiceResponse.success();
}
private void handlerMaterchant(ContentMaterialROleInitQDTO contentMaterialROleInitQDTO, String wxEnterpriseId) {
private void handlerMerchant(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());
......@@ -567,6 +565,28 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
.collect(Collectors.toList());
logger.info("企微:{} roleId:{} 新增权限code: {}", wxEnterpriseId, haobanRoleBO.getRoleId(), JSON.toJSONString(tabHaobanRoleMenus));
haobanRoleMenus.addAll(tabHaobanRoleMenus);
if (haobanRoleBO.getSystemFlag() == 0) {
// 处理只加运维权限逻辑
if (CollectionUtils.isNotEmpty(superManagementMenuCode)) {
List<TabHaobanRoleMenu> roleMenus = superManagementMenuCode
.stream()
.filter(item -> StringUtils.isNotBlank(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());
haobanRoleMenus.addAll(roleMenus);
}
}
}
logger.info("企微:{} 新增权限code: {}", wxEnterpriseId, JSON.toJSONString(haobanRoleMenus));
if (CollectionUtils.isNotEmpty(haobanRoleMenus)) {
......@@ -575,6 +595,7 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
}
private static final Map<String, List<String> > menuCodeMap = new HashMap<>();
private static final List<String> superManagementMenuCode = new ArrayList<>();
static {
// 导购
......@@ -591,6 +612,7 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
menuCodeMap.put("2" + ContentMaterialROleInitQDTO.Version.LOW.getCode(), Arrays.asList("materialMain", "commodityCenter", "commodityCenterTab", "materialCenterTab", "goodsDetail_material", "goodsCenter_Count", "materialManage"));
menuCodeMap.put("2" + ContentMaterialROleInitQDTO.Version.HIGH.getCode(), Arrays.asList("materialMain", "commodityCenter", "commodityCenterTab", "materialCenterTab",
"goodsDetail_material", "goodsCenter_Count", "materialManage", "publishMaterial", "userCenter_createCenter"));
// superManagementMenuCode.add("");
}
......@@ -605,7 +627,7 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
logger.info("flushRightOneTime 刷新企业内容权限:{}", params);
// 获取所有开通内容高级版的企业
List<String> enterpriseIds = materialEnterpriseAdaptor.queryHasRightEnterpriseIds(MaterialEnterpriseAdaptor.MaterialLevel.HIGH.getCode());
List<String> enterpriseIds = materialEnterpriseAdaptor.queryHasRightEnterpriseIds(MaterialEnterpriseAdaptor.MaterialLevel.LOW.getCode());
// 执行刷新权限
String enterpriseId = "";
if (StringUtils.isNotBlank(params) && !StringUtils.equals("-1", params)) {
......@@ -621,14 +643,11 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
logger.info("【flushRightOneTime】当前企业:{} 不是目标企业:{}, 忽略", tempId, enterpriseId);
continue;
}
ContentMaterialROleInitQDTO contentMaterialROleInitQDTO = new ContentMaterialROleInitQDTO();
contentMaterialROleInitQDTO.setEnterpriseId(tempId);
contentMaterialROleInitQDTO.setVersion(MaterialEnterpriseAdaptor.MaterialLevel.HIGH.getCode());
logger.info("【flushRightOneTime】添加企业素材纬度权限: {}", JSON.toJSONString(contentMaterialROleInitQDTO));
logger.info("【flushRightOneTime】添加企业素材纬度权限: {}", tempId);
// 查询企业下所有的微信企业id
List<TabHaobanWxEnterprise> tabHaobanWxEnterprises = wxEnterpriseRelatedService.listByEnterpriseId(contentMaterialROleInitQDTO.getEnterpriseId());
List<TabHaobanWxEnterprise> tabHaobanWxEnterprises = wxEnterpriseRelatedService.listByEnterpriseId(tempId);
if (CollectionUtils.isEmpty(tabHaobanWxEnterprises)) {
logger.info("【flushRightOneTime】企业 {} 未关联企微 ", contentMaterialROleInitQDTO.getEnterpriseId());
logger.info("【flushRightOneTime】企业 {} 未关联企微 ", tempId);
continue;
}
......@@ -637,9 +656,9 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
String wxEnterpriseId = wxEnterpris.getWxEnterpriseId();
// 处理商户权限
// 运维
List<HaobanRoleBO> haobanRoleBOS = haobanRoleService.getListByWxEnterpriseId(wxEnterpriseId, null);
List<HaobanRoleBO> haobanRoleBOS = haobanRoleService.getListByWxEnterpriseId(wxEnterpriseId, 0);
if (CollectionUtils.isEmpty(haobanRoleBOS)) {
logger.info("【flushRightOneTime】企业{} 企微 {} 下没有角色 ", contentMaterialROleInitQDTO.getEnterpriseId(), wxEnterpriseId);
logger.info("【flushRightOneTime】企业{} 企微 {} 下没有角色 ", tempId, wxEnterpriseId);
continue;
}
logger.info("【flushRightOneTime】企业 {} 企微 {} 下角色个数: {}", enterpriseId, wxEnterpriseId, haobanRoleBOS.size());
......
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