feat:完善项目
This commit is contained in:
@ -15,8 +15,10 @@ type InstanceHandle func(session *service.Session) *Instance
|
||||
type (
|
||||
// InstanceInfo 租户信息
|
||||
InstanceInfo struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"id"`
|
||||
ParentID string `json:"parent_id"`
|
||||
Name string `json:"name"`
|
||||
*model2.Area
|
||||
*model2.AreaInfo
|
||||
Remark string `json:"remark"`
|
||||
Children []*InstanceInfo `json:"children"`
|
||||
@ -29,17 +31,20 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Instance) tree(src []*model2.SysTenant, parentID uint64) []*InstanceInfo {
|
||||
func (c *Instance) tree(iModel model2.IModel, src []*model2.SysTenant, parentID uint64) []*InstanceInfo {
|
||||
out := make([]*InstanceInfo, 0)
|
||||
|
||||
for _, v := range src {
|
||||
if v.ParentID == parentID {
|
||||
iModel.SetID(v.ParentID)
|
||||
out = append(out, &InstanceInfo{
|
||||
ID: v.GetEncodeID(),
|
||||
ParentID: iModel.GetEncodeID(),
|
||||
Name: v.Name,
|
||||
Area: &v.Area,
|
||||
AreaInfo: v.Area.Format(),
|
||||
Remark: v.Remark,
|
||||
Children: c.tree(src, v.ID),
|
||||
Children: c.tree(iModel, src, v.ID),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -55,7 +60,7 @@ func (c *Instance) List() ([]*InstanceInfo, error) {
|
||||
if err := model2.Find(mSysTenant.SysTenant, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.tree(out, 0), nil
|
||||
return c.tree(mSysTenant.SysTenant, out, 0), nil
|
||||
}
|
||||
|
||||
// Form 数据操作
|
||||
|
Reference in New Issue
Block a user