Skip to content

Commit

Permalink
Apply chageImageUrl method
Browse files Browse the repository at this point in the history
  • Loading branch information
devsoopark committed May 28, 2020
1 parent bb94b0e commit 49a7d87
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
21 changes: 15 additions & 6 deletions server/src/services/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class ProductService {
}));

await this.addLikeField(products);
this.changeImageUrl(products);

return { products };
} catch (e) {
Expand Down Expand Up @@ -82,12 +83,18 @@ export default class ProductService {
.skip(skip);
const products = productRecords
.map((record) => record.toObject())
.map((product) => ({
productId: product._id,
productName: product.name,
productImages: product.productImages[0],
salePrice: Number(product.salePrice),
}));
.map((product) => {
const index = product.productNo % 61;
product.productImages[0].url = `https://naver.github.io/egjs-infinitegrid/assets/image/${index}.jpg`;

return {
productId: product._id,
productName: product.name,
productImages: product.productImages[0],
salePrice: Number(product.salePrice),
};
});

return { products };
} catch (e) {
this.logger.error(e);
Expand All @@ -105,6 +112,8 @@ export default class ProductService {
}
let products: IProductDTO[] = [productRecord.toObject()];
await this.addLikeField(products);
this.changeImageUrl(products);

const product = products[0];

return {
Expand Down
1 change: 1 addition & 0 deletions server/src/services/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export default class UserService {
}

await this.productService.addLikeField(result);
this.productService.changeImageUrl(result);

return result;
} catch (e) {
Expand Down

0 comments on commit 49a7d87

Please sign in to comment.