feat: mid
This commit is contained in:
@@ -194,3 +194,17 @@ func (svc *Service) CreateTenantUser(ctx context.Context, userID, tenantID int64
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTenantIDBySlug
|
||||
func (svc *Service) GetTenantIDBySlug(ctx context.Context, slug string) (int64, error) {
|
||||
log := svc.log.WithField("method", "GetTenantIDBySlug")
|
||||
|
||||
stmt := table.Tenants.SELECT(table.Tenants.ID).WHERE(table.Tenants.Slug.EQ(String(slug)))
|
||||
log.Debug(stmt.DebugSql())
|
||||
|
||||
var id int64
|
||||
if err := stmt.QueryContext(ctx, db.FromContext(ctx, svc.db), &id); err != nil {
|
||||
return 0, errors.Wrap(err, "failed to query tenant id by slug")
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user