@@ -29,8 +29,8 @@ type User struct {
2929
3030 OwnedClubs []Club `json:"owned_clubs,omitempty" gorm:"foreignKey:OwnerID"`
3131 ClubMemberships []ClubMembership `json:"club_memberships,omitempty" gorm:"foreignKey:UserID"`
32- Posts []Post `json:"posts,omitempty" gorm:"foreignKey:AuthorID "`
33- Comments []Comment `json:"comments,omitempty" gorm:"foreignKey:AuthorID "`
32+ Posts []Post `json:"posts,omitempty" gorm:"foreignKey:UserID "`
33+ Comments []Comment `json:"comments,omitempty" gorm:"foreignKey:UserID "`
3434 Annotations []Annotation `json:"annotations,omitempty" gorm:"foreignKey:UserID"`
3535 PostLikes []PostLike `json:"post_likes,omitempty" gorm:"foreignKey:UserID"`
3636 CommentLikes []CommentLike `json:"comment_likes,omitempty" gorm:"foreignKey:UserID"`
@@ -41,13 +41,32 @@ type User struct {
4141}
4242
4343type UserResponse struct {
44- ID uint `json:"id"`
45- Username string `json:"username"`
46- Email string `json:"email"`
47- FirstName string `json:"first_name"`
48- LastName string `json:"last_name"`
49- IsActive bool `json:"is_active"`
50- Role string `json:"role"`
44+ ID uint `json:"id"`
45+ Username string `json:"username"`
46+ Email string `json:"email"`
47+ FirstName string `json:"first_name"`
48+ LastName string `json:"last_name"`
49+ IsActive bool `json:"is_active"`
50+ Role string `json:"role"`
51+
52+ AvatarURL * string `json:"avatar_url"`
53+ Location * string `json:"location"`
54+ FavoriteGenres pq.StringArray `json:"favorite_genres"`
55+ Bio * string `json:"bio"`
56+ ReadingGoal * int `json:"reading_goal"`
57+ BooksRead int `json:"books_read"`
58+ Badges pq.StringArray `json:"badges"`
59+ IsOnline bool `json:"is_online"`
60+ LastSeen * time.Time `json:"last_seen"`
61+
62+ OwnedClubs []Club `json:"owned_clubs,omitempty"`
63+ ClubMemberships []ClubMembership `json:"club_memberships,omitempty"`
64+ Posts []Post `json:"posts,omitempty"`
65+ Comments []Comment `json:"comments,omitempty"`
66+ Annotations []Annotation `json:"annotations,omitempty"`
67+ PostLikes []PostLike `json:"post_likes,omitempty"`
68+ CommentLikes []CommentLike `json:"comment_likes,omitempty"`
69+
5170 CreatedAt time.Time `json:"created_at"`
5271}
5372
@@ -64,36 +83,54 @@ type RegisterRequest struct {
6483 LastName string `json:"last_name" validate:"required,min=2,max=50"`
6584 Role string `json:"role" validate:"omitempty,oneof=admin user moderator support superuser" gorm:"default:'user'"`
6685
86+ AvatarURL string `json:"avatar_url"`
6787 Location string `json:"location"`
6888 FavoriteGenres []string `json:"favorite_genres"`
6989 Bio string `json:"bio"`
7090 ReadingGoal int `json:"reading_goal"`
7191}
7292
7393type UpdateUserRequest struct {
74- Username * string `json:"username" validate:"omitempty,min=3,max=50"`
75- Email * string `json:"email" validate:"omitempty,email"`
76- Password * string `json:"password" validate:"omitempty,min=6"`
77- FirstName * string `json:"first_name" validate:"omitempty,min=2,max=50"`
78- LastName * string `json:"last_name" validate:"omitempty,min=2,max=50"`
94+ Username * string `json:"username" validate:"omitempty,min=3,max=50"`
95+ Email * string `json:"email" validate:"omitempty,email"`
96+ Password * string `json:"password" validate:"omitempty,min=6"`
97+ FirstName * string `json:"first_name" validate:"omitempty,min=2,max=50"`
98+ LastName * string `json:"last_name" validate:"omitempty,min=2,max=50"`
99+ Role * string `json:"role" validate:"omitempty,oneof=admin user moderator support superuser"`
100+ IsActive * bool `json:"is_active"`
101+
79102 AvatarURL * string `json:"avatar_url" validate:"omitempty,url"`
80103 Location * string `json:"location" validate:"omitempty,max=255"`
81104 FavoriteGenres * []string `json:"favorite_genres"`
82105 Bio * string `json:"bio" validate:"omitempty"`
83106 ReadingGoal * int `json:"reading_goal" validate:"omitempty,gte=0"`
84- Role * string `json:"role" validate:"omitempty,oneof=admin user moderator support superuser"`
85- IsActive * bool `json:"is_active"`
86107}
87108
88109func (u * User ) ToResponse () UserResponse {
89110 return UserResponse {
90- ID : u .ID ,
91- Username : u .Username ,
92- Email : u .Email ,
93- FirstName : u .FirstName ,
94- LastName : u .LastName ,
95- IsActive : u .IsActive ,
96- Role : u .Role ,
97- CreatedAt : u .CreatedAt ,
111+ ID : u .ID ,
112+ Username : u .Username ,
113+ Email : u .Email ,
114+ FirstName : u .FirstName ,
115+ LastName : u .LastName ,
116+ IsActive : u .IsActive ,
117+ Role : u .Role ,
118+ AvatarURL : u .AvatarURL ,
119+ Location : u .Location ,
120+ FavoriteGenres : u .FavoriteGenres ,
121+ Bio : u .Bio ,
122+ ReadingGoal : & u .ReadingGoal ,
123+ BooksRead : u .BooksRead ,
124+ Badges : u .Badges ,
125+ IsOnline : u .IsOnline ,
126+ LastSeen : u .LastSeen ,
127+ OwnedClubs : u .OwnedClubs ,
128+ ClubMemberships : u .ClubMemberships ,
129+ Posts : u .Posts ,
130+ Comments : u .Comments ,
131+ Annotations : u .Annotations ,
132+ PostLikes : u .PostLikes ,
133+ CommentLikes : u .CommentLikes ,
134+ CreatedAt : u .CreatedAt ,
98135 }
99136}
0 commit comments