diff --git a/agent/app/api/v2/runtime.go b/agent/app/api/v2/runtime.go index 64c8b3b22..b69cd41fd 100644 --- a/agent/app/api/v2/runtime.go +++ b/agent/app/api/v2/runtime.go @@ -61,13 +61,14 @@ func (b *BaseApi) CreateRuntime(c *gin.Context) { // @Security ApiKeyAuth // @Security Timestamp // @Router /runtimes/del [post] -// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除运行环境 [id]","formatEN":"Delete runtime [id]"} +// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"删除运行环境 [name]","formatEN":"Delete runtime [name]"} func (b *BaseApi) DeleteRuntime(c *gin.Context) { var req request.RuntimeDelete if err := helper.CheckBindAndValidate(&req, c); err != nil { return } - err := runtimeService.Delete(req) + name, err := runtimeService.Delete(req) + helper.SetOperationLogValues(c, map[string]string{"name": name}) if err != nil { helper.InternalServer(c, err) return diff --git a/agent/app/api/v2/website.go b/agent/app/api/v2/website.go index e9c8dd4ae..aa2bedb6e 100644 --- a/agent/app/api/v2/website.go +++ b/agent/app/api/v2/website.go @@ -402,7 +402,7 @@ func (b *BaseApi) ChangeDefaultServer(c *gin.Context) { // @Security ApiKeyAuth // @Security Timestamp // @Router /websites/php/version [post] -// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 版本变更 [domain]","formatEN":"php version update [domain]"} +// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteID","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 版本变更 [domain]","formatEN":"php version update [domain]"} func (b *BaseApi) ChangePHPVersion(c *gin.Context) { var req request.WebsitePHPVersionReq if err := helper.CheckBindAndValidate(&req, c); err != nil { diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index 3ea55cfaf..ec56add42 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -46,7 +46,7 @@ type RuntimeService struct { type IRuntimeService interface { Page(req request.RuntimeSearch) (int64, []response.RuntimeDTO, error) Create(create request.RuntimeCreate) (*model.Runtime, error) - Delete(delete request.RuntimeDelete) error + Delete(delete request.RuntimeDelete) (string, error) Update(req request.RuntimeUpdate) error Get(id uint) (res *response.RuntimeDTO, err error) GetNodePackageRunScript(req request.NodePackageReq) ([]response.PackageScripts, error) @@ -376,16 +376,16 @@ func (r *RuntimeService) DeleteCheck(runTimeId uint) ([]dto.AppResource, error) return res, nil } -func (r *RuntimeService) Delete(runtimeDelete request.RuntimeDelete) error { +func (r *RuntimeService) Delete(runtimeDelete request.RuntimeDelete) (string, error) { runtime, err := runtimeRepo.GetFirst(context.Background(), repo.WithByID(runtimeDelete.ID)) if err != nil { - return err + return "", err } website, _ := websiteRepo.GetFirst(websiteRepo.WithRuntimeID(runtimeDelete.ID)) if website.ID > 0 { - return buserr.New("ErrDelWithWebsite") + return runtime.Name, buserr.New("ErrDelWithWebsite") } - return startRuntimeDeleteTask(runtimeDelete, runtime) + return runtime.Name, startRuntimeDeleteTask(runtimeDelete, runtime) } func startRuntimeDeleteTask(runtimeDelete request.RuntimeDelete, runtime *model.Runtime) error { diff --git a/agent/cmd/server/docs/x-log.json b/agent/cmd/server/docs/x-log.json index 8da7eeb69..4a8b242c4 100644 --- a/agent/cmd/server/docs/x-log.json +++ b/agent/cmd/server/docs/x-log.json @@ -3740,13 +3740,11 @@ "formatEN": "Create runtime [name]" }, "/runtimes/del": { - "bodyKeys": [ - "id" - ], + "bodyKeys": [], "paramKeys": [], "beforeFunctions": [], - "formatZH": "删除运行环境 [id]", - "formatEN": "Delete runtime [id]" + "formatZH": "删除运行环境 [name]", + "formatEN": "Delete runtime [name]" }, "/runtimes/operate": { "bodyKeys": [ @@ -4582,13 +4580,13 @@ }, "/websites/php/version": { "bodyKeys": [ - "websiteId" + "websiteID" ], "paramKeys": [], "beforeFunctions": [ { "input_column": "id", - "input_value": "websiteId", + "input_value": "websiteID", "isList": false, "db": "websites", "output_column": "primary_domain", diff --git a/core/cmd/server/docs/docs.go b/core/cmd/server/docs/docs.go index def903419..f44b2d529 100644 --- a/core/cmd/server/docs/docs.go +++ b/core/cmd/server/docs/docs.go @@ -21983,11 +21983,9 @@ const docTemplate = `{ ], "x-panel-log": { "BeforeFunctions": [], - "bodyKeys": [ - "id" - ], - "formatEN": "Delete runtime [id]", - "formatZH": "删除运行环境 [id]", + "bodyKeys": [], + "formatEN": "Delete runtime [name]", + "formatZH": "删除运行环境 [name]", "paramKeys": [] } } @@ -28072,14 +28070,14 @@ const docTemplate = `{ { "db": "websites", "input_column": "id", - "input_value": "websiteId", + "input_value": "websiteID", "isList": false, "output_column": "primary_domain", "output_value": "domain" } ], "bodyKeys": [ - "websiteId" + "websiteID" ], "formatEN": "php version update [domain]", "formatZH": "php 版本变更 [domain]", diff --git a/core/cmd/server/docs/swagger.json b/core/cmd/server/docs/swagger.json index 254f8cb10..754045061 100644 --- a/core/cmd/server/docs/swagger.json +++ b/core/cmd/server/docs/swagger.json @@ -21979,11 +21979,9 @@ ], "x-panel-log": { "BeforeFunctions": [], - "bodyKeys": [ - "id" - ], - "formatEN": "Delete runtime [id]", - "formatZH": "删除运行环境 [id]", + "bodyKeys": [], + "formatEN": "Delete runtime [name]", + "formatZH": "删除运行环境 [name]", "paramKeys": [] } } @@ -28068,14 +28066,14 @@ { "db": "websites", "input_column": "id", - "input_value": "websiteId", + "input_value": "websiteID", "isList": false, "output_column": "primary_domain", "output_value": "domain" } ], "bodyKeys": [ - "websiteId" + "websiteID" ], "formatEN": "php version update [domain]", "formatZH": "php 版本变更 [domain]", diff --git a/core/cmd/server/docs/x-log.json b/core/cmd/server/docs/x-log.json index 8da7eeb69..4a8b242c4 100644 --- a/core/cmd/server/docs/x-log.json +++ b/core/cmd/server/docs/x-log.json @@ -3740,13 +3740,11 @@ "formatEN": "Create runtime [name]" }, "/runtimes/del": { - "bodyKeys": [ - "id" - ], + "bodyKeys": [], "paramKeys": [], "beforeFunctions": [], - "formatZH": "删除运行环境 [id]", - "formatEN": "Delete runtime [id]" + "formatZH": "删除运行环境 [name]", + "formatEN": "Delete runtime [name]" }, "/runtimes/operate": { "bodyKeys": [ @@ -4582,13 +4580,13 @@ }, "/websites/php/version": { "bodyKeys": [ - "websiteId" + "websiteID" ], "paramKeys": [], "beforeFunctions": [ { "input_column": "id", - "input_value": "websiteId", + "input_value": "websiteID", "isList": false, "db": "websites", "output_column": "primary_domain",