diff --git a/src/dao/public_platoon_user_relation_dao.go b/src/dao/public_platoon_user_relation_dao.go index c1eb8f1..745e81e 100644 --- a/src/dao/public_platoon_user_relation_dao.go +++ b/src/dao/public_platoon_user_relation_dao.go @@ -16,4 +16,5 @@ type PublicPlatoonUserRelationDao interface { PublicPlatoonUserRelationFind(uid int64) ([]*model.PublicPlatoonUserRelation, error) PublicPlatoonUserRelationFindByUid(uid int64) ([]*model.PublicPlatoonUserRelation, error) PublicPlatoonUserRelationGetOneByUid(uid int64) (*model.PublicPlatoonUserRelation, error) + PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) } diff --git a/src/implement/public_platoon_user_relation_implement.go b/src/implement/public_platoon_user_relation_implement.go index 5e34316..5c1a9fe 100644 --- a/src/implement/public_platoon_user_relation_implement.go +++ b/src/implement/public_platoon_user_relation_implement.go @@ -174,6 +174,15 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByUid(uid in return &parent, nil } +func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) { + var relation model.PublicPlatoonUserRelation + _, err := p.Db.Where("position = ?", position).Get(&relation) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return &relation, nil +} + func (p PublicPlatoonUserRelationDb) GetTreeBySmall(head *model.PublicPlatoonUserRelation, leveLimit int) ([]*model.PublicPlatoonUserRelation, error) { if leveLimit == 0 { leveLimit = 1 @@ -193,7 +202,7 @@ func (p PublicPlatoonUserRelationDb) GetTreeBySmall(head *model.PublicPlatoonUse if err1 != nil { return nil, zhios_order_relate_logx.Error(err1) } - res = append(res, son...) + queue = append(queue, son...) } return res, nil } diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index be675de..b144ab8 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -16,22 +16,22 @@ type UserDb struct { } func (p UserDb) UserGetOneByPhone(phone int) (*model.User, error) { - var user *model.User - has, err := p.Db.Where("phone = ?", phone).Get(user) + var user model.User + has, err := p.Db.Where("phone = ?", phone).Get(&user) if err != nil { return nil, zhios_order_relate_logx.Error(err) } if has == false { return nil, zhios_order_relate_logx.Error("未查询到相关用户记录") } - return user, nil + return &user, nil } func (p UserDb) UserGetOneById(id int64) (*model.User, error) { - var user *model.User - _, err := p.Db.Where("phones = ?", id).Get(&user) + var user model.User + _, err := p.Db.Where("id = ?", id).Get(&user) if err != nil { return nil, zhios_order_relate_logx.Error(err) } - return user, nil + return &user, nil }