| 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 |
|
|
|
25 |
@Controller
|
|
|
26 |
public class EntityController {
|
|
|
27 |
|
| 25427 |
amit.gupta |
28 |
private static final Logger logger = LogManager.getLogger(EntityController.class);
|
|
|
29 |
|
| 22319 |
amit.gupta |
30 |
@Autowired
|
| 25427 |
amit.gupta |
31 |
private Mongo mongo;
|
|
|
32 |
|
|
|
33 |
@Autowired
|
| 22931 |
ashik.ali |
34 |
private ResponseSender<?> responseSender;
|
| 25427 |
amit.gupta |
35 |
|
|
|
36 |
@RequestMapping(value = ProfitMandiConstants.URL_ENTITY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 21339 |
kshitij.so |
37 |
@ApiImplicitParams({
|
| 25427 |
amit.gupta |
38 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
39 |
|
| 21339 |
kshitij.so |
40 |
@ApiOperation(value = "Get entity content")
|
| 25427 |
amit.gupta |
41 |
public ResponseEntity<?> getEntity(HttpServletRequest request, @PathVariable(value = "entityId") long entityId)
|
|
|
42 |
throws Exception {
|
|
|
43 |
logger.info("Entity Id " + entityId);
|
|
|
44 |
ContentPojo cp = mongo.getEntityById(entityId);
|
|
|
45 |
EntityResponse er = new EntityResponse();
|
|
|
46 |
er.setEntity(cp);
|
|
|
47 |
return responseSender.ok(er);
|
| 21339 |
kshitij.so |
48 |
}
|
|
|
49 |
}
|