| Line 9... |
Line 9... |
| 9 |
|
9 |
|
| 10 |
import javax.servlet.http.HttpServletRequest;
|
10 |
import javax.servlet.http.HttpServletRequest;
|
| 11 |
|
11 |
|
| 12 |
import org.apache.commons.lang3.StringUtils;
|
12 |
import org.apache.commons.lang3.StringUtils;
|
| 13 |
import org.apache.http.conn.HttpHostConnectException;
|
13 |
import org.apache.http.conn.HttpHostConnectException;
|
| - |
|
14 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
15 |
import org.apache.logging.log4j.Logger;
|
| 14 |
import org.json.JSONArray;
|
16 |
import org.json.JSONArray;
|
| 15 |
import org.json.JSONObject;
|
17 |
import org.json.JSONObject;
|
| 16 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 17 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 18 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 19 |
import org.springframework.beans.factory.annotation.Value;
|
19 |
import org.springframework.beans.factory.annotation.Value;
|
| 20 |
import org.springframework.http.HttpStatus;
|
20 |
import org.springframework.http.HttpStatus;
|
| 21 |
import org.springframework.http.MediaType;
|
21 |
import org.springframework.http.MediaType;
|
| 22 |
import org.springframework.http.ResponseEntity;
|
22 |
import org.springframework.http.ResponseEntity;
|
| Line 44... |
Line 44... |
| 44 |
import com.spice.profitmandi.dao.model.UserCart;
|
44 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 45 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
45 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 46 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
46 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 47 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
47 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 48 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
48 |
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
|
| - |
|
49 |
import com.spice.profitmandi.service.RoleManagerService;
|
| 49 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
50 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 50 |
import com.spice.profitmandi.service.pricing.PricingService;
|
51 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 51 |
import com.spice.profitmandi.web.res.AvailabilityInfo;
|
52 |
import com.spice.profitmandi.web.res.AvailabilityInfo;
|
| 52 |
import com.spice.profitmandi.web.res.DealBrands;
|
53 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 53 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
54 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| Line 94... |
Line 95... |
| 94 |
private InventoryService inventoryService;
|
95 |
private InventoryService inventoryService;
|
| 95 |
|
96 |
|
| 96 |
@Autowired
|
97 |
@Autowired
|
| 97 |
private ItemRepository itemRepository;
|
98 |
private ItemRepository itemRepository;
|
| 98 |
|
99 |
|
| - |
|
100 |
@Autowired
|
| - |
|
101 |
private RoleManagerService roleManagerService;
|
| - |
|
102 |
|
| 99 |
|
103 |
|
| 100 |
List<String> filterableParams = Arrays.asList("brand");
|
104 |
List<String> filterableParams = Arrays.asList("brand");
|
| 101 |
|
105 |
|
| 102 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
106 |
@RequestMapping(value = ProfitMandiConstants.URL_DEALS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 103 |
@ApiImplicitParams({
|
107 |
@ApiImplicitParams({
|
| Line 126... |
Line 130... |
| 126 |
params.put("categoryId", categoryId);
|
130 |
params.put("categoryId", categoryId);
|
| 127 |
params.put("direction", direction);
|
131 |
params.put("direction", direction);
|
| 128 |
params.put("sort", sort);
|
132 |
params.put("sort", sort);
|
| 129 |
params.put("filterData", filterData);
|
133 |
params.put("filterData", filterData);
|
| 130 |
params.put("source", "deals");
|
134 |
params.put("source", "deals");
|
| 131 |
if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
|
135 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| 132 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
136 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
| 133 |
}
|
137 |
}
|
| 134 |
List<Object> responseObject = new ArrayList<>();
|
138 |
List<Object> responseObject = new ArrayList<>();
|
| 135 |
try {
|
139 |
try {
|
| 136 |
response = rc.get(SchemeType.HTTP, host, port, uri, params);
|
140 |
response = rc.get(SchemeType.HTTP, host, port, uri, params);
|
| Line 168... |
Line 172... |
| 168 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId") String categoryId,
|
172 |
public ResponseEntity<?> getFofo(HttpServletRequest request, @RequestParam(value = "categoryId") String categoryId,
|
| 169 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
173 |
@RequestParam(value = "offset") String offset, @RequestParam(value = "limit") String limit,
|
| 170 |
@RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand) throws Throwable {
|
174 |
@RequestParam(value = "sort", required = false) String sort, @RequestParam(value = "brand", required = false) String brand) throws Throwable {
|
| 171 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
175 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
| 172 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
176 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 173 |
if (userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
|
177 |
if (roleManagerService.isPartner(userInfo.getRoleIds())) {
|
| 174 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
178 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
| 175 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
|
179 |
List<Integer> tagIds = pricingService.getTagsIdsByRetailerId(uc.getUserId());
|
| 176 |
RestClient rc = new RestClient();
|
180 |
RestClient rc = new RestClient();
|
| 177 |
Map<String, String> params = new HashMap<>();
|
181 |
Map<String, String> params = new HashMap<>();
|
| 178 |
List<String> mandatoryQ = new ArrayList<>();
|
182 |
List<String> mandatoryQ = new ArrayList<>();
|