bug fix 1018
This commit is contained in:
@@ -3,9 +3,9 @@ package com.peanut.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.peanut.modules.book.entity.CityEntity;
|
||||
import com.peanut.modules.book.entity.CountyEntity;
|
||||
import com.peanut.modules.book.entity.ProvinceEntity;
|
||||
import com.peanut.modules.book.entity.City;
|
||||
import com.peanut.modules.book.entity.County;
|
||||
import com.peanut.modules.book.entity.Province;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -14,7 +14,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ReadProvinceUtil {
|
||||
public static List<ProvinceEntity> getFile(String filePath) {
|
||||
public static List<Province> getFile(String filePath) {
|
||||
JSONArray proJsonArray = null;
|
||||
JSONArray cityJsonArray = null;
|
||||
JSONArray countyJsonArray = null;
|
||||
@@ -23,9 +23,9 @@ public class ReadProvinceUtil {
|
||||
JSONObject countyJson = null;
|
||||
Date date = new Date();
|
||||
|
||||
List<ProvinceEntity> provinceList = null;
|
||||
List<CityEntity> cityList = null;
|
||||
List<CountyEntity> countyList = null;
|
||||
List<Province> provinceList = null;
|
||||
List<City> cityList = null;
|
||||
List<County> countyList = null;
|
||||
|
||||
// String path = request.getSession().getServletContext().getRealPath("/");
|
||||
// path = path + filePath;
|
||||
@@ -39,29 +39,29 @@ public class ReadProvinceUtil {
|
||||
if (proJson != null) {
|
||||
// 取出数据
|
||||
proJsonArray = proJson.getJSONArray("china");
|
||||
provinceList = new ArrayList<ProvinceEntity>();
|
||||
provinceList = new ArrayList<Province>();
|
||||
if (proJsonArray != null) {
|
||||
for (int i = 0; i < proJsonArray.size(); i++) {
|
||||
ProvinceEntity province = new ProvinceEntity();
|
||||
Province province = new Province();
|
||||
JSONObject temp = proJsonArray.getJSONObject(i);
|
||||
province.setProvName(temp.getString("name"));
|
||||
province.setCreateDate(date);
|
||||
province.setRegionCode(temp.getString("code"));
|
||||
|
||||
cityJsonArray = JSONArray.parseArray(temp.getString("cityList"));
|
||||
cityList = new ArrayList<CityEntity>();
|
||||
cityList = new ArrayList<City>();
|
||||
if (cityJsonArray != null) {
|
||||
for (int j = 0; j < cityJsonArray.size(); j++) {
|
||||
CityEntity city = new CityEntity();
|
||||
City city = new City();
|
||||
cityJson = cityJsonArray.getJSONObject(j);
|
||||
city.setCityName(cityJson.getString("name"));
|
||||
city.setRegionCode(cityJson.getString("code"));
|
||||
city.setCreateDate(date);
|
||||
countyJsonArray = JSONArray.parseArray(cityJson.getString("areaList"));
|
||||
countyList = new ArrayList<CountyEntity>();
|
||||
countyList = new ArrayList<County>();
|
||||
if (countyJsonArray != null) {
|
||||
for (int k = 0; k < countyJsonArray.size(); k++) {
|
||||
CountyEntity county = new CountyEntity();
|
||||
County county = new County();
|
||||
countyJson = countyJsonArray.getJSONObject(k);
|
||||
county.setCountyName(countyJson.getString("name"));
|
||||
county.setRegionCode(countyJson.getString("code"));
|
||||
|
||||
Reference in New Issue
Block a user