2025-11-15 17:43:23 +00:00
|
|
|
package mapper
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"jaecoo-be/app/database/entity"
|
|
|
|
|
res "jaecoo-be/app/module/gallery_files/response"
|
2025-11-17 15:44:55 +00:00
|
|
|
"path/filepath"
|
2025-11-15 17:43:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func GalleryFilesResponseMapper(file *entity.GalleryFiles, host string) *res.GalleryFilesResponse {
|
|
|
|
|
if file == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response := &res.GalleryFilesResponse{
|
|
|
|
|
ID: file.ID,
|
|
|
|
|
GalleryID: file.GalleryID,
|
|
|
|
|
Title: file.Title,
|
|
|
|
|
ImagePath: file.ImagePath,
|
|
|
|
|
IsActive: file.IsActive,
|
|
|
|
|
CreatedAt: file.CreatedAt,
|
|
|
|
|
UpdatedAt: file.UpdatedAt,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if file.ImagePath != nil && *file.ImagePath != "" {
|
2025-11-17 15:44:55 +00:00
|
|
|
// Extract filename from path
|
|
|
|
|
filename := filepath.Base(*file.ImagePath)
|
|
|
|
|
imageUrl := host + "/gallery-files/viewer/" + filename
|
2025-11-15 17:43:23 +00:00
|
|
|
response.ImageUrl = &imageUrl
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
}
|
|
|
|
|
|