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 | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/controllers/operation_type.go b/controllers/operation_type.go index 7246617..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,7 +117,22 @@ util.ResponseFormat(c, code.RequestParamError, err.Error()) return } - list, total, err := models.NewOperationTypeSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find() + 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(warehouseIds). + SetPreload(true).Find() if err != nil { util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触") return @@ -142,7 +158,7 @@ list[k].FinishCount = value.Count } if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Cancel)]; ok { - list[k].FinishCount = value.Count + list[k].CancelCount = value.Count } } util.ResponseFormatListWithPage(c, code.Success, list, cast.ToInt(total), params.Page, params.PageSize) -- Gitblit v1.8.0