From 8f713c0eda54810867c8e372a148b59201a04069 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 10 Oct 2023 22:22:29 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20node.js=20=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E7=8E=AF=E5=A2=83=E6=A8=A1=E5=9D=97=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#2498)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/runtime.go | 2 +- backend/app/dto/request/runtime.go | 6 +++++- backend/app/service/runtime.go | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/app/api/v1/runtime.go b/backend/app/api/v1/runtime.go index 8b4887e0c..0d87e1c53 100644 --- a/backend/app/api/v1/runtime.go +++ b/backend/app/api/v1/runtime.go @@ -191,7 +191,7 @@ func (b *BaseApi) GetNodeModules(c *gin.Context) { // @Security ApiKeyAuth // @Router /runtimes/node/modules/operate [post] func (b *BaseApi) OperateNodeModules(c *gin.Context) { - var req request.NodeModuleReq + var req request.NodeModuleOperateReq if err := helper.CheckBindAndValidate(&req, c); err != nil { return } diff --git a/backend/app/dto/request/runtime.go b/backend/app/dto/request/runtime.go index e171b70c1..32469d990 100644 --- a/backend/app/dto/request/runtime.go +++ b/backend/app/dto/request/runtime.go @@ -54,9 +54,13 @@ type RuntimeOperate struct { ID uint `json:"ID"` } -type NodeModuleReq struct { +type NodeModuleOperateReq struct { Operate string `json:"operate" validate:"oneof=install uninstall update"` ID uint `json:"ID" validate:"required"` Module string `json:"module"` PkgManager string `json:"pkgManager" validate:"oneof=npm yarn"` } + +type NodeModuleReq struct { + ID uint `json:"ID" validate:"required"` +} diff --git a/backend/app/service/runtime.go b/backend/app/service/runtime.go index d8e963f69..98ec6133b 100644 --- a/backend/app/service/runtime.go +++ b/backend/app/service/runtime.go @@ -37,7 +37,7 @@ type IRuntimeService interface { GetNodePackageRunScript(req request.NodePackageReq) ([]response.PackageScripts, error) OperateRuntime(req request.RuntimeOperate) error GetNodeModules(req request.NodeModuleReq) ([]response.NodeModule, error) - OperateNodeModules(req request.NodeModuleReq) error + OperateNodeModules(req request.NodeModuleOperateReq) error } func NewRuntimeService() IRuntimeService { @@ -482,7 +482,7 @@ func (r *RuntimeService) GetNodeModules(req request.NodeModuleReq) ([]response.N return res, nil } -func (r *RuntimeService) OperateNodeModules(req request.NodeModuleReq) error { +func (r *RuntimeService) OperateNodeModules(req request.NodeModuleOperateReq) error { runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) if err != nil { return err