diff --git a/db/dbs_user.go b/db/dbs_user.go index 4c9dd15..f81a095 100644 --- a/db/dbs_user.go +++ b/db/dbs_user.go @@ -32,6 +32,21 @@ func DbsUserRelate(eg *xorm.Engine, uid, level int) (*[]model.UserRelate, error) return &userRelate, nil } +func DbsUserRelateByParentUid(eg *xorm.Engine, uid, level int) (*[]model.UserRelate, error) { + var userRelate []model.UserRelate + sess := eg.Where("parent_uid = ?", uid) + if level > 0 { + sess.And("level<=?", level) + } + if err := sess.Asc("level").Find(&userRelate); err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if len(userRelate) == 0 { + return nil, nil + } + return &userRelate, nil +} + func SumUserRelateByParentUid(eg *xorm.Engine, parentUid string) (total int64, userRelate []*model.UserRelate, err error) { total, err = eg.Where("parent_uid = ?", parentUid).FindAndCount(&userRelate) return