Added some routes for users

And some fixes
This commit is contained in:
cdricms
2025-01-16 10:51:30 +01:00
parent fee9a237c4
commit 9a6e4a7565
7 changed files with 173 additions and 41 deletions

View File

@@ -36,17 +36,17 @@ const (
type User struct {
bun.BaseModel `bun:"table:users"`
UserID 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"`
Password string `bun:"password,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"`
Events []Event `bun:"m2m:events_to_users,join:User=Event"`
Articles []*Blog `bun:"rel:has-many,join:user_id=blog_id"`
UserID uuid.UUID `bun:"type:uuid,pk,default:gen_random_uuid()" json:"userId"`
FirstName string `bun:"firstname,notnull" json:"firstname"`
LastName string `bun:"lastname,notnull" json:"lastname"`
Email string `bun:"email,unique,notnull" json:"email"`
Password string `bun:"password,notnull" json:"password"`
Phone string `bun:"phone,notnull" json:"phone"`
Role Role `bun:"role,notnull,default:'user'" json:"role"`
CreatedAt time.Time `bun:"created_at,default:current_timestamp" json:"createdAt"`
UpdatedAt time.Time `bun:"updated_at,default:current_timestamp" json:"updatedAt"`
Events []Event `bun:"m2m:events_to_users,join:User=Event" json:"events,omitempty"`
Articles []*Blog `bun:"rel:has-many,join:user_id=blog_id" json:"articles,omitempty"`
}
type Event struct {