From 1e7aae32291b556874aa41427cc416ae59c78680 Mon Sep 17 00:00:00 2001 From: litsynp Date: Sat, 2 Mar 2024 16:47:20 +0900 Subject: [PATCH] feat: change JSON fields to camelCase --- api/common.go | 2 +- cmd/server/main.go | 2 +- internal/domain/pet/view.go | 14 +++--- internal/domain/sos_post/view.go | 84 ++++++++++++++++---------------- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/api/common.go b/api/common.go index d8dd27ac..3f2d7455 100644 --- a/api/common.go +++ b/api/common.go @@ -8,7 +8,7 @@ import ( type PaginatedView[T interface{}] struct { Page int `json:"page"` Size int `json:"size"` - IsLastPage bool `json:"is_last_page"` + IsLastPage bool `json:"isLastPage"` Items []T `json:"items"` } diff --git a/cmd/server/main.go b/cmd/server/main.go index 2e7f7176..c0ba839d 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -13,7 +13,7 @@ import ( ) // @title 이웃집멍냥 API 문서 -// @version 0.8.0 +// @version 0.9.0 // @description 이웃집멍냥 백엔드 API 문서입니다. // @termsOfService http://swagger.io/terms/ diff --git a/internal/domain/pet/view.go b/internal/domain/pet/view.go index 1e398f84..4580be60 100644 --- a/internal/domain/pet/view.go +++ b/internal/domain/pet/view.go @@ -8,12 +8,12 @@ type AddPetsToOwnerRequest struct { type AddPetRequest struct { Name string `json:"name" validate:"required"` - PetType PetType `json:"pet_type" validate:"required,oneof=dog cat"` + PetType PetType `json:"petType" validate:"required,oneof=dog cat"` Sex PetSex `json:"sex" validate:"required,oneof=male female"` Neutered bool `json:"neutered" validate:"required"` Breed string `json:"breed" validate:"required"` - BirthDate string `json:"birth_date" validate:"required"` - WeightInKg float64 `json:"weight_in_kg" validate:"required"` + BirthDate string `json:"birthDate" validate:"required"` + WeightInKg float64 `json:"weightInKg" validate:"required"` } type FindMyPetsView struct { @@ -23,17 +23,17 @@ type FindMyPetsView struct { type PetView struct { ID int `json:"id"` Name string `json:"name"` - PetType PetType `json:"pet_type"` + PetType PetType `json:"petType"` Sex PetSex `json:"sex"` Neutered bool `json:"neutered"` Breed string `json:"breed"` - BirthDate string `json:"birth_date"` - WeightInKg float64 `json:"weight_in_kg"` + BirthDate string `json:"birthDate"` + WeightInKg float64 `json:"weightInKg"` } type BreedView struct { ID int `json:"id"` - PetType PetType `json:"pet_type"` + PetType PetType `json:"petType"` Name string `json:"name"` } diff --git a/internal/domain/sos_post/view.go b/internal/domain/sos_post/view.go index ac8d09f4..dfd8dc55 100644 --- a/internal/domain/sos_post/view.go +++ b/internal/domain/sos_post/view.go @@ -12,34 +12,34 @@ import ( type WriteSosPostRequest struct { Title string `json:"title" validate:"required"` Content string `json:"content" validate:"required"` - ImageIDs []int `json:"image_ids" validate:"required"` + ImageIDs []int `json:"imageIds" validate:"required"` Reward string `json:"reward" validate:"required"` - DateStartAt time.Time `json:"date_start_at" validate:"required"` - DateEndAt time.Time `json:"date_end_at" validate:"required"` - CareType CareType `json:"care_type" validate:"required,oneof= foster visiting"` - CarerGender CarerGender `json:"carer_gender" validate:"required,oneof=male female all"` - RewardAmount RewardAmount `json:"reward_amount" validate:"required,oneof=hour"` - ConditionIDs []int `json:"condition_ids"` - PetIDs []int `json:"pet_ids"` + DateStartAt time.Time `json:"dateStartAt" validate:"required"` + DateEndAt time.Time `json:"dateEndAt" validate:"required"` + CareType CareType `json:"careType" validate:"required,oneof= foster visiting"` + CarerGender CarerGender `json:"carerGender" validate:"required,oneof=male female all"` + RewardAmount RewardAmount `json:"rewardAmount" validate:"required,oneof=hour"` + ConditionIDs []int `json:"conditionIds"` + PetIDs []int `json:"petIds"` } type WriteSosPostView struct { ID int `json:"id"` - AuthorID int `json:"author_id"` + AuthorID int `json:"authorId"` Title string `json:"title"` Content string `json:"content"` Media []media.MediaView `json:"media"` Conditions []ConditionView `json:"conditions"` Pets []pet.PetView `json:"pets"` Reward string `json:"reward"` - DateStartAt string `json:"date_start_at"` - DateEndAt string `json:"date_end_at"` - CareType CareType `json:"care_type"` - CarerGender CarerGender `json:"carer_gender"` - RewardAmount RewardAmount `json:"reward_amount"` - ThumbnailID int `json:"thumbnail_id"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + DateStartAt string `json:"dateStartAt"` + DateEndAt string `json:"dateEndAt"` + CareType CareType `json:"careType"` + CarerGender CarerGender `json:"carerGender"` + RewardAmount RewardAmount `json:"rewardAmount"` + ThumbnailID int `json:"thumbnailId"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } type FindSosPostView struct { @@ -51,14 +51,14 @@ type FindSosPostView struct { Conditions []ConditionView `json:"conditions"` Pets []pet.PetView `json:"pets"` Reward string `json:"reward"` - DateStartAt string `json:"date_start_at"` - DateEndAt string `json:"date_end_at"` - CareType CareType `json:"care_type"` - CarerGender CarerGender `json:"carer_gender"` - RewardAmount RewardAmount `json:"reward_amount"` - ThumbnailID int `json:"thumbnail_id"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + DateStartAt string `json:"dateStartAt"` + DateEndAt string `json:"dateEndAt"` + CareType CareType `json:"careType"` + CarerGender CarerGender `json:"carerGender"` + RewardAmount RewardAmount `json:"rewardAmount"` + ThumbnailID int `json:"thumbnailId"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } type FindSosPostListView struct { @@ -77,32 +77,32 @@ type UpdateSosPostRequest struct { ID int `json:"id" validate:"required"` Title string `json:"title" validate:"required"` Content string `json:"content" validate:"required"` - ImageIDs []int `json:"image_ids" validate:"required"` + ImageIDs []int `json:"imageIds" validate:"required"` Reward string `json:"reward" validate:"required"` - DateStartAt string `json:"date_start_at" validate:"required"` - DateEndAt string `json:"date_end_at" validate:"required"` - CareType CareType `json:"care_type" validate:"required,oneof= foster visiting"` - CarerGender CarerGender `json:"carer_gender" validate:"required,oneof=male female all"` - RewardAmount RewardAmount `json:"reward_amount" validate:"required,oneof=hour"` - ConditionIDs []int `json:"condition_ids"` - PetIDs []int `json:"pet_ids"` + DateStartAt string `json:"dateStartAt" validate:"required"` + DateEndAt string `json:"dateEndAt" validate:"required"` + CareType CareType `json:"careType" validate:"required,oneof= foster visiting"` + CarerGender CarerGender `json:"carerGender" validate:"required,oneof=male female all"` + RewardAmount RewardAmount `json:"rewardAmount" validate:"required,oneof=hour"` + ConditionIDs []int `json:"conditionIds"` + PetIDs []int `json:"petIds"` } type UpdateSosPostView struct { ID int `json:"id"` - AuthorID int `json:"author_id"` + AuthorID int `json:"authorId"` Title string `json:"title"` Content string `json:"content"` Media []media.MediaView `json:"media"` Conditions []ConditionView `json:"conditions"` Pets []pet.PetView `json:"pets"` Reward string `json:"reward"` - DateStartAt string `json:"date_start_at"` - DateEndAt string `json:"date_end_at"` - CareType CareType `json:"care_type"` - CarerGender CarerGender `json:"carer_gender"` - RewardAmount RewardAmount `json:"reward_amount"` - ThumbnailID int `json:"thumbnail_id"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + DateStartAt string `json:"dateStartAt"` + DateEndAt string `json:"dateEndAt"` + CareType CareType `json:"careType"` + CarerGender CarerGender `json:"carerGender"` + RewardAmount RewardAmount `json:"rewardAmount"` + ThumbnailID int `json:"thumbnailId"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` }