From afb32a9fa356442cd56eb07bec30544c74299053 Mon Sep 17 00:00:00 2001 From: Nima Nakhostin Date: Sun, 23 Nov 2025 14:07:10 +0330 Subject: [PATCH] Enhance CMS Entity with JSON Tags - Added JSON tags to all fields in the CMS entity and its related sections (heroSection, chartSection, cardSection, contactSection, footerSection) to ensure proper serialization and deserialization in API responses. - This change improves the API's usability by providing clear JSON representations of the CMS data structure. --- internal/cms/entity.go | 74 +++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/internal/cms/entity.go b/internal/cms/entity.go index c458619..924ca3a 100644 --- a/internal/cms/entity.go +++ b/internal/cms/entity.go @@ -9,18 +9,18 @@ import ( // CMS represents the content management system for the landing page type CMS struct { mongo.Model `bson:",inline"` - Key string `bson:"key"` - Language string `bson:"language"` - CompanyName string `bson:"company_name"` - Country string `bson:"country"` - Type CMSType `bson:"type"` - Hero heroSection `bson:"hero"` - Chart chartSection `bson:"chart"` - Features cardSection `bson:"features"` - Challenges cardSection `bson:"challenges"` - Advantages cardSection `bson:"advantages"` - Contact contactSection `bson:"contact"` - Footer footerSection `bson:"footer"` + Key string `bson:"key" json:"key"` + Language string `bson:"language" json:"language"` + CompanyName string `bson:"company_name" json:"company_name"` + Country string `bson:"country" json:"country"` + Type CMSType `bson:"type" json:"type"` + Hero heroSection `bson:"hero" json:"hero"` + Chart chartSection `bson:"chart" json:"chart"` + Features cardSection `bson:"features" json:"features"` + Challenges cardSection `bson:"challenges" json:"challenges"` + Advantages cardSection `bson:"advantages" json:"advantages"` + Contact contactSection `bson:"contact" json:"contact"` + Footer footerSection `bson:"footer" json:"footer"` } type CMSType string @@ -62,17 +62,17 @@ func (c *CMS) GetUpdatedAt() int64 { // heroSection represents the hero section of the landing page type heroSection struct { - Title string `bson:"title"` - Description string `bson:"description"` - ButtonText string `bson:"button_text"` - ButtonLink string `bson:"button_link"` - GifFile string `bson:"gif_file"` + Title string `bson:"title" json:"title"` + Description string `bson:"description" json:"description"` + ButtonText string `bson:"button_text" json:"button_text"` + ButtonLink string `bson:"button_link" json:"button_link"` + GifFile string `bson:"gif_file" json:"gif_file"` } // chartSection represents the chart section of the landing page type chartSection struct { Title string `bson:"title" json:"title"` - MissedAmount string `bson:"missed_amount" json:"missedAmount"` + MissedAmount string `bson:"missed_amount" json:"missed_amount"` Data []chartPoint `bson:"data" json:"data"` } @@ -83,41 +83,41 @@ type chartPoint struct { // cardSection represents the card section of the landing page type cardSection struct { - Title string `bson:"title"` - Description string `bson:"description"` - Cards []card `bson:"cards"` + Title string `bson:"title" json:"title"` + Description string `bson:"description" json:"description"` + Cards []card `bson:"cards" json:"cards"` } // card represents a card in the card section type card struct { ID string `bson:"id" json:"id"` - Icon string `bson:"icon"` - Title string `bson:"title"` - Description string `bson:"description"` + Icon string `bson:"icon" json:"icon"` + Title string `bson:"title" json:"title"` + Description string `bson:"description" json:"description"` } // contactSection represents the contact section of the landing page type contactSection struct { - Title string `bson:"title"` - Description string `bson:"description"` - SubmitButtonText string `bson:"submit_button_text"` - Fields []formField `bson:"fields"` + Title string `bson:"title" json:"title"` + Description string `bson:"description" json:"description"` + SubmitButtonText string `bson:"submit_button_text" json:"submit_button_text"` + Fields []formField `bson:"fields" json:"fields"` } // formField represents a form field in the contact section type formField struct { ID string `bson:"id" json:"id"` - Name string `bson:"name"` - Label string `bson:"label"` - Placeholder string `bson:"placeholder"` - Required bool `bson:"required"` + Name string `bson:"name" json:"name"` + Label string `bson:"label" json:"label"` + Placeholder string `bson:"placeholder" json:"placeholder"` + Required bool `bson:"required" json:"required"` } // footerSection represents the footer section of the landing page type footerSection struct { - Email string `bson:"email"` - Phone string `bson:"phone"` - Location string `bson:"location"` - Tagline string `bson:"tagline"` - Copyright string `bson:"copyright"` + Email string `bson:"email" json:"email"` + Phone string `bson:"phone" json:"phone"` + Location string `bson:"location" json:"location"` + Tagline string `bson:"tagline" json:"tagline"` + Copyright string `bson:"copyright" json:"copyright"` }