| 21577 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 22486 |
ashik.ali |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
|
|
5 |
import java.io.InputStream;
|
| 23886 |
amit.gupta |
6 |
import java.time.LocalDateTime;
|
| 21577 |
ashik.ali |
7 |
import java.util.List;
|
| 21654 |
ashik.ali |
8 |
import java.util.Map;
|
| 21577 |
ashik.ali |
9 |
|
|
|
10 |
import javax.servlet.http.HttpServletRequest;
|
| 21987 |
kshitij.so |
11 |
import javax.servlet.http.HttpServletResponse;
|
| 21577 |
ashik.ali |
12 |
|
| 23886 |
amit.gupta |
13 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
14 |
import org.apache.logging.log4j.Logger;
|
| 21577 |
ashik.ali |
15 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23784 |
ashik.ali |
16 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 21987 |
kshitij.so |
17 |
import org.springframework.beans.factory.annotation.Value;
|
| 22486 |
ashik.ali |
18 |
import org.springframework.core.io.InputStreamResource;
|
| 23886 |
amit.gupta |
19 |
import org.springframework.format.annotation.DateTimeFormat;
|
|
|
20 |
import org.springframework.format.annotation.DateTimeFormat.ISO;
|
| 22486 |
ashik.ali |
21 |
import org.springframework.http.HttpHeaders;
|
|
|
22 |
import org.springframework.http.HttpStatus;
|
| 22472 |
ashik.ali |
23 |
import org.springframework.http.ResponseEntity;
|
| 21577 |
ashik.ali |
24 |
import org.springframework.stereotype.Controller;
|
| 21654 |
ashik.ali |
25 |
import org.springframework.transaction.annotation.Transactional;
|
| 21577 |
ashik.ali |
26 |
import org.springframework.ui.Model;
|
| 22472 |
ashik.ali |
27 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21577 |
ashik.ali |
28 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 22472 |
ashik.ali |
29 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21577 |
ashik.ali |
30 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
31 |
|
| 21987 |
kshitij.so |
32 |
import com.google.gson.Gson;
|
| 21577 |
ashik.ali |
33 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 21612 |
ashik.ali |
34 |
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
|
| 24106 |
tejbeer |
35 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22472 |
ashik.ali |
36 |
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
|
| 24106 |
tejbeer |
37 |
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
|
|
|
38 |
import com.spice.profitmandi.common.model.NotificationDataModel;
|
| 21577 |
ashik.ali |
39 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22472 |
ashik.ali |
40 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 21987 |
kshitij.so |
41 |
import com.spice.profitmandi.common.util.Utils;
|
| 24123 |
tejbeer |
42 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 24106 |
tejbeer |
43 |
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
|
|
|
44 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
|
|
45 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
|
|
46 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| 24123 |
tejbeer |
47 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 24106 |
tejbeer |
48 |
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
|
| 22927 |
ashik.ali |
49 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22139 |
amit.gupta |
50 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 22069 |
ashik.ali |
51 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24106 |
tejbeer |
52 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 21577 |
ashik.ali |
53 |
|
|
|
54 |
@Controller
|
| 24123 |
tejbeer |
55 |
@Transactional(rollbackFor = Throwable.class)
|
| 21577 |
ashik.ali |
56 |
public class InventoryController {
|
| 21987 |
kshitij.so |
57 |
|
| 23568 |
govind |
58 |
private static final Logger LOGGER = LogManager.getLogger(InventoryController.class);
|
| 21987 |
kshitij.so |
59 |
|
| 21577 |
ashik.ali |
60 |
@Autowired
|
| 22927 |
ashik.ali |
61 |
private CookiesProcessor cookiesProcessor;
|
| 24123 |
tejbeer |
62 |
|
| 22354 |
ashik.ali |
63 |
@Autowired
|
| 23784 |
ashik.ali |
64 |
@Qualifier("fofoInventoryService")
|
| 22927 |
ashik.ali |
65 |
private InventoryService inventoryService;
|
| 24123 |
tejbeer |
66 |
|
| 24106 |
tejbeer |
67 |
@Autowired
|
|
|
68 |
private TagRankingRepository tagRankingRepository;
|
| 24123 |
tejbeer |
69 |
|
| 24106 |
tejbeer |
70 |
@Autowired
|
| 24123 |
tejbeer |
71 |
private ItemRepository itemRepository;
|
|
|
72 |
|
|
|
73 |
@Autowired
|
| 24106 |
tejbeer |
74 |
private MVCResponseSender mvcResponseSender;
|
| 24123 |
tejbeer |
75 |
|
| 21987 |
kshitij.so |
76 |
@Value("${saholic.api.host}")
|
|
|
77 |
private String host;
|
| 23786 |
amit.gupta |
78 |
|
| 21987 |
kshitij.so |
79 |
@Value("${saholic.api.port}")
|
|
|
80 |
private int port;
|
| 23786 |
amit.gupta |
81 |
|
| 21987 |
kshitij.so |
82 |
@Value("${saholic.api.webapp}")
|
|
|
83 |
private String webapp;
|
|
|
84 |
|
| 23786 |
amit.gupta |
85 |
@RequestMapping(value = "/getCurrentInventorySnapshot")
|
|
|
86 |
public String getCurrentAvailability(HttpServletRequest request,
|
|
|
87 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
88 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| 24123 |
tejbeer |
89 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| 23786 |
amit.gupta |
90 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
91 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
92 |
Map<String, Object> map = inventoryService.getCurrentInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
93 |
searchTerm);
|
| 22927 |
ashik.ali |
94 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
95 |
return "inventory-snapshot";
|
| 21612 |
ashik.ali |
96 |
}
|
| 21987 |
kshitij.so |
97 |
|
| 23786 |
amit.gupta |
98 |
@RequestMapping(value = "/getBadInventorySnapshot")
|
|
|
99 |
public String getBadAvailability(HttpServletRequest request,
|
|
|
100 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
101 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
102 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
103 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
104 |
if (searchTerm == null) {
|
|
|
105 |
searchTerm = "";
|
| 24052 |
amit.gupta |
106 |
}
|
| 22927 |
ashik.ali |
107 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
108 |
Map<String, Object> map = inventoryService.getBadInventorySnapshot(loginDetails.getFofoId(), offset, limit,
|
|
|
109 |
searchTerm);
|
| 22927 |
ashik.ali |
110 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
111 |
return "bad-inventory-snapshot";
|
|
|
112 |
}
|
|
|
113 |
|
| 23786 |
amit.gupta |
114 |
@RequestMapping(value = "/getPaginatedCurrentInventorySnapshot")
|
|
|
115 |
public String getPaginatedCurrentInventorySnapshot(HttpServletRequest request,
|
|
|
116 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
117 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
118 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
119 |
throws ProfitMandiBusinessException {
|
| 24123 |
tejbeer |
120 |
if (searchTerm == null) {
|
|
|
121 |
searchTerm = "";
|
| 24052 |
amit.gupta |
122 |
}
|
| 22927 |
ashik.ali |
123 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
124 |
Map<String, Object> map = inventoryService.getPaginatedCurrentInventorySnapshot(loginDetails.getFofoId(),
|
|
|
125 |
offset, limit, searchTerm);
|
| 22927 |
ashik.ali |
126 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
127 |
return "inventory-snapshot-paginated";
|
|
|
128 |
}
|
| 23786 |
amit.gupta |
129 |
|
|
|
130 |
@RequestMapping(value = "/getCatalog")
|
|
|
131 |
public String getCatalog(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
132 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
133 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
134 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
135 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
136 |
if (searchTerm == null) {
|
|
|
137 |
searchTerm = "";
|
| 24052 |
amit.gupta |
138 |
}
|
| 22927 |
ashik.ali |
139 |
Map<String, Object> map = inventoryService.getCatalog(loginDetails.getFofoId(), offset, limit, searchTerm);
|
|
|
140 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
141 |
return "catalog";
|
|
|
142 |
}
|
| 23786 |
amit.gupta |
143 |
|
|
|
144 |
@RequestMapping(value = "/getPaginatedCatalog")
|
|
|
145 |
public String getCatalogPaginated(HttpServletRequest request,
|
|
|
146 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
147 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
148 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
|
|
149 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
150 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
151 |
if (searchTerm == null) {
|
|
|
152 |
searchTerm = "";
|
| 24052 |
amit.gupta |
153 |
}
|
| 23786 |
amit.gupta |
154 |
Map<String, Object> map = inventoryService.getPaginatedCatalog(loginDetails.getFofoId(), offset, limit,
|
|
|
155 |
searchTerm);
|
| 22927 |
ashik.ali |
156 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
157 |
return "catalog-paginated";
|
|
|
158 |
}
|
|
|
159 |
|
| 23786 |
amit.gupta |
160 |
@RequestMapping(value = "/checkItemAvailability")
|
|
|
161 |
public String getItemAvailability(HttpServletRequest request,
|
|
|
162 |
@RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, Model model)
|
|
|
163 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
164 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
165 |
CustomCurrentInventorySnapshot customCurrentInventorySnapshot = inventoryService.checkItemAvailability(itemId,
|
|
|
166 |
loginDetails.getFofoId());
|
|
|
167 |
customCurrentInventorySnapshot
|
|
|
168 |
.setIconUrl(Utils.getIconUrl(customCurrentInventorySnapshot.getCatalogItemId(), host, port, webapp));
|
| 22927 |
ashik.ali |
169 |
model.addAttribute("currentInventorySnapshot", new Gson().toJson(customCurrentInventorySnapshot));
|
|
|
170 |
return "current-item-availability";
|
| 23786 |
amit.gupta |
171 |
|
| 21577 |
ashik.ali |
172 |
}
|
| 23786 |
amit.gupta |
173 |
|
| 23192 |
ashik.ali |
174 |
@RequestMapping(value = "/cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
175 |
public String addToCart(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model)
|
|
|
176 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
177 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
178 |
|
| 22927 |
ashik.ali |
179 |
Map<String, Object> map = inventoryService.addToCart(cartData, loginDetails.getFofoId());
|
|
|
180 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
181 |
return "cart";
|
|
|
182 |
}
|
| 23786 |
amit.gupta |
183 |
|
| 23192 |
ashik.ali |
184 |
@RequestMapping(value = "/validate-cart", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
185 |
public String validateCart(HttpServletRequest request, HttpServletResponse response,
|
|
|
186 |
@RequestParam(name = "cartData") String cartData, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
187 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
188 |
|
| 22927 |
ashik.ali |
189 |
Map<String, Object> map = inventoryService.validateCart(cartData, loginDetails.getFofoId());
|
|
|
190 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
191 |
return "validate-cart";
|
|
|
192 |
}
|
|
|
193 |
|
| 23786 |
amit.gupta |
194 |
@RequestMapping(value = "/grnHistory")
|
| 24123 |
tejbeer |
195 |
public String getGrnHistory(HttpServletRequest request, @RequestParam(required = false) LocalDateTime startTime,
|
| 23886 |
amit.gupta |
196 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
197 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
198 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
199 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
200 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
201 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
202 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
203 |
Map<String, Object> map = inventoryService.getGrnHistory(loginDetails.getFofoId(), startTime, endTime, offset,
|
|
|
204 |
limit, purchaseReference, searchType);
|
| 22927 |
ashik.ali |
205 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
206 |
return "grn-history";
|
| 21636 |
ashik.ali |
207 |
}
|
| 21987 |
kshitij.so |
208 |
|
| 23786 |
amit.gupta |
209 |
@RequestMapping(value = "/getPaginatedGrnHistory")
|
|
|
210 |
public String getPaginatedGrnHistory(HttpServletRequest request,
|
| 23886 |
amit.gupta |
211 |
@RequestParam(required = false) LocalDateTime startTime,
|
|
|
212 |
@RequestParam(required = false) LocalDateTime endTime,
|
| 23786 |
amit.gupta |
213 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
214 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
215 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE, defaultValue = "") String purchaseReference,
|
|
|
216 |
@RequestParam(name = "searchType", defaultValue = "") String searchType, Model model)
|
|
|
217 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
218 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24123 |
tejbeer |
219 |
Map<String, Object> map = inventoryService.getPaginatedGrnHistory(loginDetails.getFofoId(), startTime, endTime,
|
|
|
220 |
offset, limit);
|
| 22927 |
ashik.ali |
221 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
222 |
return "grn-history-paginated";
|
|
|
223 |
}
|
|
|
224 |
|
| 23786 |
amit.gupta |
225 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseId")
|
|
|
226 |
public String grnHistoryByPurchaseId(HttpServletRequest request,
|
|
|
227 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_ID) int purchaseId, Model model)
|
|
|
228 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
229 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
230 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseId, host, port,
|
|
|
231 |
webapp);
|
| 22927 |
ashik.ali |
232 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
233 |
return "grn-details";
|
| 21636 |
ashik.ali |
234 |
}
|
| 21987 |
kshitij.so |
235 |
|
| 23786 |
amit.gupta |
236 |
@RequestMapping(value = "/grnHistoryDetailByPurchaseReference")
|
|
|
237 |
public String grnHistoryByPurchaseReference(HttpServletRequest request,
|
|
|
238 |
@RequestParam(name = ProfitMandiConstants.PURCHASE_REFERENCE) String purchaseReference, Model model)
|
|
|
239 |
throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
240 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
241 |
Map<String, Object> map = inventoryService.getGrnHistoryDetail(loginDetails.getFofoId(), purchaseReference,
|
|
|
242 |
host, port, webapp);
|
| 22927 |
ashik.ali |
243 |
model.addAllAttributes(map);
|
| 21987 |
kshitij.so |
244 |
return "grn-details";
|
| 21654 |
ashik.ali |
245 |
}
|
| 23786 |
amit.gupta |
246 |
|
| 22472 |
ashik.ali |
247 |
@RequestMapping(value = "/getInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
248 |
public String getInventoryItemAgingByInterval(HttpServletRequest request, @RequestBody List<Integer> intervals,
|
|
|
249 |
Model model, @RequestParam(name = "searchContent", defaultValue = "") String searchContent,
|
|
|
250 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
251 |
@RequestParam(name = "limit", defaultValue = "10") int limit) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
252 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
253 |
Map<String, Object> map = inventoryService.getPaginatedItemAgingByInterval(loginDetails.getFofoId(), intervals,
|
|
|
254 |
searchContent, offset, limit);
|
| 22927 |
ashik.ali |
255 |
model.addAllAttributes(map);
|
| 22523 |
ashik.ali |
256 |
return "item-aging";
|
|
|
257 |
}
|
| 23786 |
amit.gupta |
258 |
|
| 22523 |
ashik.ali |
259 |
@RequestMapping(value = "/downloadInventoryItemAgingByInterval", method = RequestMethod.POST)
|
| 23786 |
amit.gupta |
260 |
public ResponseEntity<?> downloadInventoryItemAgingByInterval(HttpServletRequest request,
|
|
|
261 |
@RequestBody List<Integer> intervals, Model model) throws ProfitMandiBusinessException {
|
| 22927 |
ashik.ali |
262 |
LOGGER.info("Request received at url{} with body {}", request.getRequestURI(), intervals);
|
|
|
263 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 23786 |
amit.gupta |
264 |
|
|
|
265 |
List<InventoryItemAgingModel> inventoryItemAgingModels = inventoryService
|
|
|
266 |
.getItemAgingByInterval(fofoDetails.getFofoId(), intervals);
|
|
|
267 |
|
| 22486 |
ashik.ali |
268 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
269 |
ExcelUtils.writeInventoryItemAgingModels(inventoryItemAgingModels, intervals, byteArrayOutputStream);
|
| 23786 |
amit.gupta |
270 |
|
|
|
271 |
final HttpHeaders headers = new HttpHeaders();
|
|
|
272 |
// private static final String CONTENT_TYPE_XLSX =
|
|
|
273 |
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
274 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
275 |
// headers.set("Content-Type", "application/vnd.ms-excel");
|
| 22486 |
ashik.ali |
276 |
headers.set("Content-disposition", "inline; filename=InventoryItemAging.xlsx");
|
| 23786 |
amit.gupta |
277 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
|
|
278 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
279 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
|
|
280 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
281 |
|
| 24123 |
tejbeer |
282 |
// return
|
|
|
283 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 22472 |
ashik.ali |
284 |
}
|
| 24123 |
tejbeer |
285 |
|
| 24106 |
tejbeer |
286 |
@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
|
| 24123 |
tejbeer |
287 |
public String FeaturePanel(HttpServletRequest request,
|
|
|
288 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24106 |
tejbeer |
289 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 21987 |
kshitij.so |
290 |
|
| 24106 |
tejbeer |
291 |
List<TagRanking> tagRanking = null;
|
|
|
292 |
|
|
|
293 |
long size = 0;
|
| 24123 |
tejbeer |
294 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
|
|
295 |
size = tagRankingRepository.selectAllCount();
|
| 24106 |
tejbeer |
296 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
297 |
if (!tagRanking.isEmpty()) {
|
| 24123 |
tejbeer |
298 |
model.addAttribute("tagRanking", tagRanking);
|
| 24106 |
tejbeer |
299 |
model.addAttribute("start", offset + 1);
|
|
|
300 |
model.addAttribute("size", size);
|
|
|
301 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
302 |
|
|
|
303 |
if (tagRanking.size() < limit) {
|
|
|
304 |
model.addAttribute("end", offset + tagRanking.size());
|
|
|
305 |
} else {
|
|
|
306 |
model.addAttribute("end", offset + limit);
|
|
|
307 |
}
|
|
|
308 |
} else {
|
|
|
309 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
310 |
model.addAttribute("size", size);
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
return "feature";
|
|
|
314 |
|
|
|
315 |
}
|
| 24123 |
tejbeer |
316 |
|
| 24106 |
tejbeer |
317 |
@RequestMapping(value = "/getPaginatedfeature", method = RequestMethod.GET)
|
|
|
318 |
public String getPaginatedFeaturePanel(HttpServletRequest request,
|
|
|
319 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
320 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
|
|
321 |
throws ProfitMandiBusinessException {
|
|
|
322 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
323 |
List<TagRanking> tagRanking = null;
|
|
|
324 |
|
|
|
325 |
long size = 0;
|
| 24123 |
tejbeer |
326 |
tagRanking = tagRankingRepository.selectAllTagRanking(offset, limit);
|
| 24106 |
tejbeer |
327 |
if (!tagRanking.isEmpty()) {
|
| 24123 |
tejbeer |
328 |
|
| 24106 |
tejbeer |
329 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
330 |
model.addAttribute("start", offset + 1);
|
|
|
331 |
model.addAttribute("size", size);
|
|
|
332 |
model.addAttribute("url", "/getPaginatedfeature");
|
|
|
333 |
|
|
|
334 |
} else {
|
|
|
335 |
model.addAttribute("tagRanking", tagRanking);
|
|
|
336 |
}
|
|
|
337 |
return "feature-paginated";
|
|
|
338 |
}
|
| 24123 |
tejbeer |
339 |
|
| 24106 |
tejbeer |
340 |
@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
|
| 24123 |
tejbeer |
341 |
public String Itemfeature(HttpServletRequest request, @RequestBody ItemFeatureDataModel itemFeatureDatatModel,
|
|
|
342 |
Model model) throws Exception {
|
| 24106 |
tejbeer |
343 |
|
|
|
344 |
TagRanking tagRanking = new TagRanking();
|
|
|
345 |
tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
|
|
|
346 |
tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
|
|
|
347 |
tagRanking.setFeature(itemFeatureDatatModel.getFeature());
|
| 24123 |
tejbeer |
348 |
|
|
|
349 |
LOGGER.info("tagRanking" + tagRanking);
|
|
|
350 |
tagRankingRepository.persist(tagRanking);
|
| 24106 |
tejbeer |
351 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
352 |
return "response";
|
|
|
353 |
}
|
|
|
354 |
|
| 21577 |
ashik.ali |
355 |
}
|