fix🐛 :部门path创建初始化
This commit is contained in:
1 parent
da347e095f
commit
c3bb36c969
1 file changed
+19
-1
@@ -7,6 +7,7 @@ import (
|
|||||||
cDto "go-admin/common/dto"
|
cDto "go-admin/common/dto"
|
||||||
"go-admin/common/log"
|
"go-admin/common/log"
|
||||||
"go-admin/common/service"
|
"go-admin/common/service"
|
||||||
|
"go-admin/tools"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,6 +66,20 @@ func (e *SysDept) InsertSysDept(model *models.SysDept) error {
|
|||||||
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
||||||
return 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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,8 +97,11 @@ func (e *SysDept) UpdateSysDept(c *models.SysDept) error {
|
|||||||
}
|
}
|
||||||
if db.RowsAffected == 0 {
|
if db.RowsAffected == 0 {
|
||||||
return errors.New("无权更新该数据")
|
return errors.New("无权更新该数据")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//参数1:是要修改的数据
|
||||||
|
//参数2:是修改的数据
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user