省地市联动组件,根据element-ui组件的json格式要求,返回对应的数据结构,首先我们得有一张表记录中国的省市区数据
类似于这样,然后我们用java8 的stream api来实现数据拼接
public Map<String, Object> getCountry() {
StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append("select t4.id as id,t1.name as country,t2.name as province,")
.append("t3.name as city,t4.name as area ")
.append("from CenterBasRegion t1 left join CenterBasRegion t2 on t1.id = t2.p_id ")
.append("left join CenterBasRegion t3 on t3.p_id = t2.id ")
.append("left join CenterBasRegion t4 on t4.p_id = t3.id ")
.append("where t1.`type` = 1 and t2.`type` = 2 and t3.`type` = 3 and t