| Line 39... |
Line 39... |
| 39 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
39 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
| 40 |
import com.spice.profitmandi.common.model.UserInfo;
|
40 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 41 |
import com.spice.profitmandi.common.web.client.RestClient;
|
41 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 42 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
42 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 43 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
43 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| - |
|
44 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 44 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
45 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| - |
|
46 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 45 |
import com.spice.profitmandi.service.pricing.PricingService;
|
47 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 46 |
import com.spice.profitmandi.web.res.DealBrands;
|
48 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 47 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
49 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| 48 |
import com.spice.profitmandi.web.res.DealsResponse;
|
50 |
import com.spice.profitmandi.web.res.DealsResponse;
|
| 49 |
import com.spice.profitmandi.web.res.FofoAvailabilityInfo;
|
51 |
import com.spice.profitmandi.web.res.FofoAvailabilityInfo;
|
| Line 69... |
Line 71... |
| 69 |
|
71 |
|
| 70 |
@Autowired
|
72 |
@Autowired
|
| 71 |
private Mongo mongoClient;
|
73 |
private Mongo mongoClient;
|
| 72 |
|
74 |
|
| 73 |
@Autowired
|
75 |
@Autowired
|
| - |
|
76 |
private UserAccountRepository userAccountRepository;
|
| - |
|
77 |
|
| - |
|
78 |
@Autowired
|
| 74 |
ResponseSender<?> responseSender;
|
79 |
ResponseSender<?> responseSender;
|
| 75 |
|
80 |
|
| 76 |
List<String> filterableParams = Arrays.asList("brand");
|
81 |
List<String> filterableParams = Arrays.asList("brand");
|
| 77 |
|
82 |
|
| 78 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
83 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 128... |
Line 133... |
| 128 |
responseObject);
|
133 |
responseObject);
|
| 129 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
134 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
| 130 |
}
|
135 |
}
|
| 131 |
|
136 |
|
| 132 |
private String getCommaSeparateTags(int userId) throws Throwable {
|
137 |
private String getCommaSeparateTags(int userId) throws Throwable {
|
| - |
|
138 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
| 133 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(userId);
|
139 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
|
| 134 |
List<String> strTagIds = new ArrayList<>();
|
140 |
List<String> strTagIds = new ArrayList<>();
|
| 135 |
for (Integer tagId : tagIds) {
|
141 |
for (Integer tagId : tagIds) {
|
| 136 |
strTagIds.add(String.valueOf(tagId));
|
142 |
strTagIds.add(String.valueOf(tagId));
|
| 137 |
}
|
143 |
}
|
| 138 |
return String.join(",", strTagIds);
|
144 |
return String.join(",", strTagIds);
|
| Line 145... |
Line 151... |
| 145 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
151 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 146 |
@RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand) throws Throwable {
|
152 |
@RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand) throws Throwable {
|
| 147 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
153 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 148 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
154 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 149 |
if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
|
155 |
if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
|
| - |
|
156 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
| 150 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(userInfo.getUserId());
|
157 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
|
| 151 |
RestClient rc = new RestClient(SchemeType.HTTP, "dtr", 8984);
|
158 |
RestClient rc = new RestClient(SchemeType.HTTP, "dtr", 8984);
|
| 152 |
Map<String, String> params = new HashMap<>();
|
159 |
Map<String, String> params = new HashMap<>();
|
| 153 |
List<String> mandatoryQ = new ArrayList<>();
|
160 |
List<String> mandatoryQ = new ArrayList<>();
|
| 154 |
if(brand != null) {
|
161 |
if(brand != null) {
|
| 155 |
|
162 |
|
| Line 218... |
Line 225... |
| 218 |
@RequestParam(value = "direction", required = false) String direction,
|
225 |
@RequestParam(value = "direction", required = false) String direction,
|
| 219 |
@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
226 |
@RequestParam(value = "filterData", required = false) String filterData) throws Throwable {
|
| 220 |
logger.info("Request " + request.getParameterMap());
|
227 |
logger.info("Request " + request.getParameterMap());
|
| 221 |
String response = null;
|
228 |
String response = null;
|
| 222 |
int userId = (int) request.getAttribute("userId");
|
229 |
int userId = (int) request.getAttribute("userId");
|
| 223 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
- |
|
| 224 |
|
230 |
|
| 225 |
String uri = "/deals/" + userId;
|
231 |
String uri = "/deals/" + userId;
|
| 226 |
RestClient rc = new RestClient(SchemeType.HTTP, host, port);
|
232 |
RestClient rc = new RestClient(SchemeType.HTTP, host, port);
|
| 227 |
Map<String, String> params = new HashMap<>();
|
233 |
Map<String, String> params = new HashMap<>();
|
| 228 |
params.put("offset", offset);
|
234 |
params.put("offset", offset);
|