From a21d2184eae304ae80f32353c8a49b64a7618d22 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期四, 28 九月 2023 11:30:40 +0800 Subject: [PATCH] 1.改名 --- controllers/location.go | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/controllers/location.go b/controllers/location.go index 595a2ba..5785eb6 100644 --- a/controllers/location.go +++ b/controllers/location.go @@ -4,6 +4,7 @@ "errors" "github.com/gin-gonic/gin" "strconv" + "strings" "wms/extend/code" "wms/extend/util" "wms/models" @@ -30,6 +31,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, "鍒涘缓澶辫触") @@ -102,6 +115,14 @@ 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 + } + } err := models.NewLocationSearch().Update(¶ms) if err != nil { util.ResponseFormat(c, code.RequestParamError, "浣嶇疆淇℃伅鏇存柊澶辫触") -- Gitblit v1.8.0