Sprint 5.1: JSON snake_case tags + lowercased fields
- All response types now use lowercase json tags (id, name, photo_url, etc.) - email/phone/birthdate/last_seen_at/photo_url use omitempty - audit.Metadata type []byte (was map[string]any) - fixes register/login inconsistency where login returned ID/Name (CamelCase) while register returned id/name (lowercase)
This commit is contained in:
parent
1eb7af6bac
commit
778a2da4ef
@ -9,15 +9,15 @@ import (
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
ID int64
|
||||
UserID *uuid.UUID
|
||||
Action string
|
||||
TargetType string
|
||||
TargetID string
|
||||
Metadata map[string]any
|
||||
IP string
|
||||
UserAgent string
|
||||
CreatedAt time.Time
|
||||
ID int64 `json:"id"`
|
||||
UserID *uuid.UUID `json:"user_id,omitempty"`
|
||||
Action string `json:"action"`
|
||||
TargetType string `json:"target_type,omitempty"`
|
||||
TargetID string `json:"target_id,omitempty"`
|
||||
Metadata []byte `json:"metadata,omitempty"`
|
||||
IP string `json:"ip,omitempty"`
|
||||
UserAgent string `json:"user_agent,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
|
||||
@ -11,24 +11,24 @@ import (
|
||||
)
|
||||
|
||||
type Chat struct {
|
||||
ID uuid.UUID
|
||||
UserA uuid.UUID
|
||||
UserB uuid.UUID
|
||||
CreatedAt time.Time
|
||||
LastMsgAt time.Time
|
||||
ID uuid.UUID `json:"id"`
|
||||
UserA uuid.UUID `json:"user_a"`
|
||||
UserB uuid.UUID `json:"user_b"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
LastMsgAt time.Time `json:"last_msg_at"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
ID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
SenderID uuid.UUID
|
||||
Body string
|
||||
PhotoURL string
|
||||
Read bool
|
||||
Edited bool
|
||||
Deleted bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
ID uuid.UUID `json:"id"`
|
||||
ChatID uuid.UUID `json:"chat_id"`
|
||||
SenderID uuid.UUID `json:"sender_id"`
|
||||
Body string `json:"body"`
|
||||
PhotoURL string `json:"photo_url,omitempty"`
|
||||
Read bool `json:"read"`
|
||||
Edited bool `json:"edited"`
|
||||
Deleted bool `json:"deleted"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
@ -87,13 +87,13 @@ func (r *Repo) GetByID(ctx context.Context, id uuid.UUID) (*Chat, error) {
|
||||
|
||||
// ListChats — список чатов пользователя с инфой по последнему сообщению
|
||||
type ChatListItem struct {
|
||||
Chat Chat
|
||||
OtherID uuid.UUID
|
||||
OtherName string
|
||||
OtherPhoto string
|
||||
LastMessage string
|
||||
LastMsgAt time.Time
|
||||
UnreadCount int
|
||||
Chat Chat `json:"chat"`
|
||||
OtherID uuid.UUID `json:"other_id"`
|
||||
OtherName string `json:"other_name"`
|
||||
OtherPhoto string `json:"other_photo,omitempty"`
|
||||
LastMessage string `json:"last_message"`
|
||||
LastMsgAt time.Time `json:"last_msg_at"`
|
||||
UnreadCount int `json:"unread_count"`
|
||||
}
|
||||
|
||||
func (r *Repo) ListChats(ctx context.Context, me uuid.UUID, limit, offset int) ([]ChatListItem, error) {
|
||||
|
||||
@ -11,11 +11,11 @@ import (
|
||||
)
|
||||
|
||||
type Location struct {
|
||||
UserID uuid.UUID
|
||||
Lat float64
|
||||
Lng float64
|
||||
Visible bool
|
||||
UpdatedAt time.Time
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Lat float64 `json:"lat"`
|
||||
Lng float64 `json:"lng"`
|
||||
Visible bool `json:"visible"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
|
||||
@ -27,12 +27,12 @@ var AllowedPurposes = map[string]bool{
|
||||
}
|
||||
|
||||
type Prefs struct {
|
||||
UserID uuid.UUID
|
||||
Drinks []string
|
||||
Activities []string
|
||||
Purposes []string
|
||||
Language string
|
||||
UpdatedAt time.Time
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
Drinks []string `json:"drinks"`
|
||||
Activities []string `json:"activities"`
|
||||
Purposes []string `json:"purposes"`
|
||||
Language string `json:"language"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
|
||||
@ -11,22 +11,22 @@ import (
|
||||
)
|
||||
|
||||
type Review struct {
|
||||
ID uuid.UUID
|
||||
ReviewerID uuid.UUID
|
||||
ReviewedID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
Rating int
|
||||
Body string
|
||||
Anonymous bool
|
||||
CreatedAt time.Time
|
||||
ID uuid.UUID `json:"id"`
|
||||
ReviewerID uuid.UUID `json:"reviewer_id"`
|
||||
ReviewedID uuid.UUID `json:"reviewed_id"`
|
||||
ChatID uuid.UUID `json:"chat_id"`
|
||||
Rating int `json:"rating"`
|
||||
Body string `json:"body"`
|
||||
Anonymous bool `json:"anonymous"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
UserID uuid.UUID
|
||||
RatingAvg float64
|
||||
RatingCount int
|
||||
ReviewsLeft int
|
||||
LastActiveAt *time.Time
|
||||
UserID uuid.UUID `json:"user_id"`
|
||||
RatingAvg float64 `json:"rating_avg"`
|
||||
RatingCount int `json:"rating_count"`
|
||||
ReviewsLeft int `json:"reviews_left"`
|
||||
LastActiveAt *time.Time `json:"last_active_at,omitempty"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
|
||||
@ -11,20 +11,20 @@ import (
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID uuid.UUID
|
||||
Email string
|
||||
Phone string
|
||||
Name string
|
||||
Birthdate *time.Time
|
||||
Gender string
|
||||
City string
|
||||
Bio string
|
||||
PhotoURL string
|
||||
IsVerified bool
|
||||
IsBlocked bool
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
LastSeenAt *time.Time
|
||||
ID uuid.UUID `json:"id"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
Name string `json:"name"`
|
||||
Birthdate *time.Time `json:"birthdate,omitempty"`
|
||||
Gender string `json:"gender"`
|
||||
City string `json:"city"`
|
||||
Bio string `json:"bio"`
|
||||
PhotoURL string `json:"photo_url,omitempty"`
|
||||
IsVerified bool `json:"is_verified"`
|
||||
IsBlocked bool `json:"is_blocked"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
LastSeenAt *time.Time `json:"last_seen_at,omitempty"`
|
||||
}
|
||||
|
||||
type Repo struct {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user