1、数据表结构
2、实体类
@Data public class GzSiteMap extends BaseEntity { private static final long serialVersionUID = 1L; /** * 主键 */ private Long id; /** * 名字 */ @Excel(name = "名字") private String mapName; /** * 图标 */ @Excel(name = "图标") private String mapImg; /** * 父级id */ @Excel(name = "父级id") private Long mapParentId; /** * 父级id */ @Excel(name = "父级id") private List<GzSiteMap> childMenuList; }
3、mapper
<select id="selectMenuList" resultMap="BaseResultMap"> select * from gz_site_map where map_level = 0 </select> <resultMap id="BaseResultMap" type="com.api.domain.GzSiteMap"> <result property="id" column="id"/> <result property="mapName" column="map_name"/> <result property="mapImg" column="map_img"/> <result property="mapParentId" column="map_parent_id"/> <collection property="childMenuList" javaType="java.util.ArrayList" ofType="com.api.utils.MenuChild" select="getChildLists" column="id"/> </resultMap> <select id="getChildLists" parameterType="String" resultMap="BaseResultMap"> select * from gz_site_map where map_parent_id = #{id} </select>
4、介绍