mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-07 22:16:16 +08:00
feat: Optimized the runtime environment installation, but the application store still does not display it as installed. (#10175)
Refs https://github.com/1Panel-dev/1Panel/issues/10174
This commit is contained in:
parent
ce69b4de01
commit
97cdf7bc78
2 changed files with 22 additions and 2 deletions
|
@ -17,6 +17,7 @@ type IRuntimeRepo interface {
|
||||||
WithNotId(id uint) DBOption
|
WithNotId(id uint) DBOption
|
||||||
WithStatus(status string) DBOption
|
WithStatus(status string) DBOption
|
||||||
WithDetailId(id uint) DBOption
|
WithDetailId(id uint) DBOption
|
||||||
|
WithDetailIdsIn(ids []uint) DBOption
|
||||||
WithPort(port int) DBOption
|
WithPort(port int) DBOption
|
||||||
WithNormalStatus(status string) DBOption
|
WithNormalStatus(status string) DBOption
|
||||||
Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error)
|
Page(page, size int, opts ...DBOption) (int64, []model.Runtime, error)
|
||||||
|
@ -55,6 +56,12 @@ func (r *RuntimeRepo) WithDetailId(id uint) DBOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *RuntimeRepo) WithDetailIdsIn(ids []uint) DBOption {
|
||||||
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
|
return g.Where("app_detail_id in(?) ", ids)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -132,8 +132,21 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
appDTO.Tags = tags
|
appDTO.Tags = tags
|
||||||
installs, _ := appInstallRepo.ListBy(context.Background(), appInstallRepo.WithAppId(ap.ID))
|
if ap.Type == constant.RuntimePHP || ap.Type == constant.RuntimeGo || ap.Type == constant.RuntimeNode || ap.Type == constant.RuntimePython || ap.Type == constant.RuntimeJava || ap.Type == constant.RuntimeDotNet {
|
||||||
appDTO.Installed = len(installs) > 0
|
details, _ := appDetailRepo.GetBy(appDetailRepo.WithAppId(ap.ID))
|
||||||
|
var ids []uint
|
||||||
|
if len(details) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, d := range details {
|
||||||
|
ids = append(ids, d.ID)
|
||||||
|
}
|
||||||
|
runtimes, _ := runtimeRepo.List(runtimeRepo.WithDetailIdsIn(ids))
|
||||||
|
appDTO.Installed = len(runtimes) > 0
|
||||||
|
} else {
|
||||||
|
installs, _ := appInstallRepo.ListBy(context.Background(), appInstallRepo.WithAppId(ap.ID))
|
||||||
|
appDTO.Installed = len(installs) > 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res.Items = appDTOs
|
res.Items = appDTOs
|
||||||
res.Total = total
|
res.Total = total
|
||||||
|
|
Loading…
Add table
Reference in a new issue