jaecoo-be/app/module/galleries/mapper/galleries.mapper.go

31 lines
739 B
Go
Raw Normal View History

2025-11-15 17:43:23 +00:00
package mapper
import (
"jaecoo-be/app/database/entity"
res "jaecoo-be/app/module/galleries/response"
)
func GalleriesResponseMapper(gallery *entity.Galleries, host string) *res.GalleriesResponse {
if gallery == nil {
return nil
}
response := &res.GalleriesResponse{
ID: gallery.ID,
Title: gallery.Title,
Description: gallery.Description,
ThumbnailPath: gallery.ThumbnailPath,
IsActive: gallery.IsActive,
CreatedAt: gallery.CreatedAt,
UpdatedAt: gallery.UpdatedAt,
}
if gallery.ThumbnailPath != nil && *gallery.ThumbnailPath != "" {
thumbnailUrl := host + "/galleries/thumbnail/viewer/" + *gallery.ThumbnailPath
response.ThumbnailUrl = &thumbnailUrl
}
return response
}