| Line 18... |
Line 18... |
| 18 |
|
18 |
|
| 19 |
import com.google.gson.Gson;
|
19 |
import com.google.gson.Gson;
|
| 20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 21 |
import com.spice.profitmandi.common.model.ProfitMandiResponse;
|
21 |
import com.spice.profitmandi.common.model.ProfitMandiResponse;
|
| 22 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
22 |
import com.spice.profitmandi.common.model.ResponseStatus;
|
| - |
|
23 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 23 |
import com.spice.profitmandi.dao.model.LimitedMasterDataPojo;
|
24 |
import com.spice.profitmandi.dao.model.LimitedMasterDataPojo;
|
| 24 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
25 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 25 |
|
26 |
|
| 26 |
import io.swagger.annotations.ApiImplicitParam;
|
27 |
import io.swagger.annotations.ApiImplicitParam;
|
| 27 |
import io.swagger.annotations.ApiImplicitParams;
|
28 |
import io.swagger.annotations.ApiImplicitParams;
|
| Line 30... |
Line 31... |
| 30 |
@Controller
|
31 |
@Controller
|
| 31 |
public class MasterDataController {
|
32 |
public class MasterDataController {
|
| 32 |
|
33 |
|
| 33 |
private static final Logger logger=LoggerFactory.getLogger(MasterDataController.class);
|
34 |
private static final Logger logger=LoggerFactory.getLogger(MasterDataController.class);
|
| 34 |
|
35 |
|
| - |
|
36 |
@Autowired
|
| - |
|
37 |
private Mongo mongoClient;
|
| 35 |
|
38 |
|
| 36 |
|
- |
|
| 37 |
@Autowired
|
39 |
@Autowired
|
| 38 |
Mongo mongoClient;
|
40 |
private ResponseSender<?> responseSender;
|
| 39 |
|
41 |
|
| 40 |
|
42 |
|
| 41 |
@RequestMapping(value = ProfitMandiConstants.URL_MASTER_DATA, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
43 |
@RequestMapping(value = ProfitMandiConstants.URL_MASTER_DATA, method=RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
| 42 |
@ApiImplicitParams({
|
44 |
@ApiImplicitParams({
|
| 43 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
45 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token",
|
| 44 |
required = true, dataType = "string", paramType = "header")
|
46 |
required = true, dataType = "string", paramType = "header")
|
| 45 |
})
|
47 |
})
|
| 46 |
@ApiOperation(value = "Get limited info of master data for skuBundleId")
|
48 |
@ApiOperation(value = "Get limited info of master data for skuBundleId")
|
| 47 |
public ResponseEntity<?> getMasterDataBySkuBundleId(HttpServletRequest request, @PathVariable(value="id") long skuBundleId){
|
49 |
public ResponseEntity<?> getMasterDataBySkuBundleId(HttpServletRequest request, @PathVariable(value="id") long skuBundleId) throws Exception{
|
| 48 |
LimitedMasterDataPojo masterData = null;
|
- |
|
| 49 |
try {
|
50 |
|
| 50 |
JSONObject jsonObject = mongoClient.getItemsByBundleId(skuBundleId);
|
51 |
JSONObject jsonObject = mongoClient.getItemsByBundleId(skuBundleId);
|
| 51 |
masterData = new Gson().fromJson(jsonObject.toString(), LimitedMasterDataPojo.class);
|
52 |
LimitedMasterDataPojo masterData = new Gson().fromJson(jsonObject.toString(), LimitedMasterDataPojo.class);
|
| 52 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, masterData);
|
- |
|
| 53 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
53 |
return responseSender.ok(masterData);
|
| 54 |
} catch (Exception e) {
|
- |
|
| 55 |
logger.info("Unable to get skuBundleId "+skuBundleId,e);
|
- |
|
| 56 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString() , HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, masterData);
|
- |
|
| 57 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 58 |
}
|
- |
|
| 59 |
}
|
54 |
}
|
| 60 |
|
55 |
|
| 61 |
}
|
56 |
}
|