From c3bb36c9698b177996e40ec8ef334832f1b2355c Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Tue, 23 Feb 2021 17:44:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=F0=9F=90=9B=20=EF=BC=9A=E9=83=A8=E9=97=A8pa?= =?UTF-8?q?th=E5=88=9B=E5=BB=BA=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/sys_dept.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/admin/service/sys_dept.go b/app/admin/service/sys_dept.go index 5078c04e..e4b8c031 100644 --- a/app/admin/service/sys_dept.go +++ b/app/admin/service/sys_dept.go @@ -7,6 +7,7 @@ import ( cDto "go-admin/common/dto" "go-admin/common/log" "go-admin/common/service" + "go-admin/tools" "gorm.io/gorm" ) @@ -65,6 +66,20 @@ func (e *SysDept) InsertSysDept(model *models.SysDept) error { log.Errorf("msgID[%s] db error:%s", msgID, err) return err } + deptPath := "/" + tools.IntToString(model.DeptId) + if model.ParentId != 0 { + var deptP models.SysDepts + e.Orm.Model(&data).First(&deptP, model.ParentId) + deptPath = deptP.DeptPath + deptPath + } else { + deptPath = "/0" + deptPath + } + var mp = map[string]string{} + mp["dept_path"] = deptPath + if err := e.Orm.Model(&model).Update("dept_path",deptPath).Error; err != nil { + log.Errorf("msgID[%s] db error:%s", msgID, err) + return err + } return nil } @@ -82,8 +97,11 @@ func (e *SysDept) UpdateSysDept(c *models.SysDept) error { } if db.RowsAffected == 0 { return errors.New("无权更新该数据") - } + + //参数1:是要修改的数据 + //参数2:是修改的数据 + return nil }