Merge remote-tracking branch 'origin/dev/guerby' into dev/cedric
This commit is contained in:
@@ -3,6 +3,7 @@ module fr.latosa-escrima
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
|
||||
75
backend/schemas.go
Normal file
75
backend/schemas.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user