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:
+19
-7
@@ -236,15 +236,27 @@ func (s *cmsService) Search(ctx context.Context, form *SearchCMSForm, pagination
|
||||
|
||||
// copyFormToEntity copies data from form to entity
|
||||
func (s *cmsService) copyFormToEntity(form *CMSForm, cms *CMS) {
|
||||
if form.Language != "" {
|
||||
cms.Language = form.Language
|
||||
if form.Type != "" {
|
||||
cms.Type = CMSType(form.Type)
|
||||
}
|
||||
if form.CompanyName != "" {
|
||||
cms.CompanyName = form.CompanyName
|
||||
}
|
||||
if form.Country != "" {
|
||||
cms.Country = form.Country
|
||||
|
||||
switch cms.Type {
|
||||
case CMSTypeCompany:
|
||||
if form.Language != "" {
|
||||
cms.Language = form.Language
|
||||
}
|
||||
if form.CompanyName != "" {
|
||||
cms.CompanyName = form.CompanyName
|
||||
}
|
||||
if form.Country != "" {
|
||||
cms.Country = form.Country
|
||||
}
|
||||
case CMSTypeOrganization:
|
||||
cms.Language = ""
|
||||
cms.CompanyName = ""
|
||||
cms.Country = ""
|
||||
}
|
||||
|
||||
// Hero section
|
||||
if form.Hero.Title != "" {
|
||||
cms.Hero.Title = form.Hero.Title
|
||||
|
||||
Reference in New Issue
Block a user