Rev 25427 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import javax.servlet.http.HttpServletRequest;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.MediaType;import org.springframework.http.ResponseEntity;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.common.web.util.ResponseSender;import com.spice.profitmandi.dao.model.ContentPojo;import com.spice.profitmandi.dao.repository.dtr.Mongo;import com.spice.profitmandi.web.res.EntityResponse;import io.swagger.annotations.ApiImplicitParam;import io.swagger.annotations.ApiImplicitParams;import io.swagger.annotations.ApiOperation;import java.util.ArrayList;import java.util.Arrays;import java.util.List;@Controllerpublic class EntityController {private static final Logger logger = LogManager.getLogger(EntityController.class);@Autowiredprivate Mongo mongo;@Autowiredprivate ResponseSender<?> responseSender;@RequestMapping(value = ProfitMandiConstants.URL_ENTITY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })@ApiOperation(value = "Get entity content")public ResponseEntity<?> getEntity(HttpServletRequest request, @PathVariable(value = "entityId") long entityId)throws Exception {logger.info("Entity Id " + entityId);ContentPojo cp = mongo.getEntityById(entityId);EntityResponse er = new EntityResponse();er.setEntity(cp);return responseSender.ok(er);}@RequestMapping(value = ProfitMandiConstants.URL_SHOPIFY, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)@ApiOperation(value = "Get entity content")public ResponseEntity<?> getShopifyUrl(HttpServletRequest request) throws Exception {List<Integer> catalogIds = Arrays.asList(1024931, 1024930, 1024868, 1024855, 1024796, 1024793, 1024652, 1024617, 1024616, 1024615, 1024614);List<ContentPojo> entityList = new ArrayList<>();for (Integer catalogId : catalogIds) {ContentPojo cp = mongo.getEntityById(catalogId);if (cp != null) {entityList.add(cp);}}EntityResponse er = new EntityResponse();er.setEntities(entityList);return responseSender.ok(er);}}