| 21339 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import javax.servlet.http.HttpServletRequest;
|
|
|
4 |
|
| 25427 |
amit.gupta |
5 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
6 |
import org.apache.logging.log4j.Logger;
|
| 22319 |
amit.gupta |
7 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21339 |
kshitij.so |
8 |
import org.springframework.http.MediaType;
|
|
|
9 |
import org.springframework.http.ResponseEntity;
|
|
|
10 |
import org.springframework.stereotype.Controller;
|
|
|
11 |
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
12 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
13 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
14 |
|
|
|
15 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22319 |
amit.gupta |
16 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 25427 |
amit.gupta |
17 |
import com.spice.profitmandi.dao.model.ContentPojo;
|
|
|
18 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 21339 |
kshitij.so |
19 |
import com.spice.profitmandi.web.res.EntityResponse;
|
|
|
20 |
|
|
|
21 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
22 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
23 |
import io.swagger.annotations.ApiOperation;
|
|
|
24 |
|
| 33784 |
ranu |
25 |
import java.util.ArrayList;
|
|
|
26 |
import java.util.Arrays;
|
|
|
27 |
import java.util.List;
|
|
|
28 |
|
| 21339 |
kshitij.so |
29 |
@Controller
|
|
|
30 |
public class EntityController {
|
|
|
31 |
|
| 25427 |
amit.gupta |
32 |
private static final Logger logger = LogManager.getLogger(EntityController.class);
|
|
|
33 |
|
| 22319 |
amit.gupta |
34 |
@Autowired
|
| 25427 |
amit.gupta |
35 |
private Mongo mongo;
|
|
|
36 |
|
|
|
37 |
@Autowired
|
| 22931 |
ashik.ali |
38 |
private ResponseSender<?> responseSender;
|
| 25427 |
amit.gupta |
39 |
|
|
|
40 |
@RequestMapping(value = ProfitMandiConstants.URL_ENTITY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 21339 |
kshitij.so |
41 |
@ApiImplicitParams({
|
| 25427 |
amit.gupta |
42 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 21339 |
kshitij.so |
43 |
@ApiOperation(value = "Get entity content")
|
| 25427 |
amit.gupta |
44 |
public ResponseEntity<?> getEntity(HttpServletRequest request, @PathVariable(value = "entityId") long entityId)
|
|
|
45 |
throws Exception {
|
|
|
46 |
logger.info("Entity Id " + entityId);
|
|
|
47 |
ContentPojo cp = mongo.getEntityById(entityId);
|
|
|
48 |
EntityResponse er = new EntityResponse();
|
|
|
49 |
er.setEntity(cp);
|
|
|
50 |
return responseSender.ok(er);
|
| 21339 |
kshitij.so |
51 |
}
|
| 33784 |
ranu |
52 |
|
|
|
53 |
@RequestMapping(value = ProfitMandiConstants.URL_SHOPIFY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
54 |
@ApiOperation(value = "Get entity content")
|
|
|
55 |
public ResponseEntity<?> getShopifyUrl(HttpServletRequest request) throws Exception {
|
|
|
56 |
|
|
|
57 |
List<Integer> catalogIds = Arrays.asList(1024931, 1024930, 1024868, 1024855, 1024796, 1024793, 1024652, 1024617, 1024616, 1024615, 1024614);
|
|
|
58 |
|
|
|
59 |
List<ContentPojo> entityList = new ArrayList<>();
|
|
|
60 |
|
|
|
61 |
for (Integer catalogId : catalogIds) {
|
|
|
62 |
ContentPojo cp = mongo.getEntityById(catalogId);
|
|
|
63 |
if (cp != null) {
|
|
|
64 |
entityList.add(cp);
|
|
|
65 |
}
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
EntityResponse er = new EntityResponse();
|
|
|
69 |
er.setEntities(entityList);
|
|
|
70 |
|
|
|
71 |
return responseSender.ok(er);
|
|
|
72 |
}
|
|
|
73 |
|
| 21339 |
kshitij.so |
74 |
}
|