feat: Optimized the runtime environment installation, but the application store still does not display it as installed.

This commit is contained in:
zhengkunwang223 2025-08-28 15:32:18 +08:00
parent ce69b4de01
commit 973d8dea8c
2 changed files with 22 additions and 2 deletions

View file

@ -17,6 +17,7 @@ type IRuntimeRepo interface {
WithNotId(id uint) DBOption
WithStatus(status string) DBOption
WithDetailId(id uint) DBOption
WithDetailIdsIn(ids []uint) DBOption
WithPort(port int) DBOption
WithNormalStatus(status string) DBOption
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 {
return func(g *gorm.DB) *gorm.DB {
return g.Where("id != ?", id)

View file

@ -132,8 +132,21 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{
continue
}
appDTO.Tags = tags
installs, _ := appInstallRepo.ListBy(context.Background(), appInstallRepo.WithAppId(ap.ID))
appDTO.Installed = len(installs) > 0
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 {
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.Total = total