package mapper import ( "jaecoo-be/app/database/entity" res "jaecoo-be/app/module/product_specifications/response" "path/filepath" ) 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 != "" { // Extract filename from path filename := filepath.Base(*spec.ThumbnailPath) thumbnailUrl := host + "/product-specifications/viewer/" + filename response.ThumbnailUrl = &thumbnailUrl } return response }