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:
ga 2026-08-20 16:29:02 +00:00
parent 1eb7af6bac
commit 778a2da4ef
6 changed files with 69 additions and 69 deletions

View File

@ -9,15 +9,15 @@ import (
) )
type Event struct { type Event struct {
ID int64 ID int64 `json:"id"`
UserID *uuid.UUID UserID *uuid.UUID `json:"user_id,omitempty"`
Action string Action string `json:"action"`
TargetType string TargetType string `json:"target_type,omitempty"`
TargetID string TargetID string `json:"target_id,omitempty"`
Metadata map[string]any Metadata []byte `json:"metadata,omitempty"`
IP string IP string `json:"ip,omitempty"`
UserAgent string UserAgent string `json:"user_agent,omitempty"`
CreatedAt time.Time CreatedAt time.Time `json:"created_at"`
} }
type Repo struct { type Repo struct {

View File

@ -11,24 +11,24 @@ import (
) )
type Chat struct { type Chat struct {
ID uuid.UUID ID uuid.UUID `json:"id"`
UserA uuid.UUID UserA uuid.UUID `json:"user_a"`
UserB uuid.UUID UserB uuid.UUID `json:"user_b"`
CreatedAt time.Time CreatedAt time.Time `json:"created_at"`
LastMsgAt time.Time LastMsgAt time.Time `json:"last_msg_at"`
} }
type Message struct { type Message struct {
ID uuid.UUID ID uuid.UUID `json:"id"`
ChatID uuid.UUID ChatID uuid.UUID `json:"chat_id"`
SenderID uuid.UUID SenderID uuid.UUID `json:"sender_id"`
Body string Body string `json:"body"`
PhotoURL string PhotoURL string `json:"photo_url,omitempty"`
Read bool Read bool `json:"read"`
Edited bool Edited bool `json:"edited"`
Deleted bool Deleted bool `json:"deleted"`
CreatedAt time.Time CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time UpdatedAt time.Time `json:"updated_at"`
} }
type Repo struct { type Repo struct {
@ -87,13 +87,13 @@ func (r *Repo) GetByID(ctx context.Context, id uuid.UUID) (*Chat, error) {
// ListChats — список чатов пользователя с инфой по последнему сообщению // ListChats — список чатов пользователя с инфой по последнему сообщению
type ChatListItem struct { type ChatListItem struct {
Chat Chat Chat Chat `json:"chat"`
OtherID uuid.UUID OtherID uuid.UUID `json:"other_id"`
OtherName string OtherName string `json:"other_name"`
OtherPhoto string OtherPhoto string `json:"other_photo,omitempty"`
LastMessage string LastMessage string `json:"last_message"`
LastMsgAt time.Time LastMsgAt time.Time `json:"last_msg_at"`
UnreadCount int UnreadCount int `json:"unread_count"`
} }
func (r *Repo) ListChats(ctx context.Context, me uuid.UUID, limit, offset int) ([]ChatListItem, error) { func (r *Repo) ListChats(ctx context.Context, me uuid.UUID, limit, offset int) ([]ChatListItem, error) {

View File

@ -11,11 +11,11 @@ import (
) )
type Location struct { type Location struct {
UserID uuid.UUID UserID uuid.UUID `json:"user_id"`
Lat float64 Lat float64 `json:"lat"`
Lng float64 Lng float64 `json:"lng"`
Visible bool Visible bool `json:"visible"`
UpdatedAt time.Time UpdatedAt time.Time `json:"updated_at"`
} }
type Repo struct { type Repo struct {

View File

@ -27,12 +27,12 @@ var AllowedPurposes = map[string]bool{
} }
type Prefs struct { type Prefs struct {
UserID uuid.UUID UserID uuid.UUID `json:"user_id"`
Drinks []string Drinks []string `json:"drinks"`
Activities []string Activities []string `json:"activities"`
Purposes []string Purposes []string `json:"purposes"`
Language string Language string `json:"language"`
UpdatedAt time.Time UpdatedAt time.Time `json:"updated_at"`
} }
type Repo struct { type Repo struct {

View File

@ -11,22 +11,22 @@ import (
) )
type Review struct { type Review struct {
ID uuid.UUID ID uuid.UUID `json:"id"`
ReviewerID uuid.UUID ReviewerID uuid.UUID `json:"reviewer_id"`
ReviewedID uuid.UUID ReviewedID uuid.UUID `json:"reviewed_id"`
ChatID uuid.UUID ChatID uuid.UUID `json:"chat_id"`
Rating int Rating int `json:"rating"`
Body string Body string `json:"body"`
Anonymous bool Anonymous bool `json:"anonymous"`
CreatedAt time.Time CreatedAt time.Time `json:"created_at"`
} }
type Stats struct { type Stats struct {
UserID uuid.UUID UserID uuid.UUID `json:"user_id"`
RatingAvg float64 RatingAvg float64 `json:"rating_avg"`
RatingCount int RatingCount int `json:"rating_count"`
ReviewsLeft int ReviewsLeft int `json:"reviews_left"`
LastActiveAt *time.Time LastActiveAt *time.Time `json:"last_active_at,omitempty"`
} }
type Repo struct { type Repo struct {

View File

@ -11,20 +11,20 @@ import (
) )
type User struct { type User struct {
ID uuid.UUID ID uuid.UUID `json:"id"`
Email string Email string `json:"email,omitempty"`
Phone string Phone string `json:"phone,omitempty"`
Name string Name string `json:"name"`
Birthdate *time.Time Birthdate *time.Time `json:"birthdate,omitempty"`
Gender string Gender string `json:"gender"`
City string City string `json:"city"`
Bio string Bio string `json:"bio"`
PhotoURL string PhotoURL string `json:"photo_url,omitempty"`
IsVerified bool IsVerified bool `json:"is_verified"`
IsBlocked bool IsBlocked bool `json:"is_blocked"`
CreatedAt time.Time CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time UpdatedAt time.Time `json:"updated_at"`
LastSeenAt *time.Time LastSeenAt *time.Time `json:"last_seen_at,omitempty"`
} }
type Repo struct { type Repo struct {