phanquocdat123 commited on
Commit
3cc9b94
·
verified ·
1 Parent(s): 41e22f0

Create services/assetMapper.js

Browse files
Files changed (1) hide show
  1. services/assetMapper.js +21 -0
services/assetMapper.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // services/assetMapper.js
2
+ const googleSheets = require('./googleSheets');
3
+
4
+ const assetMapper = {
5
+ // Từ mã SP, đi tìm mọi thông tin liên quan để gửi cho khách
6
+ mapProductToAssets: async (productCode) => {
7
+ const product = await googleSheets.getProductInfo(productCode);
8
+
9
+ if (product) {
10
+ return {
11
+ price: product.price,
12
+ // Chuyển ID Drive thành link có thể xem trực tiếp
13
+ imageUrl: `https://lh3.googleusercontent.com/d/${product.driveId}`,
14
+ available: product.stock > 0
15
+ };
16
+ }
17
+ return null;
18
+ }
19
+ };
20
+
21
+ module.exports = assetMapper;