From 862585c2f92579cbb75809823c5fdadc0b7848fd Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 11 Oct 2023 01:48:29 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=88=A0=E9=99=A4=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#2505)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/repo/common.go | 7 +++++++ backend/app/service/app_install.go | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend/app/repo/common.go b/backend/app/repo/common.go index ec52f2bd3..e6cf0b23f 100644 --- a/backend/app/repo/common.go +++ b/backend/app/repo/common.go @@ -24,6 +24,7 @@ type ICommonRepo interface { WithByDate(startTime, endTime time.Time) DBOption WithByStartDate(startTime time.Time) DBOption WithByStatus(status string) DBOption + WithByFrom(from string) DBOption } type CommonRepo struct{} @@ -80,6 +81,12 @@ func (c *CommonRepo) WithByStatus(status string) DBOption { } } +func (c *CommonRepo) WithByFrom(from string) DBOption { + return func(g *gorm.DB) *gorm.DB { + return g.Where("`from` = ?", from) + } +} + func (c *CommonRepo) WithLikeName(name string) DBOption { return func(g *gorm.DB) *gorm.DB { if len(name) == 0 { diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index eae439ad3..488b5841d 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -536,9 +536,9 @@ func (a *AppInstallService) ChangeAppPort(req request.PortUpdate) error { return nil } -func (a *AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, error) { +func (a *AppInstallService) DeleteCheck(installID uint) ([]dto.AppResource, error) { var res []dto.AppResource - appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(installId)) + appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(installID)) if err != nil { return nil, err } @@ -562,8 +562,8 @@ func (a *AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, erro }) } } - if app.Type == "runtime" { - resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID)) + if app.Type == constant.Runtime { + resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID), commonRepo.WithByFrom(constant.AppResourceLocal)) for _, resource := range resources { linkInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(resource.AppInstallId)) res = append(res, dto.AppResource{