35 lines
962 B
Go
35 lines
962 B
Go
|
|
package mapper
|
||
|
|
|
||
|
|
import (
|
||
|
|
"web-qudo-be/app/database/entity"
|
||
|
|
imageMapper "web-qudo-be/app/module/popup_news_content_images/mapper"
|
||
|
|
imageRes "web-qudo-be/app/module/popup_news_content_images/response"
|
||
|
|
res "web-qudo-be/app/module/popup_news_contents/response"
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
func PopupNewsContentsResponseMapper(req *entity.PopupNewsContents) (resData *res.PopupNewsContentsResponse) {
|
||
|
|
if req != nil {
|
||
|
|
|
||
|
|
// 🔥 mapping images
|
||
|
|
var images []imageRes.PopupNewsContentImagesResponse
|
||
|
|
for _, img := range req.Images {
|
||
|
|
mapped := imageMapper.PopupNewsContentImagesResponseMapper(&img)
|
||
|
|
if mapped != nil {
|
||
|
|
images = append(images, *mapped)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
resData = &res.PopupNewsContentsResponse{
|
||
|
|
ID: req.ID,
|
||
|
|
PrimaryTitle: req.PrimaryTitle,
|
||
|
|
SecondaryTitle: req.SecondaryTitle,
|
||
|
|
Description: req.Description,
|
||
|
|
PrimaryCTA: req.PrimaryCTA,
|
||
|
|
SecondaryCTAText: req.SecondaryCTAText,
|
||
|
|
Images: images,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|