| 21277 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
|
|
4 |
|
|
|
5 |
import javax.servlet.http.HttpServletRequest;
|
|
|
6 |
|
|
|
7 |
import org.slf4j.Logger;
|
|
|
8 |
import org.slf4j.LoggerFactory;
|
|
|
9 |
import org.springframework.http.HttpStatus;
|
|
|
10 |
import org.springframework.http.ResponseEntity;
|
|
|
11 |
import org.springframework.stereotype.Controller;
|
|
|
12 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
13 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
14 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
15 |
|
|
|
16 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
17 |
import com.spice.profitmandi.dao.repository.PostOfficeRepository;
|
|
|
18 |
import com.spice.profitmandi.dao.repository.PostOfficeRepositoryImpl;
|
|
|
19 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
|
|
20 |
import com.spice.profitmandi.web.model.Response;
|
|
|
21 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
|
|
22 |
|
|
|
23 |
@Controller
|
|
|
24 |
public class PostOfficeController {
|
|
|
25 |
|
|
|
26 |
private static final Logger LOGGER=LoggerFactory.getLogger(PostOfficeController.class);
|
|
|
27 |
|
|
|
28 |
private PostOfficeRepository postOfficeRepository = PostOfficeRepositoryImpl.getInstance();
|
|
|
29 |
|
|
|
30 |
@RequestMapping(value = ProfitMandiConstants.URL_POST_OFFICE, method=RequestMethod.GET)
|
|
|
31 |
public ResponseEntity<?> getByPin(HttpServletRequest request, @RequestParam(name = "pinCode") long pinCode){
|
|
|
32 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
|
|
33 |
try {
|
|
|
34 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, postOfficeRepository.selectByPinCode(pinCode));
|
|
|
35 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
|
|
36 |
}catch (Exception e) {
|
|
|
37 |
LOGGER.error("Internal Server Error : ",e);
|
|
|
38 |
final Response response=new Response("","","", e.getMessage());
|
|
|
39 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
|
|
40 |
return new ResponseEntity<>(chatOnResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
}
|