31 lines
775 B
Go
31 lines
775 B
Go
|
|
package mapper
|
||
|
|
|
||
|
|
import (
|
||
|
|
"jaecoo-be/app/database/entity"
|
||
|
|
res "jaecoo-be/app/module/product_specifications/response"
|
||
|
|
)
|
||
|
|
|
||
|
|
func ProductSpecificationsResponseMapper(spec *entity.ProductSpecifications, host string) *res.ProductSpecificationsResponse {
|
||
|
|
if spec == nil {
|
||
|
|
return nil
|
||
|
|
}
|
||
|
|
|
||
|
|
response := &res.ProductSpecificationsResponse{
|
||
|
|
ID: spec.ID,
|
||
|
|
ProductID: spec.ProductID,
|
||
|
|
Title: spec.Title,
|
||
|
|
ThumbnailPath: spec.ThumbnailPath,
|
||
|
|
IsActive: spec.IsActive,
|
||
|
|
CreatedAt: spec.CreatedAt,
|
||
|
|
UpdatedAt: spec.UpdatedAt,
|
||
|
|
}
|
||
|
|
|
||
|
|
if spec.ThumbnailPath != nil && *spec.ThumbnailPath != "" {
|
||
|
|
thumbnailUrl := host + "/product-specifications/thumbnail/viewer/" + *spec.ThumbnailPath
|
||
|
|
response.ThumbnailUrl = &thumbnailUrl
|
||
|
|
}
|
||
|
|
|
||
|
|
return response
|
||
|
|
}
|
||
|
|
|