Commit f127c889 by zhiwj

Merge remote-tracking branch 'origin/developer' into developer

parents 4bceae29 b6049242
package com.gic.plug.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
......@@ -11,6 +12,7 @@ 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 org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
......@@ -139,4 +141,39 @@ public class ProvincesController {
}
return RestResponse.success(result);
}
@RequestMapping("dict-provinces-citys")
@ResponseBody
public RestResponse listProvincesCitys(){
ServiceResponse<List<ProvinceDTO>> serviceResponse = this.provincesApiService.selectAllProvince();
ServiceResponse<List<CityDTO>> serviceResponse1 = this.provincesApiService.selectAllCity();
List<JSONObject> result = new ArrayList<>();
if(serviceResponse.isSuccess()){
List<ProvinceDTO> list = serviceResponse.getResult();
if(CollectionUtils.isNotEmpty(list)){
for(ProvinceDTO provinceDTO : list){
JSONObject jsonObject = new JSONObject();
jsonObject.put("provinceId", provinceDTO.getProvinceId());
jsonObject.put("provinceName", provinceDTO.getProvinceName());
if(serviceResponse1.isSuccess()){
List<CityDTO> cityDTOList = serviceResponse1.getResult();
if(CollectionUtils.isNotEmpty(cityDTOList)){
List<JSONObject> jsonObjectList = new ArrayList<>();
for(CityDTO cityDTO : cityDTOList){
if(cityDTO.getProvinceId().equals(provinceDTO.getProvinceId())){
JSONObject object = new JSONObject();
object.put("cityId", cityDTO.getCityId());
object.put("cityName", cityDTO.getCityName());
jsonObjectList.add(object);
}
}
jsonObject.put("children", jsonObjectList);
}
}
result.add(jsonObject);
}
}
}
return RestResponse.success(result);
}
}
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