| Line 27... |
Line 27... |
| 27 |
private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
|
27 |
private static final Logger LOGGER=LoggerFactory.getLogger(AddressController.class);
|
| 28 |
|
28 |
|
| 29 |
@Autowired
|
29 |
@Autowired
|
| 30 |
AddressRepository addressRepository;
|
30 |
AddressRepository addressRepository;
|
| 31 |
|
31 |
|
| 32 |
|
- |
|
| 33 |
|
- |
|
| 34 |
@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ALL, method=RequestMethod.GET)
|
32 |
@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ALL, method=RequestMethod.GET)
|
| 35 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
33 |
public ResponseEntity<?> getAll(HttpServletRequest request){
|
| 36 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
34 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 37 |
try {
|
- |
|
| 38 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, addressRepository.selectAll());
|
35 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, addressRepository.selectAll());
|
| 39 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
36 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 40 |
}catch (Exception e) {
|
- |
|
| 41 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 42 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 43 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 44 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 45 |
}
|
- |
|
| 46 |
}
|
37 |
}
|
| - |
|
38 |
|
| 47 |
@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ID, method=RequestMethod.GET)
|
39 |
@RequestMapping(value = ProfitMandiConstants.URL_ADDRESS_ID, method=RequestMethod.GET)
|
| 48 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
|
40 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") long id){
|
| 49 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
41 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 50 |
try {
|
42 |
try {
|
| 51 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, addressRepository.selectById(id));
|
43 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, addressRepository.selectById(id));
|
| 52 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
44 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| 53 |
}catch (ProfitMandiBusinessException pmbe) {
|
45 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 54 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
46 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 55 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
47 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 56 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
48 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| 57 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
49 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
|
| 58 |
}catch (Exception e) {
|
- |
|
| 59 |
LOGGER.error("Internal Server Error : ",e);
|
- |
|
| 60 |
final Response response=new Response("","","", e.getMessage());
|
- |
|
| 61 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
- |
|
| 62 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
- |
|
| 63 |
}
|
50 |
}
|
| 64 |
}
|
51 |
}
|
| 65 |
|
52 |
|
| 66 |
|
53 |
|
| 67 |
}
|
54 |
}
|