联动
@Data
public class NationVo {
//省市区都是id
private Integer id;
//省市区名称
private String name;
//省对应市 市对应区的集合
private List<NationVo> list;
}
<resultMap id="mapVo" type="com.wanghao.wanghaopersys.entity.NationVo">
<id column="id" property="id" ></id>
<result column="provinceName" property="name" ></result>
<collection property="list" ofType="com.wanghao.wanghaopersys.entity.NationVo">
<id column="bid" property="id" ></id>
<result column="cityName" property="name" ></result>
<collection property="list" ofType="com.wanghao.wanghaopersys.entity.NationVo">
<id column="cid" property="id" ></id>
<result column="districtName" property="name" ></result>
</collection>
</collection>
</resultMap>
<select id="findAll" resultMap="mapVo">
SELECT
a.id ,a.`province` provinceName,
b.id bid,b.city cityName,
c.id cid,c.district districtName
FROM nation a
LEFT JOIN nation b ON a.`id`=b.parent
LEFT JOIN nation c ON b.`id`=c.parent
WHERE a.parent=1
</select>
insertModel: {
username: ‘’,
phone: ‘’,
sex: ‘0’,
userface: ‘’,
province: ‘’,
city: ‘’,
district: ‘’
},