Mybatis 注解 @Many 实现 递归菜单获取



import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MenuMapper {

@Select("select * from menu where parentid=0")
@Results(id="tree",value = {
@Result(property = "id",column = "id"),
@Result(property = "name",column = "name"),
@Result(property = "parentId",column = "parentId"),
@Result(property = "children",column = "id",many = @Many(select = "getTreeByParentId")),
})
List<Menu> getTreeList();

@Select("select * from menu where parentId = #{parentId}")
@ResultMap("tree")
List<Menu> getTreeByParentId(int parentId);
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM