Enhance CMS Entity and Forms with Type Field
- Added a new Type field to the CMS entity to differentiate between Company and Organization types, improving data categorization. - Updated the CMSForm to include validation for the Type field, ensuring proper input handling. - Modified the ToResponse method to include the Type field in the CMSResponse, enhancing the API response structure. - Adjusted the copyFormToEntity method in the CMS service to handle the new Type field, maintaining data integrity based on the selected type. - Enhanced Swagger documentation to reflect the changes in the CMS API, providing clear examples for the new Type field.
This commit is contained in:
+31
-22
@@ -8,6 +8,7 @@ type CMSForm struct {
|
||||
Language string `json:"language" valid:"optional,length(2|100)" example:"en"`
|
||||
CompanyName string `json:"company_name" valid:"optional,length(2|100)" example:"Opplens"`
|
||||
Country string `json:"country" valid:"optional,length(3)" example:"SWE"`
|
||||
Type CMSType `json:"type" valid:"optional,in(company|organization)" example:"company"`
|
||||
Hero heroSectionForm `json:"hero" valid:"optional"`
|
||||
Chart chartSectionForm `json:"chart" valid:"optional"`
|
||||
Features cardSectionForm `json:"features" valid:"optional"`
|
||||
@@ -86,17 +87,21 @@ type SearchCMSForm struct {
|
||||
|
||||
// CMSResponse represents the CMS data sent in API responses
|
||||
type CMSResponse struct {
|
||||
ID string `json:"id"`
|
||||
Key string `json:"key"`
|
||||
Hero heroSection `json:"hero"`
|
||||
Chart chartSection `json:"chart"`
|
||||
Features cardSection `json:"features"`
|
||||
Challenges cardSection `json:"challenges"`
|
||||
Advantages cardSection `json:"advantages"`
|
||||
Contact contactSection `json:"contact"`
|
||||
Footer footerSection `json:"footer"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
ID string `json:"id"`
|
||||
Key string `json:"key"`
|
||||
Language string `json:"language"`
|
||||
CompanyName string `json:"company_name"`
|
||||
Country string `json:"country"`
|
||||
Type CMSType `json:"type"`
|
||||
Hero heroSection `json:"hero"`
|
||||
Chart chartSection `json:"chart"`
|
||||
Features cardSection `json:"features"`
|
||||
Challenges cardSection `json:"challenges"`
|
||||
Advantages cardSection `json:"advantages"`
|
||||
Contact contactSection `json:"contact"`
|
||||
Footer footerSection `json:"footer"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
}
|
||||
|
||||
// CMSListResponse represents the response for listing CMS entries
|
||||
@@ -108,16 +113,20 @@ type CMSListResponse struct {
|
||||
// ToResponse converts CMS to CMSResponse
|
||||
func (c *CMS) ToResponse() *CMSResponse {
|
||||
return &CMSResponse{
|
||||
ID: c.GetID(),
|
||||
Key: c.Key,
|
||||
Hero: c.Hero,
|
||||
Chart: c.Chart,
|
||||
Features: c.Features,
|
||||
Challenges: c.Challenges,
|
||||
Advantages: c.Advantages,
|
||||
Contact: c.Contact,
|
||||
Footer: c.Footer,
|
||||
CreatedAt: c.GetCreatedAt(),
|
||||
UpdatedAt: c.GetUpdatedAt(),
|
||||
ID: c.GetID(),
|
||||
Key: c.Key,
|
||||
Language: c.Language,
|
||||
CompanyName: c.CompanyName,
|
||||
Country: c.Country,
|
||||
Type: c.Type,
|
||||
Hero: c.Hero,
|
||||
Chart: c.Chart,
|
||||
Features: c.Features,
|
||||
Challenges: c.Challenges,
|
||||
Advantages: c.Advantages,
|
||||
Contact: c.Contact,
|
||||
Footer: c.Footer,
|
||||
CreatedAt: c.GetCreatedAt(),
|
||||
UpdatedAt: c.GetUpdatedAt(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user