diff --git a/backend/app/api/v1/runtime.go b/backend/app/api/v1/runtime.go index 3d6112cab..e4eef9e86 100644 --- a/backend/app/api/v1/runtime.go +++ b/backend/app/api/v1/runtime.go @@ -76,6 +76,20 @@ func (b *BaseApi) DeleteRuntime(c *gin.Context) { helper.SuccessWithOutData(c) } +func (b *BaseApi) DeleteRuntimeCheck(c *gin.Context) { + runTimeId, err := helper.GetIntParamByKey(c, "runTimeId") + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil) + return + } + checkData, err := runtimeService.DeleteCheck(runTimeId) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, checkData) +} + // @Tags Runtime // @Summary Update runtime // @Description 更新运行环境 diff --git a/backend/app/service/runtime.go b/backend/app/service/runtime.go index 9b780825f..b98ff6411 100644 --- a/backend/app/service/runtime.go +++ b/backend/app/service/runtime.go @@ -44,6 +44,7 @@ type IRuntimeService interface { OperateNodeModules(req request.NodeModuleOperateReq) error SyncForRestart() error SyncRuntimeStatus() error + DeleteCheck(installID uint) ([]dto.AppResource, error) } func NewRuntimeService() IRuntimeService { @@ -177,6 +178,18 @@ func (r *RuntimeService) Page(req request.RuntimeSearch) (int64, []response.Runt return total, res, nil } +func (r *RuntimeService) DeleteCheck(runTimeId uint) ([]dto.AppResource, error) { + var res []dto.AppResource + websites, _ := websiteRepo.GetBy(websiteRepo.WithRuntimeID(runTimeId)) + for _, website := range websites { + res = append(res, dto.AppResource{ + Type: "website", + Name: website.PrimaryDomain, + }) + } + return res, nil +} + func (r *RuntimeService) Delete(runtimeDelete request.RuntimeDelete) error { runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(runtimeDelete.ID)) if err != nil { diff --git a/backend/router/ro_runtime.go b/backend/router/ro_runtime.go index 539e9901c..eeee73c45 100644 --- a/backend/router/ro_runtime.go +++ b/backend/router/ro_runtime.go @@ -15,6 +15,7 @@ func (r *RuntimeRouter) InitRouter(Router *gin.RouterGroup) { baseApi := v1.ApiGroupApp.BaseApi { + groupRouter.GET("/installed/delete/check/:runTimeId", baseApi.DeleteRuntimeCheck) groupRouter.POST("/search", baseApi.SearchRuntimes) groupRouter.POST("", baseApi.CreateRuntime) groupRouter.POST("/del", baseApi.DeleteRuntime) diff --git a/frontend/src/api/modules/runtime.ts b/frontend/src/api/modules/runtime.ts index 792bf44b8..2f6dd775f 100644 --- a/frontend/src/api/modules/runtime.ts +++ b/frontend/src/api/modules/runtime.ts @@ -2,6 +2,7 @@ import http from '@/api'; import { ResPage, ReqPage } from '../interface'; import { Runtime } from '../interface/runtime'; import { TimeoutEnum } from '@/enums/http-enum'; +import { App } from '@/api/interface/app'; export const SearchRuntimes = (req: Runtime.RuntimeReq) => { return http.post>(`/runtimes/search`, req); @@ -15,6 +16,10 @@ export const DeleteRuntime = (req: Runtime.RuntimeDelete) => { return http.post(`/runtimes/del`, req); }; +export const RuntimeDeleteCheck = (runTimeId: number) => { + return http.get(`runtimes/installed/delete/check/${runTimeId}`); +}; + export const GetRuntime = (id: number) => { return http.get(`/runtimes/${id}`); }; diff --git a/frontend/src/views/website/runtime/node/index.vue b/frontend/src/views/website/runtime/node/index.vue index 59e548b19..b2cc9f81f 100644 --- a/frontend/src/views/website/runtime/node/index.vue +++ b/frontend/src/views/website/runtime/node/index.vue @@ -84,13 +84,14 @@ + + + diff --git a/frontend/src/views/website/runtime/php/index.vue b/frontend/src/views/website/runtime/php/index.vue index 21462e897..007db060d 100644 --- a/frontend/src/views/website/runtime/php/index.vue +++ b/frontend/src/views/website/runtime/php/index.vue @@ -79,13 +79,14 @@ +