From f4508a84236a4aff1c7b5bfa17a14a8ff95728ba Mon Sep 17 00:00:00 2001 From: yinbentan <yinbentan@live.com> Date: 星期一, 08 七月 2024 09:45:10 +0800 Subject: [PATCH] 接口调用报错处理 --- controllers/operation_type.go | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/controllers/operation_type.go b/controllers/operation_type.go index 247562f..cf07e2f 100644 --- a/controllers/operation_type.go +++ b/controllers/operation_type.go @@ -7,6 +7,7 @@ "github.com/spf13/cast" "gorm.io/gorm" "strconv" + "strings" "wms/constvar" "wms/extend/code" "wms/extend/util" @@ -116,11 +117,21 @@ util.ResponseFormat(c, code.RequestParamError, err.Error()) return } + warehouseIds := make([]int, 0) + if "" != params.WarehouseIds { + for _, strId := range strings.Split(params.WarehouseIds, ",") { + intId, err := strconv.Atoi(strId) + if err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + } + warehouseIds = append(warehouseIds, intId) + } + } list, total, err := models.NewOperationTypeSearch(). SetPage(params.Page, params.PageSize). SetKeyword(params.Keyword). SetOrder("id desc"). - SetWarehouseIds(params.WarehouseIds). + SetWarehouseIds(warehouseIds). SetPreload(true).Find() if err != nil { util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触") -- Gitblit v1.8.0