31 lines
661 B
Go
31 lines
661 B
Go
|
|
package mapper
|
||
|
|
|
||
|
|
import (
|
||
|
|
"jaecoo-be/app/database/entity"
|
||
|
|
res "jaecoo-be/app/module/gallery_files/response"
|
||
|
|
)
|
||
|
|
|
||
|
|
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 != "" {
|
||
|
|
imageUrl := host + "/gallery-files/image/viewer/" + *file.ImagePath
|
||
|
|
response.ImageUrl = &imageUrl
|
||
|
|
}
|
||
|
|
|
||
|
|
return response
|
||
|
|
}
|
||
|
|
|