| Line 31... |
Line 31... |
| 31 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
31 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 32 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
32 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 33 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
33 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 34 |
import com.spice.profitmandi.common.model.ProfitMandiResponse;
|
34 |
import com.spice.profitmandi.common.model.ProfitMandiResponse;
|
| 35 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
35 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
| - |
|
36 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 36 |
import com.spice.profitmandi.common.web.client.RestClient;
|
37 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 37 |
import com.spice.profitmandi.dao.entity.catalog.Tag;
|
38 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 38 |
import com.spice.profitmandi.service.pricing.PricingService;
|
39 |
import com.spice.profitmandi.service.pricing.PricingService;
|
| 39 |
import com.spice.profitmandi.service.tag.TagService;
|
- |
|
| 40 |
import com.spice.profitmandi.web.res.DealBrands;
|
40 |
import com.spice.profitmandi.web.res.DealBrands;
|
| 41 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
41 |
import com.spice.profitmandi.web.res.DealObjectResponse;
|
| 42 |
import com.spice.profitmandi.web.res.DealsResponse;
|
42 |
import com.spice.profitmandi.web.res.DealsResponse;
|
| 43 |
|
43 |
|
| 44 |
import io.swagger.annotations.ApiImplicitParam;
|
44 |
import io.swagger.annotations.ApiImplicitParam;
|
| Line 69... |
Line 69... |
| 69 |
@RequestParam(value="offset") String offset, @RequestParam(value="limit") String limit, @RequestParam(value="sort", required=false) String sort,
|
69 |
@RequestParam(value="offset") String offset, @RequestParam(value="limit") String limit, @RequestParam(value="sort", required=false) String sort,
|
| 70 |
@RequestParam(value="direction", required=false) String direction, @RequestParam(value="filterData", required=false) String filterData ) throws Throwable {
|
70 |
@RequestParam(value="direction", required=false) String direction, @RequestParam(value="filterData", required=false) String filterData ) throws Throwable {
|
| 71 |
logger.info("Request "+request.getParameterMap());
|
71 |
logger.info("Request "+request.getParameterMap());
|
| 72 |
String response = null;
|
72 |
String response = null;
|
| 73 |
int userId = (int)request.getAttribute("userId");
|
73 |
int userId = (int)request.getAttribute("userId");
|
| - |
|
74 |
UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
|
| 74 |
//TODO: move to properties
|
75 |
//TODO: move to properties
|
| 75 |
String uri = "/deals/"+userId;
|
76 |
String uri = "/deals/"+userId;
|
| 76 |
RestClient rc = new RestClient(SchemeType.HTTP, host , port);
|
77 |
RestClient rc = new RestClient(SchemeType.HTTP, host , port);
|
| 77 |
Map<String, String> params = new HashMap<>();
|
78 |
Map<String, String> params = new HashMap<>();
|
| 78 |
params.put("offset", offset);
|
79 |
params.put("offset", offset);
|
| Line 80... |
Line 81... |
| 80 |
params.put("categoryId", categoryId);
|
81 |
params.put("categoryId", categoryId);
|
| 81 |
params.put("direction", direction);
|
82 |
params.put("direction", direction);
|
| 82 |
params.put("sort", sort);
|
83 |
params.put("sort", sort);
|
| 83 |
params.put("filterData", filterData);
|
84 |
params.put("filterData", filterData);
|
| 84 |
params.put("source", "deals");
|
85 |
params.put("source", "deals");
|
| - |
|
86 |
if(userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
|
| 85 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
87 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
| - |
|
88 |
}
|
| 86 |
List<Object> responseObject = new ArrayList<>();
|
89 |
List<Object> responseObject = new ArrayList<>();
|
| 87 |
try {
|
90 |
try {
|
| 88 |
response = rc.get(uri, params);
|
91 |
response = rc.get(uri, params);
|
| 89 |
} catch (Exception | ProfitMandiBusinessException e) {
|
92 |
} catch (Exception | ProfitMandiBusinessException e) {
|
| 90 |
logger.error("Unable to get deals",e);
|
93 |
logger.error("Unable to get deals",e);
|
| Line 127... |
Line 130... |
| 127 |
@RequestParam(value="offset") String offset, @RequestParam(value="limit") String limit, @RequestParam(value="sort", required=false) String sort,
|
130 |
@RequestParam(value="offset") String offset, @RequestParam(value="limit") String limit, @RequestParam(value="sort", required=false) String sort,
|
| 128 |
@RequestParam(value="direction", required=false) String direction, @RequestParam(value="filterData", required=false) String filterData ) throws Throwable{
|
131 |
@RequestParam(value="direction", required=false) String direction, @RequestParam(value="filterData", required=false) String filterData ) throws Throwable{
|
| 129 |
logger.info("Request "+request.getParameterMap());
|
132 |
logger.info("Request "+request.getParameterMap());
|
| 130 |
String response = null;
|
133 |
String response = null;
|
| 131 |
int userId = (int)request.getAttribute("userId");
|
134 |
int userId = (int)request.getAttribute("userId");
|
| 132 |
//TODO: move to properties
|
135 |
UserInfo userInfo = (UserInfo)request.getAttribute("userInfo");
|
| - |
|
136 |
|
| 133 |
String uri = "/deals/"+userId;
|
137 |
String uri = "/deals/"+userId;
|
| 134 |
RestClient rc = new RestClient(SchemeType.HTTP, host , port);
|
138 |
RestClient rc = new RestClient(SchemeType.HTTP, host , port);
|
| 135 |
Map<String, String> params = new HashMap<>();
|
139 |
Map<String, String> params = new HashMap<>();
|
| 136 |
params.put("offset", offset);
|
140 |
params.put("offset", offset);
|
| 137 |
params.put("limit", limit);
|
141 |
params.put("limit", limit);
|
| 138 |
params.put("categoryId", categoryId);
|
142 |
params.put("categoryId", categoryId);
|
| 139 |
params.put("direction", direction);
|
143 |
params.put("direction", direction);
|
| 140 |
params.put("sort", sort);
|
144 |
params.put("sort", sort);
|
| 141 |
params.put("source", "online");
|
145 |
params.put("source", "online");
|
| 142 |
params.put("filterData", filterData);
|
146 |
params.put("filterData", filterData);
|
| - |
|
147 |
if(userInfo.getRoleNames().contains(RoleType.FOFO.toString())) {
|
| 143 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
148 |
params.put("tag_ids", getCommaSeparateTags(userId));
|
| - |
|
149 |
}
|
| 144 |
List<Object> responseObject = new ArrayList<>();
|
150 |
List<Object> responseObject = new ArrayList<>();
|
| 145 |
try {
|
151 |
try {
|
| 146 |
response = rc.get(uri, params);
|
152 |
response = rc.get(uri, params);
|
| 147 |
} catch (Exception | ProfitMandiBusinessException e) {
|
153 |
} catch (Exception | ProfitMandiBusinessException e) {
|
| 148 |
logger.error("Unable to get deals",e);
|
154 |
logger.error("Unable to get deals",e);
|