|
|
@@ -1,4 +1,4 @@ |
|
|
|
package implement |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
@@ -120,60 +120,6 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFindByParamsByPage |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFind(uid int64) ([]*model.PublicPlatoonUserRelation, error) { |
|
|
|
var head model.PublicPlatoonUserRelation |
|
|
|
if uid != 0 { |
|
|
|
has, err1 := p.Db.Where("uid = ?", uid).Get(&head) |
|
|
|
if err1 != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err1) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, zhios_order_relate_logx.Error("未查询到数据") |
|
|
|
} |
|
|
|
} else { |
|
|
|
has, err2 := p.Db.Where("level_total = ?", 1).Get(&head) |
|
|
|
if err2 != nil { |
|
|
|
return nil, err2 |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, zhios_order_relate_logx.Error("未查询到数据") |
|
|
|
} |
|
|
|
} |
|
|
|
relations, err3 := p.GetTreeBySmall(&head, 3) |
|
|
|
if err3 != nil { |
|
|
|
return nil, err3 |
|
|
|
} |
|
|
|
return relations, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFindByUid(uid int64) ([]*model.PublicPlatoonUserRelation, error) { |
|
|
|
var head model.PublicPlatoonUserRelation |
|
|
|
has, err1 := p.Db.Where("uid = ?", uid).Get(&head) |
|
|
|
if err1 != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err1) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, zhios_order_relate_logx.Error("未查询到数据") |
|
|
|
} |
|
|
|
relations, err3 := p.GetTreeBySmall(&head, 0) |
|
|
|
if err3 != nil { |
|
|
|
return nil, err3 |
|
|
|
} |
|
|
|
return relations, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByUid(uid int64) (*model.PublicPlatoonUserRelation, error) { |
|
|
|
var parent model.PublicPlatoonUserRelation |
|
|
|
has, err := p.Db.Where("uid = ?", uid).Get(&parent) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, zhios_order_relate_logx.Error("未查询到上级用户公排记录") |
|
|
|
} |
|
|
|
return &parent, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) { |
|
|
|
var relation model.PublicPlatoonUserRelation |
|
|
|
_, err := p.Db.Where("position = ?", position).Get(&relation) |
|
|
@@ -193,12 +139,12 @@ func (p PublicPlatoonUserRelationDb) GetTreeBySmall(head *model.PublicPlatoonUse |
|
|
|
for len(queue) > 0 { |
|
|
|
node := queue[0] |
|
|
|
queue = queue[1:] |
|
|
|
if node.LevelTotal > head.LevelTotal+leveLimit { |
|
|
|
if node.Level1 > head.Level1+leveLimit { |
|
|
|
break |
|
|
|
} |
|
|
|
res = append(res, node) |
|
|
|
var son []*model.PublicPlatoonUserRelation |
|
|
|
err1 := p.Db.Where("father_uid1 = ?", node.Uid).Find(&son) |
|
|
|
err1 := p.Db.Where("father_uid1 = ?", node.Uid).Find(son) |
|
|
|
if err1 != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err1) |
|
|
|
} |
|
|
|