|
|
@@ -15,6 +15,43 @@ type UserRelateDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserRelateDb) UserRelatesByPuid(puid interface{}, limit, start int) (*[]model.UserRelate, error) { |
|
|
|
var m []model.UserRelate |
|
|
|
if limit == 0 && start == 0 { |
|
|
|
if err := u.Db.Where("parent_uid = ?", puid). |
|
|
|
Cols(`id,parent_uid,uid,level,invite_time`). |
|
|
|
Find(&m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Warn(err) |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
if err := u.Db.Where("parent_uid = ?", puid). |
|
|
|
Cols(`id,parent_uid,uid,level,invite_time`).Limit(limit, start). |
|
|
|
Find(&m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Warn(err) |
|
|
|
} |
|
|
|
|
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserRelateDb) UserRelatesByPuIDAndLv(puid, lv interface{}) (*[]model.UserRelate, error) { |
|
|
|
var m []model.UserRelate |
|
|
|
if err := u.Db.Where("parent_uid = ? AND level = ?", puid, lv). |
|
|
|
Cols(`id,parent_uid,uid,level,invite_time`). |
|
|
|
Find(&m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Warn(err) |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserRelateDb) UserRelateInsert(userRelate *model.UserRelate) (int64, error) { |
|
|
|
affected, err := u.Db.Insert(userRelate) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserRelateDb) FindUserRelate(uid int64, level int) (*[]model.UserRelate, error) { |
|
|
|
var userRelate []model.UserRelate |
|
|
|
sess := u.Db.Where("uid = ?", uid) |
|
|
|