31 lines
769 B
Go
31 lines
769 B
Go
package mapper
|
|
|
|
import (
|
|
"jaecoo-be/app/database/entity"
|
|
res "jaecoo-be/app/module/promotions/response"
|
|
)
|
|
|
|
func PromotionsResponseMapper(promotion *entity.Promotions, host string) *res.PromotionsResponse {
|
|
if promotion == nil {
|
|
return nil
|
|
}
|
|
|
|
response := &res.PromotionsResponse{
|
|
ID: promotion.ID,
|
|
Title: promotion.Title,
|
|
Description: promotion.Description,
|
|
ThumbnailPath: promotion.ThumbnailPath,
|
|
IsActive: promotion.IsActive,
|
|
CreatedAt: promotion.CreatedAt,
|
|
UpdatedAt: promotion.UpdatedAt,
|
|
}
|
|
|
|
if promotion.ThumbnailPath != nil && *promotion.ThumbnailPath != "" {
|
|
thumbnailUrl := host + "/promotions/thumbnail/viewer/" + *promotion.ThumbnailPath
|
|
response.ThumbnailUrl = &thumbnailUrl
|
|
}
|
|
|
|
return response
|
|
}
|
|
|