Subversion Repositories SmartDukaan

Rev

Rev 23568 | Rev 31599 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23568 Rev 27113
Line 22... Line 22...
22
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;
23
import com.spice.profitmandi.dao.entity.logistics.PostOffice;
24
import com.spice.profitmandi.dao.repository.logistics.PostOfficeRepository;
24
import com.spice.profitmandi.dao.repository.logistics.PostOfficeRepository;
25
 
25
 
26
@Controller
26
@Controller
27
@Transactional(rollbackFor=Throwable.class)
27
@Transactional(rollbackFor = Throwable.class)
28
public class PostOfficeController {
28
public class PostOfficeController {
29
	
29
 
30
	@Autowired
30
	@Autowired
31
	private ResponseSender<?> responseSender;
31
	private ResponseSender<?> responseSender;
32
	
32
 
33
	private static final Logger LOGGER=LogManager.getLogger(PostOfficeController.class);
33
	private static final Logger LOGGER = LogManager.getLogger(PostOfficeController.class);
34
	
34
 
35
	@Autowired
35
	@Autowired
36
	private PostOfficeRepository postOfficeRepository;
36
	private PostOfficeRepository postOfficeRepository;
37
	
37
 
38
	@RequestMapping(value = ProfitMandiConstants.URL_POST_OFFICE, method=RequestMethod.GET)
38
	@RequestMapping(value = ProfitMandiConstants.URL_POST_OFFICE, method = RequestMethod.GET)
39
	public ResponseEntity<?> getByPin(HttpServletRequest request, @RequestParam(name = "pinCode") int pinCode){
39
	public ResponseEntity<?> getByPin(HttpServletRequest request, @RequestParam(name = "pinCode") int pinCode) {
40
		LOGGER.info("requested url : "+request.getRequestURL().toString());
40
		LOGGER.info("requested url : " + request.getRequestURL().toString());
41
		List<PostOffice> postOffices = postOfficeRepository.selectByPinCode(pinCode);
41
		List<PostOffice> postOffices = postOfficeRepository.selectByPinCode(pinCode);
42
		Set<String> cities = new HashSet<>();
42
		Set<String> cities = new HashSet<>();
43
		Map<String, Object> map = new HashMap<>(3);
43
		Map<String, Object> map = new HashMap<>(3);
44
		
44
 
45
		map.put(ProfitMandiConstants.PIN_CODE, pinCode);
45
		map.put(ProfitMandiConstants.PIN_CODE, pinCode);
46
		for(PostOffice postOffice : postOffices){
46
		for (PostOffice postOffice : postOffices) {
47
			String city = postOffice.getCity();
47
			String city = postOffice.getCity();
48
			if(city.equals("NA")){
48
			if (city.equals("NA")) {
49
				cities.add(postOffice.getDistrict());
49
				cities.add(postOffice.getDistrict());
-
 
50
	
50
			}else{
51
			} else {
51
				cities.add(postOffice.getCity());
52
				cities.add(postOffice.getCity());
52
			}
53
			}
53
			map.put(ProfitMandiConstants.STATE, postOffice.getState());
54
			map.put(ProfitMandiConstants.STATE, postOffice.getState());
54
		}
55
		}
55
		map.put(ProfitMandiConstants.CITIES, cities);
56
		map.put(ProfitMandiConstants.CITIES, cities);
56
		return responseSender.ok(postOfficeRepository.selectByPinCode(pinCode));
57
		return responseSender.ok(map);
57
		
58
 
58
	}
59
	}
59
}
60
}
60
61