f1909da1ad
Go CI / build (push) Failing after 2m42s
feat: create basic server to manage google oauth, account, sessions, places, attributes and ratings.
78 lines
1.9 KiB
Go
78 lines
1.9 KiB
Go
package models
|
|
|
|
type RoleType int
|
|
|
|
const (
|
|
ADMIN RoleType = iota
|
|
TRUSTED
|
|
USER
|
|
)
|
|
|
|
// User represents an authenticated user.
|
|
type User struct {
|
|
ID string `json:"id"` // e.g., "user-google-123"
|
|
GoogleID string `json:"googleId"`
|
|
DisplayName string `json:"displayName"`
|
|
Email string `json:"email"`
|
|
Role RoleType `json:"role"`
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|
|
|
|
type Session struct {
|
|
ID string `json:"id"`
|
|
UserID string `json:"userId"`
|
|
CreatedAt string `json:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt"`
|
|
}
|
|
|
|
// Place represents a physical location.
|
|
type Place struct {
|
|
ID string `json:"id"` // e.g., "place-001"
|
|
Name string `json:"name"`
|
|
Category string `json:"category"` // e.g., "Restaurant"
|
|
Address Address `json:"address"`
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|
|
|
|
// Address is a sub-struct for Place.
|
|
type Address struct {
|
|
Street string `json:"street"`
|
|
City string `json:"city"`
|
|
State string `json:"state"`
|
|
Zip string `json:"zip"`
|
|
Country string `json:"country"`
|
|
}
|
|
|
|
type Category struct {
|
|
ID string `json:"category"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type ScopeType int
|
|
|
|
const (
|
|
CATEGORY ScopeType = iota
|
|
PLACE
|
|
)
|
|
|
|
// Attribute defines a "thing" that can be rated, with a specific scope.
|
|
type Attribute struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Scope ScopeType `json:"scope"`
|
|
OwnerID string `json:"ownerID,omitempty"`
|
|
Description string `json:"description,omitempty"`
|
|
Attachment string `json:"attachment,omitempty"`
|
|
}
|
|
|
|
// Rating is the central record linking a user, place, and attribute.
|
|
type Rating struct {
|
|
ID string `json:"id"`
|
|
PlaceID string `json:"placeId"`
|
|
AttributeID string `json:"attributeId"`
|
|
UserID string `json:"userId"`
|
|
Score int `json:"score"` // 1-10
|
|
Comment string `json:"comment,omitempty"`
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|