Commit 19595791 by 陶光胜

省市区

parent 24602bfc
......@@ -4,11 +4,14 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.plug.web.vo.CityVO;
import com.gic.plug.web.vo.CountyVO;
import com.gic.plug.web.vo.ProvinceVO;
import com.gic.store.dto.CityDTO;
import com.gic.store.dto.CountyDTO;
import com.gic.store.dto.ProvinceDTO;
import com.gic.store.service.ProvincesApiService;
import com.gic.store.utils.ErrorCode;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -57,4 +60,40 @@ public class ProvincesController {
}
return RestResponse.success();
}
@RequestMapping("query-provinces")
@ResponseBody
public Object searchProvinces(String search){
ServiceResponse<List<ProvinceDTO>> serviceResponse = this.provincesApiService.queryProvinces(search);
if(serviceResponse.isSuccess()){
return RestResponse.success(EntityUtil.changeEntityListByJSON(ProvinceVO.class, serviceResponse.getResult()));
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
@RequestMapping("query-city")
@ResponseBody
public Object searchCitys(String search){
if(StringUtils.isBlank(search)){
RestResponse.failure(ErrorCode.ERR_2.getCode(), ErrorCode.ERR_2.getMsg());
}
ServiceResponse<List<CityDTO>> serviceResponse = this.provincesApiService.queryCity(search);
if(serviceResponse.isSuccess()){
return RestResponse.success(EntityUtil.changeEntityListByJSON(CityVO.class, serviceResponse.getResult()));
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
@RequestMapping("query-county")
@ResponseBody
public Object searchCounty(String search){
if(StringUtils.isBlank(search)){
RestResponse.failure(ErrorCode.ERR_2.getCode(), ErrorCode.ERR_2.getMsg());
}
ServiceResponse<List<CountyDTO>> serviceResponse = this.provincesApiService.queryCounty(search);
if(serviceResponse.isSuccess()){
return RestResponse.success(EntityUtil.changeEntityListByJSON(CountyVO.class, serviceResponse.getResult()));
}
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment