@@ -47,6 +47,7 @@ type IAppService interface {
4747 GetAppDetailByID (id uint ) (* response.AppDetailDTO , error )
4848 SyncAppListFromLocal (taskID string )
4949 GetAppIcon (appID uint ) ([]byte , error )
50+ GetAppDetailByKey (appKey , version string ) (response.AppDetailSimpleDTO , error )
5051}
5152
5253func NewIAppService () IAppService {
@@ -118,14 +119,15 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (*response.
118119 }
119120 }
120121 appDTO := & response.AppItem {
121- ID : ap .ID ,
122- Name : ap .Name ,
123- Key : ap .Key ,
124- Limit : ap .Limit ,
125- GpuSupport : ap .GpuSupport ,
126- Recommend : ap .Recommend ,
127- Description : ap .GetDescription (ctx ),
128- Type : ap .Type ,
122+ ID : ap .ID ,
123+ Name : ap .Name ,
124+ Key : ap .Key ,
125+ Limit : ap .Limit ,
126+ GpuSupport : ap .GpuSupport ,
127+ Recommend : ap .Recommend ,
128+ Description : ap .GetDescription (ctx ),
129+ Type : ap .Type ,
130+ BatchInstallSupport : ap .BatchInstallSupport ,
129131 }
130132 appDTOs = append (appDTOs , appDTO )
131133 tags , err := getAppTags (ap .ID , lang )
@@ -203,6 +205,20 @@ func (a AppService) GetApp(ctx *gin.Context, key string) (*response.AppDTO, erro
203205 return & appDTO , nil
204206}
205207
208+ func (a AppService ) GetAppDetailByKey (appKey , version string ) (response.AppDetailSimpleDTO , error ) {
209+ var appDetailDTO response.AppDetailSimpleDTO
210+ app , err := appRepo .GetFirst (appRepo .WithKey (appKey ))
211+ if err != nil {
212+ return appDetailDTO , err
213+ }
214+ appDetail , err := appDetailRepo .GetFirst (appDetailRepo .WithAppId (app .ID ), appDetailRepo .WithVersion (version ))
215+ if err != nil {
216+ return appDetailDTO , err
217+ }
218+ appDetailDTO .ID = appDetail .ID
219+ return appDetailDTO , nil
220+ }
221+
206222func (a AppService ) GetAppDetail (appID uint , version , appType string ) (response.AppDetailDTO , error ) {
207223 var (
208224 appDetailDTO response.AppDetailDTO
@@ -386,11 +402,21 @@ func (a AppService) Install(req request.AppInstallCreate) (appInstall *model.App
386402 App : app ,
387403 }
388404 composeMap := make (map [string ]interface {})
405+ var composeRes []byte
389406 if req .EditCompose {
390407 if err = yaml .Unmarshal ([]byte (req .DockerCompose ), & composeMap ); err != nil {
391408 return
392409 }
393410 } else {
411+ if appDetail .DockerCompose == "" {
412+ dockerComposeUrl := fmt .Sprintf ("%s/%s/1panel/%s/%s/docker-compose.yml" , global .CONF .RemoteURL .AppRepo , global .CONF .Base .Mode , app .Key , appDetail .Version )
413+ _ , composeRes , err = req_helper .HandleRequest (dockerComposeUrl , http .MethodGet , constant .TimeOut20s )
414+ if err != nil {
415+ return
416+ }
417+ appDetail .DockerCompose = string (composeRes )
418+ _ = appDetailRepo .Update (context .Background (), appDetail )
419+ }
394420 if err = yaml .Unmarshal ([]byte (appDetail .DockerCompose ), & composeMap ); err != nil {
395421 return
396422 }
0 commit comments