From 0a6d50cb60b2f37434f160ea3d5163fdd9b180ef Mon Sep 17 00:00:00 2001 From: nothingnowhere1 Date: Fri, 24 May 2024 05:04:31 +0300 Subject: [PATCH 1/2] stubs --- server/index.js | 1 + server/routers/my/index.js | 11 ++++ .../routers/my/json/catalog-data/success.json | 33 ++++++++++++ .../routers/my/json/item-data/newsuccess.json | 51 +++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 server/routers/my/index.js create mode 100644 server/routers/my/json/catalog-data/success.json create mode 100644 server/routers/my/json/item-data/newsuccess.json diff --git a/server/index.js b/server/index.js index c09b5ab..4fc11d6 100644 --- a/server/index.js +++ b/server/index.js @@ -56,6 +56,7 @@ app.use('/example', require('./routers/example')) // app.use('/car-wash', require('./routers/car-wash')) app.use('/zoom-bar', require('./routers/zoom-bar')) app.use('/r-and-m', require('./routers/r-and-m')) +app.use('/my', require('./routers/my')) app.use('/edateam', require('./routers/edateam')) app.use('/webstar-project', require('./routers/webstar-project')) //app.use('/basket', require('./routers/basket')) diff --git a/server/routers/my/index.js b/server/routers/my/index.js new file mode 100644 index 0000000..9bb5b69 --- /dev/null +++ b/server/routers/my/index.js @@ -0,0 +1,11 @@ +const router = require('express').Router(); + +router.get('/catalog-data', (request, response) => { + response.send(require('./json/catalog-data/success.json')) + }) + +router.get('/catalog-data', (request, response) => { + response.send(require('./json/item-data/newsuccess.json')) +}) + +module.exports = router; diff --git a/server/routers/my/json/catalog-data/success.json b/server/routers/my/json/catalog-data/success.json new file mode 100644 index 0000000..8d58b7c --- /dev/null +++ b/server/routers/my/json/catalog-data/success.json @@ -0,0 +1,33 @@ +{ + "data": [ + [{"photo": "shirt2_1x", + "alt" :"ХУДИ УТЕПЛЕННОЕ", + "name": "ХУДИ УТЕПЛЕННОЕ", + "price": "1500 руб.", + "setphoto": ["shirt2_1x","shirt2_2x", "shirt2_4x"]}, + {"photo": "shirt3_1x", + "alt" :"РУБАШКА МУЖСКАЯ", + "name": "РУБАШКА МУЖСКАЯ", + "price": "1500 руб.", + "setphoto": ["shirt3_1x","shirt3_2x", "shirt3_4x"]}, + {"photo": "shirt4_1x", + "alt" :"ТРЕНЧ ЖЕНСКИЙ", + "name": "ТРЕНЧ ЖЕНСКИЙ", + "price": "1500 руб.", + "setphoto": ["shirt4_1x","shirt4_2x", "shirt4_4x"]}], + [{"photo": "shirt6_1x", + "alt" :"ФУТБОЛКА С ОРНАМЕНТОМ ПЕЙСЛИ", + "name": "ФУТБОЛКА С ОРНАМЕНТОМ ПЕЙСЛИ", + "price": "1500 руб.", + "setphoto": ["shirt6_1x","shirt6_2x", "shirt6_4x"]}, + {"photo": "shirt5_1x", + "alt" :"ЗИП С ПРИНТОМ", + "name": "ЗИП С ПРИНТОМ", + "price": "1500 руб.", + "setphoto": ["shirt5_1x","shirt5_2x", "shirt5_4x"]}, + {"photo": "shirt1_1x", + "alt" :"ФУТБОЛКА С ОРНАМЕНТОМ МОСФИЛЬМ", + "name": "ФУТБОЛКА С ОРНАМЕНТОМ МОСФИЛЬМ", + "price": "1500 руб.", + "setphoto": ["shirt1_1x","shirt1_2x", "shirt1_4x"]}]] +} \ No newline at end of file diff --git a/server/routers/my/json/item-data/newsuccess.json b/server/routers/my/json/item-data/newsuccess.json new file mode 100644 index 0000000..cb70bcc --- /dev/null +++ b/server/routers/my/json/item-data/newsuccess.json @@ -0,0 +1,51 @@ +{ + "data":[ + { + "photo": ["shirt7_1x", "shirt7.1_1x"], + "alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", + "name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", + "price": "1500 руб.", + "setphoto": ["shirt7_1x","shirt7.1_1x","shirt7_2x","shirt7.2_2x", "shirt7_4x", "shirt7.2_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["79653", + "Весна-Лето 2023", + "Черное море", + "без застежки", + "светло-серый", + "100% Хлопок", + "свободный", + "картина", + "удлиненная", + "101-78-96", + "178", + "M (48)", + "без карманов", + "160", + "Женский"] + }, + { + "photo": ["shirt8_1x", "shirt8.2_1x"], + "alt" :"ЗИП МУЖСКОЙ", + "name": "ЗИП МУЖСКОЙ", + "price": "1500 руб.", + "setphoto": ["shirt8_1x","shirt8.2_1x","shirt8_2x","shirt8.1_2x", "shirt8_4x", "shirt8.1_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["7934", + "Весна-Осень 2023", + "Третьяковская галерея", + "с застежкой", + "черный", + "100% Хлопок", + "свободный", + "надпись", + "удлиненная", + "90-80-96", + "182", + "L (50)", + "с карманами", + "160", + "Мужской"] + } + ] + +} \ No newline at end of file From eb87f400eebfffdb09daa43e8f931dc0e7afe5a6 Mon Sep 17 00:00:00 2001 From: nothingnowhere1 Date: Sat, 25 May 2024 12:44:44 +0300 Subject: [PATCH 2/2] edit json files --- server/routers/my/index.js | 27 +++- .../routers/my/json/catalog-data/success.json | 69 +++++---- .../routers/my/json/item-data/newsuccess.json | 136 +++++++++++++++++- 3 files changed, 199 insertions(+), 33 deletions(-) diff --git a/server/routers/my/index.js b/server/routers/my/index.js index 9bb5b69..c2dec2e 100644 --- a/server/routers/my/index.js +++ b/server/routers/my/index.js @@ -1,11 +1,30 @@ const router = require('express').Router(); router.get('/catalog-data', (request, response) => { - response.send(require('./json/catalog-data/success.json')) + response.send(require('./stubs/json/catalog-data/success.json')) }) -router.get('/catalog-data', (request, response) => { - response.send(require('./json/item-data/newsuccess.json')) +router.get('/item-data', (request, response) => { + response.send(require('./stubs/json/catalog-data/newsuccess.json')) }) +router.post('/search', (request, response) => { + const searchTerm = request.body.search.toLowerCase(); -module.exports = router; + try { + const itemsData = require('./stubs/json/catalog-data/newsuccess.json'); + const itemData = itemsData.data.find(item => item.name.toLowerCase().includes(searchTerm)); + + if (itemData) { + return response.json({ data: itemData }); + } else { + console.log('Item not found'); + return response.status(404).send('Item not found'); + } + } catch (error) { + console.error('Error reading file:', error); + return response.status(500).send('Internal server error'); + } +}); + + +module.exports = router; \ No newline at end of file diff --git a/server/routers/my/json/catalog-data/success.json b/server/routers/my/json/catalog-data/success.json index 8d58b7c..38a6285 100644 --- a/server/routers/my/json/catalog-data/success.json +++ b/server/routers/my/json/catalog-data/success.json @@ -1,33 +1,52 @@ { - "data": [ - [{"photo": "shirt2_1x", - "alt" :"ХУДИ УТЕПЛЕННОЕ", - "name": "ХУДИ УТЕПЛЕННОЕ", + "data":[ + [{ + "id": 1, + "photo": "shirt7_1x", + "alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", + "name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", "price": "1500 руб.", - "setphoto": ["shirt2_1x","shirt2_2x", "shirt2_4x"]}, - {"photo": "shirt3_1x", - "alt" :"РУБАШКА МУЖСКАЯ", - "name": "РУБАШКА МУЖСКАЯ", + "setphoto": ["shirt7_1x","shirt7_2x","shirt7_4x"] + }, + { + "id":2, + "photo": "shirt8_1x", + "alt" :"ЗИП МУЖСКОЙ", + "name": "ЗИП МУЖСКОЙ", "price": "1500 руб.", - "setphoto": ["shirt3_1x","shirt3_2x", "shirt3_4x"]}, - {"photo": "shirt4_1x", - "alt" :"ТРЕНЧ ЖЕНСКИЙ", - "name": "ТРЕНЧ ЖЕНСКИЙ", + "setphoto": ["shirt8_1x","shirt8_2x","shirt8_4x"] + }, + { + "id": 3, + "photo": "shirt1_1x", + "alt" :"Фотография футболки белого цвета с цитатой из К/ф Кавказская пленница", + "name": "ФУТБОЛКА С ПРИНТОМ МОСФИЛЬМ", "price": "1500 руб.", - "setphoto": ["shirt4_1x","shirt4_2x", "shirt4_4x"]}], - [{"photo": "shirt6_1x", - "alt" :"ФУТБОЛКА С ОРНАМЕНТОМ ПЕЙСЛИ", - "name": "ФУТБОЛКА С ОРНАМЕНТОМ ПЕЙСЛИ", + "setphoto": ["shirt1_1x","shirt1_2x","shirt1_4x"] + }], + [{ + "id": 4, + "photo": "shirt9_1x", + "alt" :"ЛАВАНДОВОЕ ХУДИ", + "name": "ЛАВАНДОВОЕ ХУДИ", "price": "1500 руб.", - "setphoto": ["shirt6_1x","shirt6_2x", "shirt6_4x"]}, - {"photo": "shirt5_1x", - "alt" :"ЗИП С ПРИНТОМ", - "name": "ЗИП С ПРИНТОМ", + "setphoto": ["shirt9_1x","shirt9_2x","shirt9_4x"] + }, + { + "id": 5, + "photo": "shirt10_1x", + "alt" :"ФУТБОЛКА АНИМЕ", + "name": "ФУТБОЛКА АНИМЕ", "price": "1500 руб.", - "setphoto": ["shirt5_1x","shirt5_2x", "shirt5_4x"]}, - {"photo": "shirt1_1x", - "alt" :"ФУТБОЛКА С ОРНАМЕНТОМ МОСФИЛЬМ", - "name": "ФУТБОЛКА С ОРНАМЕНТОМ МОСФИЛЬМ", + "setphoto": ["shirt10_1x","shirt10_2x","shirt10_4x"] + }, + { + "id": 6, + "photo":"shirt11_1x", + "alt" :"ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА", + "name": "ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА", "price": "1500 руб.", - "setphoto": ["shirt1_1x","shirt1_2x", "shirt1_4x"]}]] + "setphoto": ["shirt11_1x","shirt11_2x", "shirt11_4x"] + }] + ] } \ No newline at end of file diff --git a/server/routers/my/json/item-data/newsuccess.json b/server/routers/my/json/item-data/newsuccess.json index cb70bcc..e454edd 100644 --- a/server/routers/my/json/item-data/newsuccess.json +++ b/server/routers/my/json/item-data/newsuccess.json @@ -1,11 +1,15 @@ { "data":[ { - "photo": ["shirt7_1x", "shirt7.1_1x"], + "id": 1, + "photo": ["shirt7_1x", "shirt7_1_1x"], "alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", "name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", "price": "1500 руб.", - "setphoto": ["shirt7_1x","shirt7.1_1x","shirt7_2x","shirt7.2_2x", "shirt7_4x", "shirt7.2_4x"], + "color" : "Серый", + "colorid" : 7, + "colorcss": ["#606060","#FFFFFF"], + "setphoto": ["shirt7_1x","shirt7_1_1x","shirt7_2x","shirt7_1_2x", "shirt7_4x", "shirt7_1_4x"], "size": ["XS/S","M/L","XL/XLL"], "body": ["79653", "Весна-Лето 2023", @@ -24,11 +28,12 @@ "Женский"] }, { - "photo": ["shirt8_1x", "shirt8.2_1x"], + "id":2, + "photo": ["shirt8_1x", "shirt8_1_1x"], "alt" :"ЗИП МУЖСКОЙ", "name": "ЗИП МУЖСКОЙ", "price": "1500 руб.", - "setphoto": ["shirt8_1x","shirt8.2_1x","shirt8_2x","shirt8.1_2x", "shirt8_4x", "shirt8.1_4x"], + "setphoto": ["shirt8_1x","shirt8_1_1x","shirt8_2x","shirt8_1_2x", "shirt8_4x", "shirt8_1_4x"], "size": ["XS/S","M/L","XL/XLL"], "body": ["7934", "Весна-Осень 2023", @@ -45,6 +50,129 @@ "с карманами", "160", "Мужской"] + }, + { + "id": 3, + "photo": ["shirt1_1x", "shirt1_1_1x"], + "alt" :"Фотография футболки белого цвета с цитатой из К/ф Кавказская пленница", + "name": "Футболка с принтом Мосфильм", + "price": "1500 руб.", + "setphoto": ["shirt1_1x","shirt1_1_1x","shirt1_2x","shirt1_1_2x", "shirt1_4x", "shirt1_1_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["79776", + "Весна-Лето 2021", + "Третьяковская галерея", + "без застежки", + "темно-серый", + "100% Хлопок", + "свободный", + "надписи", + "удлиненная", + "101-78-96", + "189", + "L (50)", + "без карманов", + "160", + "Женский"] + }, + { + "id": 4, + "photo": ["shirt9_1x", "shirt9.1_1x"], + "alt" :"ЛАВАНДОВОЕ ХУДИ", + "name": "ЛАВАНДОВОЕ ХУДИ", + "price": "1500 руб.", + "setphoto": ["shirt9_1x","shirt9.1_1x","shirt9_2x","shirt9.1_2x", "shirt9_4x", "shirt9.1_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["79276", + "Весна-Лето 2021", + "Третьяковская галерея", + "без застежки", + "лавандовы", + "100% Хлопок", + "свободный", + "надписи", + "удлиненная", + "101-78-96", + "184", + "L (50)", + "с карманами", + "160", + "Женский"] + }, + { + "id": 5, + "photo": ["shirt10_1x", "shirt10.1_1x"], + "alt" :"ФУТБОЛКА АНИМЕ", + "name": "ФУТБОЛКА АНИМА", + "price": "1500 руб.", + "setphoto": ["shirt10_1x","shirt10.1_1x","shirt10_2x","shirt10.1_2x", "shirt10_4x", "shirt10.1_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["79276", + "Лето 2024", + "Третьяковская галерея", + "без застежки", + "фистошковый", + "100% Хлопок", + "свободный", + "картина", + "удлиненная", + "101-78-96", + "189", + "L (50)", + "без карманов", + "160", + "Мужской"] + }, + { + "id": 6, + "photo": ["shirt11_1x", "shirt11.1_1x"], + "alt" :"ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА", + "name": "ФУТБОЛКА ОВЕРСАЙЗ С ПРИНТОМ ЭРАРТА", + "price": "1500 руб.", + "setphoto": ["shirt11_1x","shirt11.1_1x","shirt11_2x","shirt11.1_2x", "shirt11_4x", "shirt11.1_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["79276", + "Лето 2024", + "Третьяковская галерея", + "без застежки", + "черный", + "100% Хлопок", + "свободный", + "картина", + "удлиненная", + "101-78-96", + "189", + "L (50)", + "без карманов", + "160", + "Женский"] + }, + { + "id": 7, + "photo": ["shirt7_1x", "shirt7_1_1x"], + "alt" :"ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", + "name": "ФУТБОЛКА 'ЧЕРНОЕ МОРЕ'", + "price": "1500 руб.", + "color" : "Белый", + "colorid" : 1, + "colorcss": ["#606060","#FFFFFF"], + "setphoto": ["shirt7_1x","shirt7_1_1x","shirt7_2x","shirt7_1_2x", "shirt7_4x", "shirt7_1_4x"], + "size": ["XS/S","M/L","XL/XLL"], + "body": ["79653", + "Весна-Лето 2023", + "Черное море", + "без застежки", + "светло-серый", + "100% Хлопок", + "свободный", + "картина", + "удлиненная", + "101-78-96", + "178", + "M (48)", + "без карманов", + "160", + "Женский"] } ]