AddressController.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.iamberry.rst.controllers.address;
  2. import com.iamberry.rst.core.address.City;
  3. import com.iamberry.rst.core.address.District;
  4. import com.iamberry.rst.core.address.Province;
  5. import com.iamberry.rst.faces.address.AddressService;
  6. import com.iamberry.wechat.tools.ResponseJson;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. import java.util.List;
  12. @Controller
  13. @RequestMapping("/address")
  14. public class AddressController {
  15. @Autowired
  16. private AddressService addressService;
  17. /**
  18. * 获取省
  19. * @param province
  20. * @return
  21. */
  22. @ResponseBody
  23. @RequestMapping(value = "/list_province")
  24. ResponseJson listProvince(Province province){
  25. ResponseJson rj =new ResponseJson(200, "查询成功", 200);
  26. List<Province> provinceList = addressService.listProvince(province);
  27. rj.addResponseKeyValue("provinceList", provinceList);
  28. if (provinceList == null || provinceList.size() < 1) {
  29. return new ResponseJson(500, "查询失败", 500);
  30. } else {
  31. return rj;
  32. }
  33. }
  34. /**
  35. * 获取市
  36. * @param city
  37. * @return
  38. */
  39. @ResponseBody
  40. @RequestMapping(value = "/list_city")
  41. ResponseJson listCity(City city){
  42. ResponseJson rj =new ResponseJson(200, "查询成功", 200);
  43. List<City> cityList = addressService.listCity(city);
  44. rj.addResponseKeyValue("cityList", cityList);
  45. if (cityList == null || cityList.size() < 1) {
  46. return new ResponseJson(500, "查询失败", 500);
  47. } else {
  48. return rj;
  49. }
  50. }
  51. /**
  52. * 获取省
  53. * @param district
  54. * @return
  55. */
  56. @ResponseBody
  57. @RequestMapping(value = "/list_district")
  58. ResponseJson listDistrict(District district){
  59. ResponseJson rj =new ResponseJson(200, "查询成功", 200);
  60. List<District> districtList = addressService.listDistrict(district);
  61. rj.addResponseKeyValue("cityList", districtList);
  62. if (districtList == null || districtList.size() < 1) {
  63. return new ResponseJson(500, "查询失败", 500);
  64. } else {
  65. return rj;
  66. }
  67. }
  68. }