9a444a1e7d
- Introduced a new CMS management feature, including the ability to create, retrieve, update, search, and delete CMS entries. - Implemented the CMS entity, repository, service, and handler layers following Clean Architecture principles. - Added API endpoints for CMS operations in Swagger documentation, ensuring comprehensive API specifications. - Enhanced error handling and validation for CMS data, improving robustness and user experience. - Updated the main application to initialize the CMS repository and service, integrating them into the existing system.
111 lines
3.3 KiB
Go
111 lines
3.3 KiB
Go
package cms
|
|
|
|
import (
|
|
"tm/pkg/mongo"
|
|
|
|
"go.mongodb.org/mongo-driver/v2/bson"
|
|
)
|
|
|
|
// CMS represents the content management system for the landing page
|
|
type CMS struct {
|
|
mongo.Model `bson:",inline"`
|
|
Key string `bson:"key" json:"key" validate:"required"`
|
|
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"`
|
|
}
|
|
|
|
// SetID sets the CMS ID (implements IDSetter interface)
|
|
func (c *CMS) SetID(id string) {
|
|
c.ID, _ = bson.ObjectIDFromHex(id)
|
|
}
|
|
|
|
// GetID returns the CMS ID (implements IDGetter interface)
|
|
func (c *CMS) GetID() string {
|
|
return c.ID.Hex()
|
|
}
|
|
|
|
// SetCreatedAt sets the created timestamp (implements Timestamp interface)
|
|
func (c *CMS) SetCreatedAt(timestamp int64) {
|
|
c.CreatedAt = timestamp
|
|
}
|
|
|
|
// SetUpdatedAt sets the updated timestamp (implements Timestamp interface)
|
|
func (c *CMS) SetUpdatedAt(timestamp int64) {
|
|
c.UpdatedAt = timestamp
|
|
}
|
|
|
|
// GetCreatedAt returns the created timestamp (implements Timestamp interface)
|
|
func (c *CMS) GetCreatedAt() int64 {
|
|
return c.CreatedAt
|
|
}
|
|
|
|
// GetUpdatedAt returns the updated timestamp (implements Timestamp interface)
|
|
func (c *CMS) GetUpdatedAt() int64 {
|
|
return c.UpdatedAt
|
|
}
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// 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"`
|
|
Data []chartPoint `bson:"data" json:"data"`
|
|
}
|
|
|
|
type chartPoint struct {
|
|
Key string `bson:"key" json:"key"`
|
|
Value int `bson:"value" json:"value"`
|
|
}
|
|
|
|
// cardSection represents the card section of the landing page
|
|
type cardSection struct {
|
|
Title string `bson:"title"`
|
|
Description string `bson:"description"`
|
|
Cards []card `bson:"cards"`
|
|
}
|
|
|
|
// card represents a card in the card section
|
|
type card struct {
|
|
Icon string `bson:"icon"`
|
|
Title string `bson:"title"`
|
|
Description string `bson:"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"`
|
|
}
|
|
|
|
// formField represents a form field in the contact section
|
|
type formField struct {
|
|
Name string `bson:"name"`
|
|
Label string `bson:"label"`
|
|
Placeholder string `bson:"placeholder"`
|
|
Required bool `bson:"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"`
|
|
}
|