| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.File;
|
3 |
import java.io.File;
|
| 4 |
import java.io.FileInputStream;
|
4 |
import java.io.FileInputStream;
|
| 5 |
import java.io.FileNotFoundException;
|
5 |
import java.io.FileNotFoundException;
|
| - |
|
6 |
import java.time.LocalDateTime;
|
| 6 |
import java.util.ArrayList;
|
7 |
import java.util.ArrayList;
|
| 7 |
import java.util.List;
|
8 |
import java.util.List;
|
| 8 |
import java.util.Map;
|
9 |
import java.util.Map;
|
| - |
|
10 |
import java.util.stream.Collectors;
|
| 9 |
|
11 |
|
| 10 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 11 |
|
13 |
|
| 12 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 13 |
import org.apache.logging.log4j.LogManager;
|
14 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
15 |
import org.apache.logging.log4j.Logger;
|
| - |
|
16 |
import org.json.JSONObject;
|
| 14 |
import org.springframework.beans.factory.annotation.Autowired;
|
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
18 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 15 |
import org.springframework.core.io.InputStreamResource;
|
19 |
import org.springframework.core.io.InputStreamResource;
|
| 16 |
import org.springframework.http.HttpHeaders;
|
20 |
import org.springframework.http.HttpHeaders;
|
| 17 |
import org.springframework.http.HttpStatus;
|
21 |
import org.springframework.http.HttpStatus;
|
| 18 |
import org.springframework.http.ResponseEntity;
|
22 |
import org.springframework.http.ResponseEntity;
|
| 19 |
import org.springframework.stereotype.Controller;
|
23 |
import org.springframework.stereotype.Controller;
|
| Line 30... |
Line 34... |
| 30 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
34 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 32 |
import com.spice.profitmandi.common.model.AddLocationModel;
|
36 |
import com.spice.profitmandi.common.model.AddLocationModel;
|
| 33 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
37 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 34 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
38 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 35 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
39 |
import com.spice.profitmandi.common.model.PromoterDetailModel;
|
| 36 |
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
|
40 |
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
|
| 37 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 38 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
41 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 39 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
42 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 40 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
43 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 41 |
import com.spice.profitmandi.dao.entity.dtr.Shop;
|
44 |
import com.spice.profitmandi.dao.entity.dtr.Shop;
|
| 42 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
45 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 43 |
import com.spice.profitmandi.dao.entity.fofo.InActiveFofoStore;
|
46 |
import com.spice.profitmandi.dao.entity.fofo.InActiveFofoStore;
|
| 44 |
import com.spice.profitmandi.dao.entity.user.User;
|
- |
|
| 45 |
import com.spice.profitmandi.dao.entity.user.Location;
|
47 |
import com.spice.profitmandi.dao.entity.user.Location;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
| - |
|
49 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 46 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
50 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 47 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
51 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
52 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 48 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
53 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
|
54 |
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
|
| 50 |
import com.spice.profitmandi.dao.repository.user.LocationRepository;
|
55 |
import com.spice.profitmandi.dao.repository.user.LocationRepository;
|
| - |
|
56 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| 51 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
57 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| - |
|
58 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 52 |
import com.spice.profitmandi.service.user.RetailerService;
|
59 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 53 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
60 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 54 |
|
61 |
|
| 55 |
@Controller
|
62 |
@Controller
|
| 56 |
@Transactional(rollbackFor = Throwable.class)
|
63 |
@Transactional(rollbackFor = Throwable.class)
|
| Line 72... |
Line 79... |
| 72 |
|
79 |
|
| 73 |
@Autowired
|
80 |
@Autowired
|
| 74 |
private DocumentRepository documentRepository;
|
81 |
private DocumentRepository documentRepository;
|
| 75 |
|
82 |
|
| 76 |
@Autowired
|
83 |
@Autowired
|
| - |
|
84 |
@Qualifier("userUserRepository")
|
| 77 |
private UserRepository userRepository;
|
85 |
private UserRepository userRepository;
|
| 78 |
|
86 |
|
| 79 |
@Autowired
|
87 |
@Autowired
|
| 80 |
private LocationRepository locationRepository;
|
88 |
private LocationRepository locationRepository;
|
| 81 |
|
89 |
|
| Line 83... |
Line 91... |
| 83 |
private ResponseSender<?> responseSender;
|
91 |
private ResponseSender<?> responseSender;
|
| 84 |
|
92 |
|
| 85 |
@Autowired
|
93 |
@Autowired
|
| 86 |
private MVCResponseSender mvcResponseSender;
|
94 |
private MVCResponseSender mvcResponseSender;
|
| 87 |
|
95 |
|
| - |
|
96 |
@Autowired
|
| - |
|
97 |
private InventoryService inventoryService;
|
| - |
|
98 |
|
| - |
|
99 |
@Autowired
|
| - |
|
100 |
private PromoterRepository promoterRepository;
|
| - |
|
101 |
|
| - |
|
102 |
@Autowired
|
| - |
|
103 |
private Mongo mongoClient;
|
| - |
|
104 |
|
| 88 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
|
105 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
|
| 89 |
public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request,
|
106 |
public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request,
|
| 90 |
@RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
|
107 |
@RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
|
| 91 |
Model model) throws ProfitMandiBusinessException {
|
108 |
Model model) throws ProfitMandiBusinessException {
|
| 92 |
LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(),
|
109 |
LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(),
|
| 93 |
emailIdOrMobileNumber);
|
110 |
emailIdOrMobileNumber);
|
| 94 |
Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
|
111 |
Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
|
| 95 |
model.addAllAttributes(map);
|
112 |
model.addAllAttributes(map);
|
| 96 |
model.addAttribute("counterSizes", CounterSize.values());
|
113 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 97 |
if(map.containsKey("retailer")) {
|
114 |
if (map.containsKey("retailer")) {
|
| 98 |
Retailer retailer = (Retailer)map.get("retailer");
|
115 |
Retailer retailer = (Retailer) map.get("retailer");
|
| 99 |
User user = userRepository.selectById(retailer.getId());
|
116 |
User user = userRepository.selectById(retailer.getId());
|
| 100 |
if (user.getLocation() != null) {
|
117 |
if (user.getLocation() != null) {
|
| 101 |
Location location = locationRepository.selectById(user.getLocation());
|
118 |
Location location = locationRepository.selectById(user.getLocation());
|
| 102 |
model.addAttribute("locationdetail", location);
|
119 |
model.addAttribute("locationdetail", location);
|
| 103 |
LOGGER.info("location" + location);
|
120 |
LOGGER.info("location" + location);
|
| 104 |
}
|
121 |
}
|
| 105 |
}
|
122 |
}
|
| 106 |
|
- |
|
| 107 |
return "retailer-details";
|
123 |
return "retailer-details";
|
| 108 |
}
|
124 |
}
|
| 109 |
|
125 |
|
| 110 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
|
126 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
|
| 111 |
public String updateRetailerDetails(HttpServletRequest request,
|
127 |
public String updateRetailerDetails(HttpServletRequest request,
|
| Line 161... |
Line 177... |
| 161 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
177 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
| 162 |
} catch (FileNotFoundException e) {
|
178 |
} catch (FileNotFoundException e) {
|
| 163 |
LOGGER.error("Retailer Document file not found : ", e);
|
179 |
LOGGER.error("Retailer Document file not found : ", e);
|
| 164 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
180 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
| 165 |
}
|
181 |
}
|
| 166 |
// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
182 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
| - |
|
183 |
// ByteArrayOutputStream();
|
| 167 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
184 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
| 168 |
|
185 |
|
| 169 |
final HttpHeaders headers = new HttpHeaders();
|
186 |
final HttpHeaders headers = new HttpHeaders();
|
| 170 |
String contentType = "";
|
187 |
String contentType = "";
|
| 171 |
if (document.getContentType() == ContentType.JPEG) {
|
188 |
if (document.getContentType() == ContentType.JPEG) {
|
| Line 179... |
Line 196... |
| 179 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
196 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
| 180 |
headers.setContentLength(document.getSize());
|
197 |
headers.setContentLength(document.getSize());
|
| 181 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
198 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
| 182 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
199 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 183 |
|
200 |
|
| - |
|
201 |
// return
|
| 184 |
// return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
202 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 185 |
}
|
203 |
}
|
| 186 |
|
204 |
|
| 187 |
@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
|
205 |
@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
|
| 188 |
public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request,
|
206 |
public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request,
|
| 189 |
@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
|
207 |
@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
|
| Line 225... |
Line 243... |
| 225 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
243 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
| 226 |
} catch (FileNotFoundException e) {
|
244 |
} catch (FileNotFoundException e) {
|
| 227 |
LOGGER.error("Retailer Document file not found : ", e);
|
245 |
LOGGER.error("Retailer Document file not found : ", e);
|
| 228 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
246 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
| 229 |
}
|
247 |
}
|
| 230 |
// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
248 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
| - |
|
249 |
// ByteArrayOutputStream();
|
| 231 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
250 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
| 232 |
|
251 |
|
| 233 |
final HttpHeaders headers = new HttpHeaders();
|
252 |
final HttpHeaders headers = new HttpHeaders();
|
| 234 |
String contentType = "";
|
253 |
String contentType = "";
|
| 235 |
if (document.getContentType() == ContentType.JPEG) {
|
254 |
if (document.getContentType() == ContentType.JPEG) {
|
| Line 243... |
Line 262... |
| 243 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
262 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
| 244 |
headers.setContentLength(document.getSize());
|
263 |
headers.setContentLength(document.getSize());
|
| 245 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
264 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
| 246 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
265 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 247 |
|
266 |
|
| 248 |
// return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
- |
|
| 249 |
}
|
- |
|
| 250 |
|
- |
|
| 251 |
@RequestMapping(value = "/getAddLocation", method = RequestMethod.GET)
|
- |
|
| 252 |
public String getAddLocationModal(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 253 |
model.addAttribute("stateNames", Utils.getAllStateNames());
|
- |
|
| 254 |
|
- |
|
| 255 |
return "add-location-modal";
|
- |
|
| 256 |
}
|
- |
|
| 257 |
|
- |
|
| 258 |
@RequestMapping(value = "/addLocation", method = RequestMethod.POST)
|
- |
|
| 259 |
public String addLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel, Model model)
|
- |
|
| 260 |
throws Exception {
|
267 |
// return
|
| 261 |
|
- |
|
| 262 |
Location location = new Location();
|
- |
|
| 263 |
location.setName(addLocationModel.getName());
|
- |
|
| 264 |
location.setLine1(addLocationModel.getLine1());
|
- |
|
| 265 |
location.setLine2(addLocationModel.getLine2());
|
- |
|
| 266 |
location.setCity(addLocationModel.getCity());
|
- |
|
| 267 |
location.setState(addLocationModel.getState());
|
- |
|
| 268 |
location.setPin(addLocationModel.getPin());
|
- |
|
| 269 |
|
- |
|
| 270 |
LOGGER.info("PostLocation" + location);
|
- |
|
| 271 |
locationRepository.persist(location);
|
- |
|
| 272 |
|
- |
|
| 273 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
268 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 274 |
return "response";
|
- |
|
| 275 |
|
- |
|
| 276 |
}
|
269 |
}
|
| 277 |
|
270 |
|
| 278 |
@GetMapping(value = "/getAllStores")
|
271 |
@GetMapping(value = "/getAllStores")
|
| 279 |
public String getAllStores(HttpServletRequest request, Model model) {
|
272 |
public String getAllStores(HttpServletRequest request, Model model) {
|
| 280 |
|
273 |
|
| Line 334... |
Line 327... |
| 334 |
|
327 |
|
| 335 |
return fofoIds;
|
328 |
return fofoIds;
|
| 336 |
|
329 |
|
| 337 |
}
|
330 |
}
|
| 338 |
|
331 |
|
| - |
|
332 |
@RequestMapping(value = "/userDetails", method = RequestMethod.GET)
|
| - |
|
333 |
public String UserInfoByEmailIdOrMobileNumber(HttpServletRequest request,
|
| - |
|
334 |
@RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
|
| - |
|
335 |
Model model) throws Exception {
|
| - |
|
336 |
boolean value = userRepository.isExistByEmailId(emailIdOrMobileNumber);
|
| - |
|
337 |
|
| - |
|
338 |
LOGGER.info("value" + emailIdOrMobileNumber);
|
| - |
|
339 |
LOGGER.info("boolean" + value);
|
| - |
|
340 |
|
| - |
|
341 |
if (value == true) {
|
| - |
|
342 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
343 |
|
| - |
|
344 |
} else {
|
| - |
|
345 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
| - |
|
346 |
|
| - |
|
347 |
}
|
| - |
|
348 |
|
| - |
|
349 |
return "response";
|
| - |
|
350 |
}
|
| - |
|
351 |
|
| - |
|
352 |
@RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)
|
| - |
|
353 |
public String getPromoterInfo(HttpServletRequest request,
|
| - |
|
354 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
355 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| - |
|
356 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| - |
|
357 |
List<Promoter> promoterInfo = null;
|
| - |
|
358 |
|
| - |
|
359 |
long size = 0;
|
| - |
|
360 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
| - |
|
361 |
.collect(Collectors.toList());
|
| - |
|
362 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
| - |
|
363 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| - |
|
364 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
365 |
model.addAttribute("brands", inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID));
|
| - |
|
366 |
promoterInfo = promoterRepository.selectAllPromoter(offset, limit);
|
| - |
|
367 |
|
| - |
|
368 |
size = promoterRepository.selectAllCount();
|
| - |
|
369 |
|
| - |
|
370 |
LOGGER.info("promoterInfo" + promoterInfo);
|
| - |
|
371 |
if (!promoterInfo.isEmpty()) {
|
| - |
|
372 |
List<Integer> partnerIds = new ArrayList<>();
|
| - |
|
373 |
|
| - |
|
374 |
for (Promoter promoterdetail : promoterInfo) {
|
| - |
|
375 |
partnerIds.add(promoterdetail.getRetailerId());
|
| - |
|
376 |
}
|
| - |
|
377 |
Map<Integer, CustomRetailer> partnersMap = null;
|
| - |
|
378 |
if(!partnerIds.equals(null)){
|
| - |
|
379 |
LOGGER.info("partnerIds" + partnerIds);
|
| - |
|
380 |
partnersMap = retailerService.getFofoRetailers(partnerIds);
|
| - |
|
381 |
}
|
| - |
|
382 |
|
| - |
|
383 |
LOGGER.info("partnerIds" + partnersMap);
|
| - |
|
384 |
model.addAttribute("promoterInfo", promoterInfo);
|
| - |
|
385 |
model.addAttribute("partnersMap", partnersMap);
|
| - |
|
386 |
model.addAttribute("start", offset + 1);
|
| - |
|
387 |
model.addAttribute("size", size);
|
| - |
|
388 |
model.addAttribute("url", "/getPaginatedPromoterInfo");
|
| - |
|
389 |
|
| - |
|
390 |
if (promoterInfo.size() < limit) {
|
| - |
|
391 |
model.addAttribute("end", offset + promoterInfo.size());
|
| - |
|
392 |
} else {
|
| - |
|
393 |
model.addAttribute("end", offset + limit);
|
| - |
|
394 |
}
|
| - |
|
395 |
} else {
|
| - |
|
396 |
model.addAttribute("promoterInfo", promoterInfo);
|
| - |
|
397 |
model.addAttribute("size", size);
|
| - |
|
398 |
}
|
| - |
|
399 |
return "promoter-info";
|
| - |
|
400 |
|
| - |
|
401 |
}
|
| - |
|
402 |
|
| - |
|
403 |
@RequestMapping(value = "/getPaginatedPromoterInfo", method = RequestMethod.GET)
|
| - |
|
404 |
public String getPaginatedPromoterInfo(HttpServletRequest request,
|
| - |
|
405 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
406 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| - |
|
407 |
throws ProfitMandiBusinessException {
|
| - |
|
408 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
| - |
|
409 |
List<Promoter> promoterInfo = null;
|
| - |
|
410 |
promoterInfo = promoterRepository.selectAllPromoter(offset, limit);
|
| - |
|
411 |
|
| - |
|
412 |
LOGGER.info("promoterInfo" + promoterInfo);
|
| - |
|
413 |
if (!promoterInfo.isEmpty()) {
|
| - |
|
414 |
List<Integer> partnerIds = new ArrayList<>();
|
| - |
|
415 |
|
| - |
|
416 |
for (Promoter promoterdetail : promoterInfo) {
|
| - |
|
417 |
partnerIds.add(promoterdetail.getRetailerId());
|
| - |
|
418 |
}
|
| - |
|
419 |
Map<Integer, CustomRetailer> partnersMap = null;
|
| - |
|
420 |
if(!partnerIds.equals(null)){
|
| - |
|
421 |
LOGGER.info("partnerIds" + partnerIds);
|
| - |
|
422 |
partnersMap = retailerService.getFofoRetailers(partnerIds);
|
| - |
|
423 |
}
|
| - |
|
424 |
|
| - |
|
425 |
LOGGER.info("partnerIds" + partnersMap);
|
| - |
|
426 |
model.addAttribute("promoterInfo", promoterInfo);
|
| - |
|
427 |
model.addAttribute("partnersMap", partnersMap);
|
| - |
|
428 |
model.addAttribute("url", "/getPaginatedPromoterInfo");
|
| - |
|
429 |
} else {
|
| - |
|
430 |
model.addAttribute("promoterInfo", promoterInfo);
|
| - |
|
431 |
|
| - |
|
432 |
}
|
| - |
|
433 |
|
| - |
|
434 |
return "promoter-info-paginated";
|
| - |
|
435 |
}
|
| - |
|
436 |
|
| - |
|
437 |
@RequestMapping(value = "/createPromoter", method = RequestMethod.POST)
|
| - |
|
438 |
public String createPromoter(HttpServletRequest request, @RequestBody PromoterDetailModel promoterdetailModel,
|
| - |
|
439 |
Model model) throws Exception {
|
| - |
|
440 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| - |
|
441 |
LOGGER.info("requested url : " + promoterdetailModel);
|
| - |
|
442 |
if (promoterdetailModel.getId()==0) {
|
| - |
|
443 |
Promoter promoter = new Promoter();
|
| - |
|
444 |
promoter.setName(promoterdetailModel.getName());
|
| - |
|
445 |
promoter.setBrand(promoterdetailModel.getBrand());
|
| - |
|
446 |
promoter.setEmail(promoterdetailModel.getEmail());
|
| - |
|
447 |
promoter.setMobile(promoterdetailModel.getMobile());
|
| - |
|
448 |
promoter.setRetailerId(promoterdetailModel.getRetailerId());
|
| - |
|
449 |
promoter.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
450 |
promoterRepository.persist(promoter);
|
| - |
|
451 |
} else {
|
| - |
|
452 |
Promoter updatePromoter = promoterRepository.selectById(promoterdetailModel.getId());
|
| - |
|
453 |
updatePromoter.setRetailerId(promoterdetailModel.getRetailerId());
|
| - |
|
454 |
promoterRepository.persist(updatePromoter);
|
| - |
|
455 |
}
|
| - |
|
456 |
|
| - |
|
457 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
458 |
|
| - |
|
459 |
return "response";
|
| - |
|
460 |
|
| - |
|
461 |
}
|
| - |
|
462 |
|
| - |
|
463 |
@RequestMapping(value = "/removePromoterfromPartnerStore", method = RequestMethod.POST)
|
| - |
|
464 |
public String removePromoterfromPartnerStore(HttpServletRequest request,
|
| - |
|
465 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| - |
|
466 |
|
| - |
|
467 |
Promoter promoter = promoterRepository.selectById(id);
|
| - |
|
468 |
|
| - |
|
469 |
promoter.setRetailerId(0);
|
| - |
|
470 |
promoterRepository.persist(promoter);
|
| - |
|
471 |
|
| - |
|
472 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
473 |
|
| - |
|
474 |
return "response";
|
| - |
|
475 |
}
|
| - |
|
476 |
|
| - |
|
477 |
@RequestMapping(value = "/addLocation", method = RequestMethod.POST)
|
| - |
|
478 |
public String addLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel, Model model)
|
| - |
|
479 |
throws Exception {
|
| - |
|
480 |
|
| - |
|
481 |
Location location = new Location();
|
| - |
|
482 |
location.setName(addLocationModel.getName());
|
| - |
|
483 |
location.setLine1(addLocationModel.getLine1());
|
| - |
|
484 |
location.setLine2(addLocationModel.getLine2());
|
| - |
|
485 |
location.setCity(addLocationModel.getCity());
|
| - |
|
486 |
location.setState(addLocationModel.getState());
|
| - |
|
487 |
location.setPin(addLocationModel.getPin());
|
| - |
|
488 |
|
| - |
|
489 |
LOGGER.info("PostLocation" + location);
|
| - |
|
490 |
locationRepository.persist(location);
|
| - |
|
491 |
|
| - |
|
492 |
User user = userRepository.selectById(addLocationModel.getUserId());
|
| - |
|
493 |
user.setLocation(location.getId());
|
| - |
|
494 |
userRepository.persist(user);
|
| - |
|
495 |
|
| - |
|
496 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
497 |
return "response";
|
| - |
|
498 |
|
| - |
|
499 |
}
|
| - |
|
500 |
|
| - |
|
501 |
@RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
|
| - |
|
502 |
public String updateLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel,
|
| - |
|
503 |
Model model) throws Exception {
|
| - |
|
504 |
|
| - |
|
505 |
Location userlocation = locationRepository.selectById(addLocationModel.getUserId());
|
| - |
|
506 |
|
| - |
|
507 |
userlocation.setName(addLocationModel.getName());
|
| - |
|
508 |
userlocation.setCity(addLocationModel.getCity());
|
| - |
|
509 |
userlocation.setLine1(addLocationModel.getLine1());
|
| - |
|
510 |
userlocation.setLine2(addLocationModel.getLine2());
|
| - |
|
511 |
userlocation.setPin(addLocationModel.getPin());
|
| - |
|
512 |
userlocation.setState(addLocationModel.getState());
|
| - |
|
513 |
|
| - |
|
514 |
locationRepository.persist(userlocation);
|
| - |
|
515 |
|
| - |
|
516 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
517 |
return "response";
|
| - |
|
518 |
|
| - |
|
519 |
}
|
| - |
|
520 |
|
| 339 |
}
|
521 |
}
|