feat: portal tenant apply flow
This commit is contained in:
@@ -842,6 +842,19 @@ func (t *tenant) FindByCode(ctx context.Context, code string) (*models.Tenant, e
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
// FindOwnedByUserID 查询用户创建/拥有的租户(一个用户仅允许拥有一个租户)。
|
||||
func (t *tenant) FindOwnedByUserID(ctx context.Context, userID int64) (*models.Tenant, error) {
|
||||
if userID <= 0 {
|
||||
return nil, errors.New("user_id must be > 0")
|
||||
}
|
||||
tbl, query := models.TenantQuery.QueryContext(ctx)
|
||||
m, err := query.Where(tbl.UserID.Eq(userID)).Order(tbl.ID.Desc()).First()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "find owned tenant failed, user_id: %d", userID)
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (t *tenant) FindTenantUser(ctx context.Context, tenantID, userID int64) (*models.TenantUser, error) {
|
||||
logrus.WithField("tenant_id", tenantID).WithField("user_id", userID).Info("find tenant user")
|
||||
tbl, query := models.TenantUserQuery.QueryContext(ctx)
|
||||
|
||||
@@ -52,10 +52,10 @@ func (s *TenantJoinTestSuite) truncateAll(ctx context.Context) {
|
||||
), ShouldBeNil)
|
||||
}
|
||||
|
||||
func (s *TenantJoinTestSuite) seedInvite(ctx context.Context, tenantID, creatorUserID int64, code string, status consts.TenantInviteStatus, maxUses, usedCount int32, expiresAt time.Time) *models.TenantInvite {
|
||||
func (s *TenantJoinTestSuite) seedInvite(ctx context.Context, tenantID, inviterUserID int64, code string, status consts.TenantInviteStatus, maxUses, usedCount int32, expiresAt time.Time) *models.TenantInvite {
|
||||
inv := &models.TenantInvite{
|
||||
TenantID: tenantID,
|
||||
UserID: creatorUserID,
|
||||
UserID: inviterUserID,
|
||||
Code: code,
|
||||
Status: status,
|
||||
MaxUses: maxUses,
|
||||
|
||||
Reference in New Issue
Block a user