基本菜单、层级管理
- 功能实现:根据父级菜单,查出所有子菜单
核心:parentId
- 新建SystemMenuQueryObject,存储parentId
- SQL都是内联查询,加parentId是否为空判断,用于query拼接
<sql id="conditions_sql">
<where>
<if test="parentId==null">
and child.parent_id is null
</if>
<if test="parentId!=null">
and child.parent_id =#{parentId}
</if>
</where>
</sql>
queryForCount/queryForList都需要,必须使用左外连接,否则父菜单为空时查询不出来
<include refid="conditions_sql"/>
- 新增、编辑、查看下级