feat: live module and jenkins pipeline to harbor deploy
This commit is contained in:
@@ -127,6 +127,50 @@ func EnsureAdminSurface(db *gorm.DB, surface platformmodule.Surface, rootAuthori
|
||||
})
|
||||
}
|
||||
|
||||
// RemoveAdminMenus removes obsolete menu metadata without touching business
|
||||
// data. It is used by module migrations when a menu is intentionally deleted
|
||||
// from the current admin surface.
|
||||
func RemoveAdminMenus(db *gorm.DB, names ...string) error {
|
||||
if db == nil || len(names) == 0 || !db.Migrator().HasTable(&menuPO{}) {
|
||||
return nil
|
||||
}
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
var menus []menuPO
|
||||
if err := tx.Where("name IN ?", names).Find(&menus).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if len(menus) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
ids := make([]uint, 0, len(menus))
|
||||
for _, menu := range menus {
|
||||
ids = append(ids, menu.ID)
|
||||
}
|
||||
if tx.Migrator().HasTable(&authorityMenuPO{}) {
|
||||
if err := tx.Where("sys_base_menu_id IN ?", ids).Delete(&authorityMenuPO{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if tx.Migrator().HasTable(&authorityButtonPO{}) {
|
||||
if err := tx.Where("sys_menu_id IN ?", ids).Delete(&authorityButtonPO{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if tx.Migrator().HasTable(&menuButtonPO{}) {
|
||||
if err := tx.Unscoped().Where("sys_base_menu_id IN ?", ids).Delete(&menuButtonPO{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if tx.Migrator().HasTable(&menuParameterPO{}) {
|
||||
if err := tx.Unscoped().Where("sys_base_menu_id IN ?", ids).Delete(&menuParameterPO{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return tx.Unscoped().Where("id IN ?", ids).Delete(&menuPO{}).Error
|
||||
})
|
||||
}
|
||||
|
||||
// InheritAPIPolicy grants a new route only to authorities that already own
|
||||
// the supplied predecessor route. This preserves existing read-access intent
|
||||
// without broadening unrelated write permissions.
|
||||
|
||||
Reference in New Issue
Block a user