feat:完善项目
This commit is contained in:
@ -17,6 +17,7 @@ type (
|
||||
InstanceInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.SysMenu
|
||||
ParentID string `json:"parent_id"`
|
||||
Children []*InstanceInfo `json:"children"`
|
||||
}
|
||||
// InstanceIdentityInfo 多个身份菜单信息
|
||||
@ -37,15 +38,22 @@ type (
|
||||
)
|
||||
|
||||
// tree 树状筛选
|
||||
func (c *Instance) tree(src []*model2.SysMenu, parentID uint64) []*InstanceInfo {
|
||||
func (c *Instance) tree(iModel model2.IModel, src []*model2.SysMenu, parentID uint64) []*InstanceInfo {
|
||||
out := make([]*InstanceInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
parentID := "0"
|
||||
|
||||
if v.ParentID > 0 {
|
||||
iModel.SetID(v.ParentID)
|
||||
parentID = iModel.GetEncodeID()
|
||||
}
|
||||
out = append(out, &InstanceInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ParentID: parentID,
|
||||
SysMenu: v,
|
||||
Children: c.tree(src, v.ID),
|
||||
Children: c.tree(iModel, src, v.ID),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -79,7 +87,7 @@ func (c *Instance) List() ([]*InstanceInfo, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.tree(out, 0), nil
|
||||
return c.tree(mSysMenu.SysMenu, out, 0), nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
@ -96,7 +104,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
},
|
||||
Auth: model2.SysMenuAuth(params.Auth),
|
||||
Sort: params.Sort,
|
||||
Status: model2.SysMenuStatusForNormal,
|
||||
Status: model2.SysMenuStatus(params.Status),
|
||||
Remark: params.Remark,
|
||||
})
|
||||
}
|
||||
@ -121,7 +129,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
||||
out.Status = model2.SysMenuStatus(params.Status)
|
||||
out.Remark = params.Remark
|
||||
|
||||
if err = model2.Save(out); err != nil {
|
||||
if err = model2.Save(out.SysMenu); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user