| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.util.HashMap;
|
| - |
|
4 |
import java.util.HashSet;
|
| - |
|
5 |
import java.util.List;
|
| - |
|
6 |
import java.util.Map;
|
| - |
|
7 |
import java.util.Set;
|
| - |
|
8 |
|
| 3 |
import javax.servlet.http.HttpServletRequest;
|
9 |
import javax.servlet.http.HttpServletRequest;
|
| 4 |
|
10 |
|
| 5 |
import org.slf4j.Logger;
|
11 |
import org.slf4j.Logger;
|
| 6 |
import org.slf4j.LoggerFactory;
|
12 |
import org.slf4j.LoggerFactory;
|
| 7 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 12... |
Line 18... |
| 12 |
import org.springframework.web.bind.annotation.RequestMethod;
|
18 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 13 |
import org.springframework.web.bind.annotation.RequestParam;
|
19 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 14 |
|
20 |
|
| 15 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
21 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 16 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
22 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| - |
|
23 |
import com.spice.profitmandi.dao.entity.logistics.PostOffice;
|
| 17 |
import com.spice.profitmandi.dao.repository.logistics.PostOfficeRepository;
|
24 |
import com.spice.profitmandi.dao.repository.logistics.PostOfficeRepository;
|
| 18 |
|
25 |
|
| 19 |
@Controller
|
26 |
@Controller
|
| 20 |
@Transactional(rollbackFor=Throwable.class)
|
27 |
@Transactional(rollbackFor=Throwable.class)
|
| 21 |
public class PostOfficeController {
|
28 |
public class PostOfficeController {
|
| Line 29... |
Line 36... |
| 29 |
private PostOfficeRepository postOfficeRepository;
|
36 |
private PostOfficeRepository postOfficeRepository;
|
| 30 |
|
37 |
|
| 31 |
@RequestMapping(value = ProfitMandiConstants.URL_POST_OFFICE, method=RequestMethod.GET)
|
38 |
@RequestMapping(value = ProfitMandiConstants.URL_POST_OFFICE, method=RequestMethod.GET)
|
| 32 |
public ResponseEntity<?> getByPin(HttpServletRequest request, @RequestParam(name = "pinCode") int pinCode){
|
39 |
public ResponseEntity<?> getByPin(HttpServletRequest request, @RequestParam(name = "pinCode") int pinCode){
|
| 33 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
40 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
41 |
List<PostOffice> postOffices = postOfficeRepository.selectByPinCode(pinCode);
|
| - |
|
42 |
Set<String> cities = new HashSet<>();
|
| - |
|
43 |
Map<String, Object> map = new HashMap<>(3);
|
| - |
|
44 |
|
| - |
|
45 |
map.put(ProfitMandiConstants.PIN_CODE, pinCode);
|
| - |
|
46 |
for(PostOffice postOffice : postOffices){
|
| - |
|
47 |
String city = postOffice.getCity();
|
| - |
|
48 |
if(city.equals("NA")){
|
| - |
|
49 |
cities.add(postOffice.getDistrict());
|
| - |
|
50 |
}else{
|
| - |
|
51 |
cities.add(postOffice.getCity());
|
| - |
|
52 |
}
|
| - |
|
53 |
map.put(ProfitMandiConstants.STATE, postOffice.getState());
|
| - |
|
54 |
}
|
| - |
|
55 |
map.put(ProfitMandiConstants.CITIES, cities);
|
| 34 |
return responseSender.ok(postOfficeRepository.selectByPinCode(pinCode));
|
56 |
return responseSender.ok(postOfficeRepository.selectByPinCode(pinCode));
|
| 35 |
|
57 |
|
| 36 |
}
|
58 |
}
|
| 37 |
}
|
59 |
}
|
| 38 |
|
60 |
|