https://wuliu.taobao.com/user/output_address.do?range=country
https://wuliu.taobao.com/user/output_address.do?range=province
https://wuliu.taobao.com/user/output_address.do?range=city
https://wuliu.taobao.com/user/output_address.do?range=county
将上面获取的json拷贝到txt文件里面,下面是mac系统的,如果是windows系统,那么修改
String url = "/Users/tentsuuhou/Desktop/"+name+".txt";
这个路径转换程你拷贝json到txt文件的路径就可以了
package com.dtb.member.controller.api;import com.dtb.member.mapper.AreaDaoMapper;import com.dtb.member.service.ApiLogService;import com.dtb.member.util.DateUtils;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import java.io.File;import java.io.FileReader;import java.io.IOException;import java.util.*;/** * @Author:ChengJian * @Description: * @Date: Created in 下午3:21 2019/4/2 */@Controller@RequestMapping(value = "/upload")public class AreaController { @Autowired AreaDaoMapper areaDaoMapper; @RequestMapping(value = "/area.html") @ResponseBody public String upload(String name) throws IOException { String url = "/Users/tentsuuhou/Desktop/"+name+".txt"; File file = new File(url); FileReader reader = new FileReader(file); int fileLength = (int)file.length(); char[] chars = new char[fileLength]; reader.read(chars); String area [] = String.valueOf(chars).split("]"); List
public interface AreaDaoMapper { int insertArea(List
INSERT INTO t_shop_county (administrative_code, area_name, parent_administrative_code, pin_yin_name, add_time, update_time) VALUES (#{item.num1},#{item.num2},#{item.num3},#{item.num4},#{item.num5},#{item.num6})