f
This commit is contained in:
@@ -52,6 +52,22 @@ func (r *GormSubordinateRepository) FindInvitationByTokenHash(ctx context.Contex
|
||||
return &inv, nil
|
||||
}
|
||||
|
||||
// FindActiveInvitationByParent 查询主账号当前可用的固定邀请码(pending 且未过期)
|
||||
func (r *GormSubordinateRepository) FindActiveInvitationByParent(ctx context.Context, parentUserID string) (*entities.SubordinateInvitation, error) {
|
||||
var inv entities.SubordinateInvitation
|
||||
err := r.withCtx(ctx).
|
||||
Where("parent_user_id = ? AND status = ? AND expires_at > ?", parentUserID, entities.InvitationStatusPending, time.Now()).
|
||||
Order("created_at ASC").
|
||||
First(&inv).Error
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &inv, nil
|
||||
}
|
||||
|
||||
// FindInvitationByID 按ID
|
||||
func (r *GormSubordinateRepository) FindInvitationByID(ctx context.Context, id string) (*entities.SubordinateInvitation, error) {
|
||||
var inv entities.SubordinateInvitation
|
||||
|
||||
Reference in New Issue
Block a user