76 lines
2.1 KiB
Go
76 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"github.com/uptrace/bun"
|
|
"time"
|
|
)
|
|
|
|
type Role string
|
|
|
|
const (
|
|
AdminRole Role = "admin"
|
|
UserRole Role = "user"
|
|
)
|
|
|
|
type User struct {
|
|
bun.BaseModel `bun:"table:users"`
|
|
|
|
ID uuid.UUID `bun:"type:uuid,pk,default:gen_random_uuid()"`
|
|
FirstName string `bun:"firstname,notnull"`
|
|
LastName string `bun:"lastname,notnull"`
|
|
Email string `bun:"email,unique,notnull"`
|
|
Phone string `bun:"phone,notnull"`
|
|
Role Role `bun:"role,notnull,default:'user'"`
|
|
CreatedAt time.Time `bun:"created_at,default:current_timestamp"`
|
|
UpdatedAt time.Time `bun:"updated_at,default:current_timestamp"`
|
|
}
|
|
|
|
type Event struct {
|
|
bun.BaseModel `bun:"table:events"`
|
|
|
|
EventID uuid.UUID `bun:"type:uuid,pk"`
|
|
CreationDate time.Time `bun:"creation_date,notnull,default:current_timestamp"`
|
|
ScheduleStart time.Time `bun:"schedule_start,notnull"`
|
|
ScheduleEnd time.Time `bun:"schedule_end,notnull"`
|
|
Status string `bun:"status,notnull"`
|
|
}
|
|
|
|
type EventsToUsers struct {
|
|
bun.BaseModel `bun:"table:events_to_users"`
|
|
|
|
EventID uuid.UUID `bun:"type:uuid,notnull"`
|
|
UserID uuid.UUID `bun:"type:uuid,notnull"`
|
|
|
|
Event *Event `bun:"rel:belongs_to,join:event_id=event_id"`
|
|
User *User `bun:"rel:belongs_to,join:user_id=user_id"`
|
|
|
|
PrimaryKey struct {
|
|
EventID uuid.UUID `bun:"pk"`
|
|
UserID uuid.UUID `bun:"pk"`
|
|
}
|
|
}
|
|
|
|
type Blog struct {
|
|
bun.BaseModel `bun:"table:blogs"`
|
|
|
|
UUID uuid.UUID `bun:"type:uuid,pk"`
|
|
Slug string `bun:"slug,unique,notnull"`
|
|
Content string `bun:"content,notnull"`
|
|
Label string `bun:"label"`
|
|
AuthorID uuid.UUID `bun:"author,notnull"`
|
|
Published time.Time `bun:"published,default:current_timestamp"`
|
|
Summary string `bun:"summary"`
|
|
Image string `bun:"image"`
|
|
Href string `bun:"href"`
|
|
|
|
Author *User `bun:"rel:belongs_to,join:author=author_id"`
|
|
}
|
|
|
|
type WebsiteSettings struct {
|
|
bun.BaseModel `bun:"table:website_settings"`
|
|
|
|
ID uuid.UUID `bun:"type:uuid,pk,default:gen_random_uuid()"`
|
|
AutoAcceptDemand bool `bun:"auto_accept_demand,default:false"`
|
|
}
|