|
@@ -38,16 +38,10 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/list_province")
|
|
|
public ResponseJson listProvince(Province province) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
|
|
|
List<Province> provinceList = addressService.listProvince(province);
|
|
|
- rj.addResponseKeyValue("provinceList", provinceList);
|
|
|
- if (provinceList == null || provinceList.size() < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
- } else {
|
|
|
- return rj;
|
|
|
- }
|
|
|
+ return (provinceList == null || provinceList.size() < 1) ?
|
|
|
+ ResponseJson.getFAILURE() :
|
|
|
+ ResponseJson.getSUCCESS().addResponseKeyValue("provinceList", provinceList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -58,16 +52,10 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/list_city")
|
|
|
public ResponseJson listCity(City city)throws Exception{
|
|
|
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
|
|
|
List<City> cityList = addressService.listCity(city);
|
|
|
- rj.addResponseKeyValue("cityList", cityList);
|
|
|
- if (cityList == null || cityList.size() < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
- } else {
|
|
|
- return rj;
|
|
|
- }
|
|
|
+ return (cityList == null || cityList.size() < 1) ?
|
|
|
+ ResponseJson.getFAILURE() :
|
|
|
+ ResponseJson.getSUCCESS().addResponseKeyValue("cityList", cityList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -78,16 +66,10 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/list_district")
|
|
|
public ResponseJson listDistrict(District district)throws Exception{
|
|
|
- ResponseJson rj =new ResponseJson(200, "查询成功", 200);
|
|
|
List<District> districtList = addressService.listDistrict(district);
|
|
|
- rj.addResponseKeyValue("districtList", districtList);
|
|
|
- if (districtList == null || districtList.size() < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
- } else {
|
|
|
- return rj;
|
|
|
- }
|
|
|
+ return (districtList == null || districtList.size() < 1) ?
|
|
|
+ ResponseJson.getFAILURE() :
|
|
|
+ ResponseJson.getSUCCESS().addResponseKeyValue("districtList", districtList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -107,8 +89,7 @@ public class AddressController {
|
|
|
if (totalNum != 0){
|
|
|
pagedResult.setTotal(totalNum);
|
|
|
}
|
|
|
- StitchAttrUtil.getSa()
|
|
|
- .setModelAndView(province, mv, "/address/listProvinces", pagedResult);
|
|
|
+ StitchAttrUtil.getSa().setModelAndView(province, mv, "/address/listProvinces", pagedResult);
|
|
|
return mv;
|
|
|
}
|
|
|
|
|
@@ -119,7 +100,7 @@ public class AddressController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/to_add_city")
|
|
|
- public ModelAndView to_add_city(@RequestParam("provinceId") Integer provinceId) {
|
|
|
+ public ModelAndView toAddCity(@RequestParam("provinceId") Integer provinceId) {
|
|
|
return new ModelAndView("address/add_city").addObject("provinceId", provinceId);
|
|
|
}
|
|
|
|
|
@@ -130,7 +111,7 @@ public class AddressController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/to_add_district")
|
|
|
- public ModelAndView to_add_district(@RequestParam("cityId") Integer cityId) {
|
|
|
+ public ModelAndView toAddDistrict(@RequestParam("cityId") Integer cityId) {
|
|
|
return new ModelAndView("address/add_district").addObject("cityId", cityId);
|
|
|
}
|
|
|
|
|
@@ -143,20 +124,15 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/add_district")
|
|
|
public ResponseJson addDistrict(District district) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "添加成功", 200);
|
|
|
if(district.getCityId() == null || district.getDistrict() == null || district.getPostcode() == null){
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
district.setDivisionCode(district.getDistrictId());
|
|
|
Integer num = addressService.addDistrict(district);
|
|
|
if (num < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getSUCCESS();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -167,20 +143,15 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/add_city")
|
|
|
public ResponseJson addDistrict(City city) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "添加成功", 200);
|
|
|
if(city.getCityId() == null || city.getProvinceId() == null || city.getCity() == null){
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
Integer num = addressService.addCity(city);
|
|
|
city.setDivisionCode(city.getCityId());
|
|
|
if (num < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getSUCCESS();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -190,20 +161,15 @@ public class AddressController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/detect_city")
|
|
|
- public ResponseJson detect_city(HttpServletRequest request,Integer cityId) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "删除成功", 200);
|
|
|
- if(cityId == null || cityId.equals("")){
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ public ResponseJson detectCity(HttpServletRequest request,Integer cityId) throws Exception {
|
|
|
+ if(cityId == null){
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
Integer num = addressService.delCity(cityId);
|
|
|
if (num < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getSUCCESS();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -214,19 +180,14 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/del_district")
|
|
|
public ResponseJson delDistrict(Integer districtId) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "删除成功", 200);
|
|
|
- if(districtId == null || districtId.equals("")){
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ if(districtId == null){
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
Integer num = addressService.delDistrict(districtId);
|
|
|
if (num < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getSUCCESS();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -237,7 +198,7 @@ public class AddressController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/to_update_district")
|
|
|
- public ModelAndView to_update_district(@RequestParam("districtId") Integer districtId) {
|
|
|
+ public ModelAndView toUpdateDistrict(@RequestParam("districtId") Integer districtId) {
|
|
|
District district = new District();
|
|
|
district.setDistrictId(districtId);
|
|
|
List<District> districts = addressService.listDistrict(district);
|
|
@@ -251,7 +212,7 @@ public class AddressController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping("/to_update_city")
|
|
|
- public ModelAndView to_update_city(@RequestParam("cityId") Integer cityId) {
|
|
|
+ public ModelAndView toUpdateCity(@RequestParam("cityId") Integer cityId) {
|
|
|
City city = new City();
|
|
|
city.setCityId(cityId);
|
|
|
List<City> citys = addressService.listCity(city);
|
|
@@ -266,19 +227,14 @@ public class AddressController {
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/updateDistrict")
|
|
|
public ResponseJson updateDistrict(District district) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "修改成功", 200);
|
|
|
if(district == null || district.getDistrictId() == null){
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
Integer num = addressService.updateDistrict(district);
|
|
|
if (num < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getSUCCESS();
|
|
|
}
|
|
|
/**
|
|
|
* 修改市
|
|
@@ -287,20 +243,15 @@ public class AddressController {
|
|
|
*/
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/update_city")
|
|
|
- public ResponseJson update_city(City city) throws Exception {
|
|
|
- ResponseJson rj =new ResponseJson(200, "修改成功", 200);
|
|
|
+ public ResponseJson updateCity(City city) throws Exception {
|
|
|
if(city == null || city.getCityId() == null|| city.getCity() == null){
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
Integer num = addressService.updateCity(city);
|
|
|
if (num < 1) {
|
|
|
- rj.setResultCode(500);
|
|
|
- rj.setReturnCode(500);
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getFAILURE();
|
|
|
}
|
|
|
- return rj;
|
|
|
+ return ResponseJson.getSUCCESS();
|
|
|
}
|
|
|
|
|
|
}
|