mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
feat: 限制删除运行环境中使用的应用版本 (#1197)
This commit is contained in:
parent
ab45cc27d5
commit
824051e89e
@ -14,6 +14,7 @@ type IRuntimeRepo interface {
|
|||||||
WithImage(image string) DBOption
|
WithImage(image string) DBOption
|
||||||
WithNotId(id uint) DBOption
|
WithNotId(id uint) DBOption
|
||||||
WithStatus(status string) DBOption
|
WithStatus(status string) DBOption
|
||||||
|
WithDetailId(id uint) DBOption
|
||||||
Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error)
|
Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error)
|
||||||
Create(ctx context.Context, runtime *model.Runtime) error
|
Create(ctx context.Context, runtime *model.Runtime) error
|
||||||
Save(runtime *model.Runtime) error
|
Save(runtime *model.Runtime) error
|
||||||
@ -43,6 +44,12 @@ func (r *RuntimeRepo) WithImage(image string) DBOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RuntimeRepo) WithDetailId(id uint) DBOption {
|
||||||
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
|
return g.Where("app_detail_id = ?", id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *RuntimeRepo) WithNotId(id uint) DBOption {
|
func (r *RuntimeRepo) WithNotId(id uint) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("id != ?", id)
|
return g.Where("id != ?", id)
|
||||||
|
@ -852,6 +852,10 @@ func (a AppService) SyncAppListFromRemote() error {
|
|||||||
addDetails = append(addDetails, d)
|
addDetails = append(addDetails, d)
|
||||||
} else {
|
} else {
|
||||||
if d.Status == constant.AppTakeDown {
|
if d.Status == constant.AppTakeDown {
|
||||||
|
runtime, _ := runtimeRepo.GetFirst(runtimeRepo.WithDetailId(d.ID))
|
||||||
|
if runtime.ID > 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
deleteDetails = append(deleteDetails, d)
|
deleteDetails = append(deleteDetails, d)
|
||||||
} else {
|
} else {
|
||||||
updateDetails = append(updateDetails, d)
|
updateDetails = append(updateDetails, d)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user