Commit e030d109 by huangZW

111

parent 5c294239
......@@ -8,6 +8,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
......@@ -180,39 +181,38 @@ public class StoreController extends WebBaseController{
//获取首页销售数据
@IgnoreLogin
@RequestMapping("/get-area-list")
public HaobanResponse getArea(String id) {
Map<String,Object> map = new HashMap<>();
Map<String, ProvinceDTO> provinceMap = GlobalDictMap.provinceMap;
Map<String,CityDTO> cityMap = GlobalDictMap.cityMap;
Map<String,CountyDTO> countyMap = GlobalDictMap.countyMap;
List<ProvinceDTO> provinceList=new ArrayList<ProvinceDTO>();
List<CityDTO> cityList=new ArrayList<CityDTO>();
List<CountyDTO>countyList=new ArrayList<CountyDTO>();
for (String key : provinceMap.keySet()) {
provinceList.add(provinceMap.get(key));
}
for (String key : cityMap.keySet()) {
cityList.add(cityMap.get(key));
}
for (String key : countyMap.keySet()) {
countyList.add(countyMap.get(key));
}
if(StringUtils.isEmpty(id)){
//省
return resultResponse(HaoBanErrCode.ERR_1,provinceList);
}else{
if(cityMap.containsKey(id)){
//市
return resultResponse(HaoBanErrCode.ERR_1,cityList);
}else if(countyMap.containsKey(id)){
//区
return resultResponse(HaoBanErrCode.ERR_1,countyList);
}
public HaobanResponse getArea(Integer type,String id) {
if (type == null) {
return resultResponse(HaoBanErrCode.ERR_2);
}
map.put("province", provinceList);
map.put("city", cityList);
map.put("country", countyList);
return resultResponse(HaoBanErrCode.ERR_8,map);
switch (type) {
// 省
case 1:
return resultResponse(HaoBanErrCode.ERR_1, GlobalDictMap.provinceMap);
// 市
case 2:
Map<String, CityDTO> tabCityMap = GlobalDictMap.cityMap;
Map<String, CityDTO> cityMap = new HashMap<String, CityDTO>();
Set<Map.Entry<String, CityDTO>> citySet = tabCityMap.entrySet();
for (Map.Entry<String, CityDTO> entry : citySet) {
if (entry.getValue().getProvinceId().equals(id)) {
cityMap.put(entry.getKey(), entry.getValue());
}
}
return resultResponse(HaoBanErrCode.ERR_1, cityMap);
case 3:
Map<String, CountyDTO> tabCountyMap = GlobalDictMap.countyMap;
Map<String, CountyDTO> countyMap = new HashMap<String, CountyDTO>();
Set<Map.Entry<String, CountyDTO>> tabSet = tabCountyMap.entrySet();
for (Map.Entry<String, CountyDTO> entry : tabSet) {
if (entry.getValue().getCityId().equals(id)) {
countyMap.put(entry.getKey(), entry.getValue());
}
}
return resultResponse(HaoBanErrCode.ERR_1, countyMap);
}
return resultResponse(HaoBanErrCode.ERR_8);
}
//获取首页销售数据
@RequestMapping("/change-store-detail")
......
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