先看一下数据库
主键id,名称product_code,父parent,和kind
设计菜单类
setter,getter
dao
public interface productmapper {
list getproductkindrelationdto();
}
mapper.xml
select t.id,t.kind,t.parent,t.product_code from t_product_kind_relation t where t.parent is null or t.parent = ''
select t.id,t.kind,t.parent,t.product_code from t_product_kind_relation t where t.parent=#{product_code}
其中findbyparent会查询到所有的父菜单,
而在getproductkindrelationdto中我们定义了如何去查找子菜单,调用findbyparent
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!