From 824051e89e45ca32aedb3be3695fc9ccb4a9b19f Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 30 May 2023 21:54:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=99=90=E5=88=B6=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=8E=AF=E5=A2=83=E4=B8=AD=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E5=BA=94=E7=94=A8=E7=89=88=E6=9C=AC=20(#1197)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/repo/runtime.go | 7 +++++++ backend/app/service/app.go | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/backend/app/repo/runtime.go b/backend/app/repo/runtime.go index 59ed29e0c..00470a8a9 100644 --- a/backend/app/repo/runtime.go +++ b/backend/app/repo/runtime.go @@ -14,6 +14,7 @@ type IRuntimeRepo interface { WithImage(image string) DBOption WithNotId(id uint) DBOption WithStatus(status string) DBOption + WithDetailId(id uint) DBOption Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error) Create(ctx context.Context, 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 { return func(g *gorm.DB) *gorm.DB { return g.Where("id != ?", id) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index d43362efe..643b0ab4a 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -852,6 +852,10 @@ func (a AppService) SyncAppListFromRemote() error { addDetails = append(addDetails, d) } else { if d.Status == constant.AppTakeDown { + runtime, _ := runtimeRepo.GetFirst(runtimeRepo.WithDetailId(d.ID)) + if runtime.ID > 0 { + continue + } deleteDetails = append(deleteDetails, d) } else { updateDetails = append(updateDetails, d)