de30497f59
- Implemented tenant and user management features including: - Tenant creation and management with associated migrations. - User creation and management with associated migrations. - Tenant membership management with associated migrations. - Platform user roles management with associated migrations. - Quota management with associated migrations. - Article and template management with associated migrations. - Added HTTP handlers for templates and workspaces. - Created tests for protected and public routes. - Introduced a script to check tenant scope in SQL queries. - Documented task plan for backend completion and frontend foundation.
65 lines
1.1 KiB
Go
65 lines
1.1 KiB
Go
package repository
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
|
|
"github.com/geo-platform/tenant-api/internal/tenant/repository/generated"
|
|
)
|
|
|
|
func newQuerier(db generated.DBTX) generated.Querier {
|
|
return generated.New(db)
|
|
}
|
|
|
|
func nullableText(value pgtype.Text) *string {
|
|
if !value.Valid {
|
|
return nil
|
|
}
|
|
text := value.String
|
|
return &text
|
|
}
|
|
|
|
func nullableInt64(value pgtype.Int8) *int64 {
|
|
if !value.Valid {
|
|
return nil
|
|
}
|
|
number := value.Int64
|
|
return &number
|
|
}
|
|
|
|
func intFromInt4(value pgtype.Int4) int {
|
|
if !value.Valid {
|
|
return 0
|
|
}
|
|
return int(value.Int32)
|
|
}
|
|
|
|
func timeFromTimestamp(value pgtype.Timestamptz) time.Time {
|
|
if !value.Valid {
|
|
return time.Time{}
|
|
}
|
|
return value.Time
|
|
}
|
|
|
|
func pgText(value *string) pgtype.Text {
|
|
if value == nil {
|
|
return pgtype.Text{}
|
|
}
|
|
return pgtype.Text{String: *value, Valid: true}
|
|
}
|
|
|
|
func pgInt8(value *int64) pgtype.Int8 {
|
|
if value == nil {
|
|
return pgtype.Int8{}
|
|
}
|
|
return pgtype.Int8{Int64: *value, Valid: true}
|
|
}
|
|
|
|
func pgTimestamp(value *time.Time) pgtype.Timestamptz {
|
|
if value == nil {
|
|
return pgtype.Timestamptz{}
|
|
}
|
|
return pgtype.Timestamptz{Time: *value, Valid: true}
|
|
}
|