From 96844c22ef3fba86a55e0af1b51bc1009d6fa950 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期五, 20 十月 2023 11:57:48 +0800 Subject: [PATCH] 1.库存盘点bug修改 --- controllers/location.go | 34 +++++++++++++++++++++++++++++++--- 1 files changed, 31 insertions(+), 3 deletions(-) diff --git a/controllers/location.go b/controllers/location.go index 682c1f0..e545fb9 100644 --- a/controllers/location.go +++ b/controllers/location.go @@ -30,6 +30,18 @@ util.ResponseFormat(c, code.RequestParamError, err) return } + if params.ParentId != 0 { + //鏌ヨ涓婄骇鍚嶇О + first, err := models.NewLocationSearch().SetID(params.ParentId).First() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏌ヨ涓婄骇鍚嶇О澶辫触") + return + } + params.JointName = first.JointName + "/" + params.Name + } else { + params.JointName = params.Name + } + err := models.NewLocationSearch().Create(¶ms) if err != nil { util.ResponseFormat(c, code.RequestParamError, "鍒涘缓澶辫触") @@ -59,9 +71,6 @@ if err != nil { util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") return - } - for _, location := range list { - location.JointName = location.ParentId + "/" + location.Name } util.ResponseFormatList(c, code.Success, list, int(total)) @@ -105,6 +114,25 @@ util.ResponseFormat(c, code.RequestParamError, err) return } + //index := strings.LastIndex(params.JointName, "/") + //if index > 0 { + // jn := params.JointName[:index] + // oldName := params.JointName[index+1:] + // if oldName != params.Name { + // params.JointName = jn + "/" + params.Name + // } + //} + if params.ParentId != 0 { + //鏌ヨ涓婄骇鍚嶇О + first, err := models.NewLocationSearch().SetID(params.ParentId).First() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏌ヨ涓婄骇鍚嶇О澶辫触") + return + } + params.JointName = first.JointName + "/" + params.Name + } else { + params.JointName = params.Name + } err := models.NewLocationSearch().Update(¶ms) if err != nil { util.ResponseFormat(c, code.RequestParamError, "浣嶇疆淇℃伅鏇存柊澶辫触") -- Gitblit v1.8.0