Add addCustomMenu support and // ADD OTHER SERVICE anchor for CEV2 menu injection
This commit is contained in:
@@ -76,6 +76,8 @@ public class MongoDataInitializer implements CommandLineRunner {
|
||||
// 5. Initialize Core Navigation Menus
|
||||
initMenusAndAccess(adminGrp, userGrp);
|
||||
|
||||
// ADD OTHER SERVICE
|
||||
|
||||
LOGGER.info("[MongoDataInitializer] Baseline data initialization check complete.");
|
||||
}
|
||||
|
||||
@@ -218,4 +220,34 @@ public class MongoDataInitializer implements CommandLineRunner {
|
||||
LOGGER.warn("[MongoDataInitializer] Could not grant access for menu {}: {}", menu.getMenuItemId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void addCustomMenu(String tableName, String menuActionLink, String menuType) {
|
||||
Long parentMenuId = 1577L;
|
||||
if ("Master".equalsIgnoreCase(menuType) || "Masters".equalsIgnoreCase(menuType)) {
|
||||
parentMenuId = 1601L;
|
||||
}
|
||||
List<MenuDet> existing = menuDetRepository.findAll();
|
||||
for (MenuDet em : existing) {
|
||||
if (menuActionLink.equalsIgnoreCase(em.getMain_menu_action_name())
|
||||
|| tableName.equalsIgnoreCase(em.getMenuItemDesc())) {
|
||||
LOGGER.info("[MongoDataInitializer] Menu '{}' already exists, skipping.", tableName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
long maxId = 1700L;
|
||||
for (MenuDet em : existing) {
|
||||
if (em.getMenuItemId() != null && em.getMenuItemId() > maxId) {
|
||||
maxId = em.getMenuItemId();
|
||||
}
|
||||
}
|
||||
Long nextMenuItemId = maxId + 1L;
|
||||
|
||||
MenuDet m = createMenu(nextMenuItemId, parentMenuId, 8001L, tableName, tableName, menuActionLink, tableName);
|
||||
List<AppUserRole> allRoles = appUserRoleRepository.findAll();
|
||||
for (AppUserRole role : allRoles) {
|
||||
grantAccess(role, m);
|
||||
}
|
||||
LOGGER.info("[MongoDataInitializer] Custom menu '{}' created with ID {} under parent {}.", tableName, nextMenuItemId, parentMenuId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user