mirror of
https://github.com/1Panel-dev/1Panel
synced 2024-11-23 00:18:21 +00:00
fix: 解决部分应用删除失败的问题 (#2505)
This commit is contained in:
parent
db613c3bf7
commit
862585c2f9
@ -24,6 +24,7 @@ type ICommonRepo interface {
|
|||||||
WithByDate(startTime, endTime time.Time) DBOption
|
WithByDate(startTime, endTime time.Time) DBOption
|
||||||
WithByStartDate(startTime time.Time) DBOption
|
WithByStartDate(startTime time.Time) DBOption
|
||||||
WithByStatus(status string) DBOption
|
WithByStatus(status string) DBOption
|
||||||
|
WithByFrom(from string) DBOption
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommonRepo struct{}
|
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 {
|
func (c *CommonRepo) WithLikeName(name string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
|
@ -536,9 +536,9 @@ func (a *AppInstallService) ChangeAppPort(req request.PortUpdate) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, error) {
|
func (a *AppInstallService) DeleteCheck(installID uint) ([]dto.AppResource, error) {
|
||||||
var res []dto.AppResource
|
var res []dto.AppResource
|
||||||
appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(installId))
|
appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(installID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -562,8 +562,8 @@ func (a *AppInstallService) DeleteCheck(installId uint) ([]dto.AppResource, erro
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if app.Type == "runtime" {
|
if app.Type == constant.Runtime {
|
||||||
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID))
|
resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithLinkId(appInstall.ID), commonRepo.WithByFrom(constant.AppResourceLocal))
|
||||||
for _, resource := range resources {
|
for _, resource := range resources {
|
||||||
linkInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(resource.AppInstallId))
|
linkInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(resource.AppInstallId))
|
||||||
res = append(res, dto.AppResource{
|
res = append(res, dto.AppResource{
|
||||||
|
Loading…
Reference in New Issue
Block a user