Commit 4c42a79f by songyinghui

feature: 菜单权限初始化

parent a06c6f29
......@@ -30,6 +30,12 @@ public class ContentMaterialROleInitQDTO implements Serializable {
*/
private Integer version;
/**
* 老版本
* null 代表是新增
*/
private Integer oldVersion;
public enum Version {
LOW(1, "基础版本"),
HIGH(2, "高级版");
......@@ -81,4 +87,12 @@ public class ContentMaterialROleInitQDTO implements Serializable {
public void setVersion(Integer version) {
this.version = version;
}
public Integer getOldVersion() {
return oldVersion;
}
public void setOldVersion(Integer oldVersion) {
this.oldVersion = oldVersion;
}
}
......@@ -537,12 +537,28 @@ public class HaobanRoleApiServiceImpl implements HaobanRoleApiService {
logger.info("企业{} 企微 {} 下没有角色 ", contentMaterialROleInitQDTO.getEnterpriseId(), wxEnterpriseId);
return;
}
if (contentMaterialROleInitQDTO.getOldVersion() != null
&& MaterialEnterpriseAdaptor.MaterialLevel.HIGH.getCode().equals(contentMaterialROleInitQDTO.getOldVersion())
&& MaterialEnterpriseAdaptor.MaterialLevel.LOW.getCode().equals(contentMaterialROleInitQDTO.getVersion()) ) {
logger.info("从高级版到低级版, 菜单不做调整 {}", JSON.toJSONString(contentMaterialROleInitQDTO));
return;
}
List<TabHaobanRoleMenu> haobanRoleMenus = new ArrayList<>();
for (HaobanRoleBO haobanRoleBO : haobanRoleBOS) {
List<String> menuCodes = menuCodeMap.get(haobanRoleBO.getClerkType() + "" + contentMaterialROleInitQDTO.getVersion());
if (CollectionUtils.isEmpty(menuCodes)) {
continue;
}
// 处理当前版本 如果是低到高 只处理版本差异的
if (contentMaterialROleInitQDTO.getOldVersion() != null
&& MaterialEnterpriseAdaptor.MaterialLevel.LOW.getCode().equals(contentMaterialROleInitQDTO.getOldVersion())
&& MaterialEnterpriseAdaptor.MaterialLevel.HIGH.getCode().equals(contentMaterialROleInitQDTO.getVersion())) {
// 从低版本 升级到 高版本, 此时菜单code只取 版本 差异的菜单
List<String> lowMenuCodes = menuCodeMap.get(haobanRoleBO.getClerkType() + "" + contentMaterialROleInitQDTO.getOldVersion());
List<String> highMenuCodes = menuCodeMap.get(haobanRoleBO.getClerkType() + "" + contentMaterialROleInitQDTO.getVersion());
highMenuCodes.removeAll(lowMenuCodes);
menuCodes = highMenuCodes;
}
logger.info("本次对应的menuCode:{}", JSON.toJSONString(menuCodes));
List<String> hasExistMenuCodes = haobanRoleMenuService.getByWxEnterpriseIdAndRoleId(wxEnterpriseId, haobanRoleBO.getRoleId());
if (CollectionUtils.isEmpty(hasExistMenuCodes)) {
......
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