| Line 122... |
Line 122... |
| 122 |
@Autowired
|
122 |
@Autowired
|
| 123 |
private RoleManager roleManagerService;
|
123 |
private RoleManager roleManagerService;
|
| 124 |
|
124 |
|
| 125 |
List<String> filterableParams = Arrays.asList("brand");
|
125 |
List<String> filterableParams = Arrays.asList("brand");
|
| 126 |
|
126 |
|
| 127 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
- |
|
| 128 |
@ApiImplicitParams({
|
- |
|
| 129 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
- |
|
| 130 |
@ApiOperation(value = "Get deals")
|
- |
|
| 131 |
public ResponseEntity<?> getDeals(HttpServletRequest request, @RequestParam(value = "categoryId") String categoryId,
|
- |
|
| 132 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
- |
|
| 133 |
@RequestParam(value = "sort", required = false) String sort,
|
- |
|
| 134 |
@RequestParam(value = "direction", required = false) String direction,
|
- |
|
| 135 |
@RequestParam(value = "filterData", required = false) String filterData)
|
- |
|
| 136 |
throws ProfitMandiBusinessException {
|
- |
|
| 137 |
logger.info("Request " + request.getParameterMap());
|
- |
|
| 138 |
String response = null;
|
- |
|
| 139 |
int userId = (int) request.getAttribute("userId");
|
- |
|
| 140 |
|
- |
|
| 141 |
// If pincode belongs to Specific warehouse marked
|
- |
|
| 142 |
// availability should be fetched for that warehouse only
|
- |
|
| 143 |
// show only skus belonging to that specific
|
- |
|
| 144 |
// else use normal flow
|
- |
|
| 145 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
- |
|
| 146 |
// TODO: move to properties
|
- |
|
| 147 |
String uri = "/deals/" + userId;
|
- |
|
| 148 |
RestClient rc = new RestClient();
|
- |
|
| 149 |
Map<String, String> params = new HashMap<>();
|
- |
|
| 150 |
params.put("offset", offset);
|
- |
|
| 151 |
params.put("limit", limit);
|
- |
|
| 152 |
params.put("categoryId", categoryId);
|
- |
|
| 153 |
params.put("direction", direction);
|
- |
|
| 154 |
params.put("sort", sort);
|
- |
|
| 155 |
params.put("filterData", filterData);
|
- |
|
| 156 |
params.put("source", "deals");
|
- |
|
| 157 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
- |
|
| 158 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
- |
|
| 159 |
}
|
- |
|
| 160 |
List<Object> responseObject = new ArrayList<>();
|
- |
|
| 161 |
try {
|
- |
|
| 162 |
response = rc.get(SchemeType.HTTP, host, port, uri, params);
|
- |
|
| 163 |
} catch (HttpHostConnectException e) {
|
- |
|
| 164 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
- |
|
| 165 |
}
|
- |
|
| 166 |
|
- |
|
| 167 |
JsonArray result_json = Json.parse(response).asArray();
|
- |
|
| 168 |
for (JsonValue j : result_json) {
|
- |
|
| 169 |
// logger.info("res " + j.asArray());
|
- |
|
| 170 |
List<Object> innerObject = new ArrayList<>();
|
- |
|
| 171 |
for (JsonValue jsonObject : j.asArray()) {
|
- |
|
| 172 |
innerObject.add(toDealObject(jsonObject.asObject()));
|
- |
|
| 173 |
}
|
- |
|
| 174 |
if (innerObject.size() > 0) {
|
- |
|
| 175 |
responseObject.add(innerObject);
|
- |
|
| 176 |
}
|
- |
|
| 177 |
}
|
- |
|
| 178 |
return responseSender.ok(responseObject);
|
- |
|
| 179 |
}
|
- |
|
| 180 |
|
127 |
|
| 181 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
128 |
@RequestMapping(value = "/fofo/buckets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 182 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
129 |
public ResponseEntity<?> getBuckets(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| 183 |
logger.info("Request " + request.getParameterMap());
|
130 |
logger.info("Request " + request.getParameterMap());
|
| 184 |
return responseSender.ok(itemBucketService.getBuckets(Optional.of(true)));
|
131 |
return responseSender.ok(itemBucketService.getBuckets(Optional.of(true)));
|