-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchProduct.rb
148 lines (133 loc) · 5.14 KB
/
SearchProduct.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
require_relative 'Entity/Product';
require_relative 'ProductGroupList';
class SearchProduct
def getByGroupId(productGroupId)
productGroupIdList = self.getProductGroupIds(productGroupId);
list = Array.new();
i = 1;
while (i < productGroupIdList.length()) do
case productGroupIdList[i]
when 1
list = (list + self.getProducts4Group1()).uniq;
when 2
list = (list + self.getProducts4Group2()).uniq;
when 3
list = (list + self.getProducts4Group3()).uniq;
else
result = "No such method";
end
i += 1;
end
return list;
end
# @todo move into the db
def getProducts4Group1()
productList = Array.new();
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/67837080-59c1-43e8-ac95-46859feebb2a_5627faa7-f96b-458c-b6f3-c342ed99716d_large.jpg?v=1488853105',
'Hugo Boss',
['Cotton', 'Polyester']
));
productList.insert(-1,Product.new(
4,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/a0fbc1d2-2f3a-4928-bd4e-2a22eb960ce8_a7bf4f51-a2c8-4d87-a983-a134ad61fda3_large.jpg?v=1488853116',
'Hugo Boss',
['Cotton', 'Polyester']
));
productList.insert(-1,Product.new(
4,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/ffb36633-7f3e-4ac2-8eda-3f5f6c774210_ed99c2b3-24df-4e3b-9f77-518e3d7d5f12_large.jpg?v=1488853174',
'Hugo Boss',
['Cotton', 'Polyester']
));
return productList;
end
# @todo move into the db
def getProducts4Group2()
productList = Array.new();
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/03_ce982bf6-365f-4ad6-8636-208b6b5416fa_large.jpg?v=1488852960',
'Armani',
['Polyester']
));
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/9cff613a-357b-4bd1-996d-8e90c34a267a_a802075d-f427-4dbc-a595-80e51f13fbb8_large.jpg?v=1488853154',
'Armani',
['Polyester']
));
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/047ed2fd-34be-4991-87b9-ef05e226351b_9e684167-a75f-451d-88eb-72c147b8801c_large.jpg?v=1508922347',
'Armani',
['Polyester']
));
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/3b8314cd-d1d4-4713-9f39-2f8dd3c4148e_0ae2e3d4-e394-48cd-8c95-dd1acbb23562_large.jpg?v=1488853225',
'Armani',
['Polyester']
));
return productList;
end
# @todo move into the db
def getProducts4Group3()
productList = Array.new();
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/03_ce982bf6-365f-4ad6-8636-208b6b5416fa_large.jpg?v=1488852960',
'Hugo Boss',
['Cotton']
));
productList.insert(-1,Product.new(
3,
'Schuhe',
['L'],
'Cras in nunc non ipsum duo cursus ultrices est',
'/collections/men/products/cras-in-nunc-non-ipsum-duo-cursus-ultrices',
'//cdn.shopify.com/s/files/1/1825/4753/products/bfb56c35-1919-4407-ac3d-b7868789da08_d3b42852-7665-4a74-a2e1-10ba22604dd2_large.jpg?v=1488853080',
'Hugo Boss',
['Cotton']
));
return productList;
end
def getProductGroupIds(id)
productGroupList = ProductGroupList.new();
productGroup = productGroupList.get().findGroupById(id);
return productGroup.getAllGroupIds();
end
end