多对多 查询 框架有办法简化操作吗
String sqlstr = " select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, " +
" m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, " +
" m.order_num, m.create_time " +
" from sys_menu m " +
" left join sys_role_menu rm on m.menu_id = rm.menu_id " +
" left join sys_user_role ur on rm.role_id = ur.role_id " +
" left join sys_role ro on ur.role_id = ro.role_id " +
" where ur.user_id = @userId";
if (Strings.isNotBlank(menu.getMenuName())) {
sqlstr += " AND m.menu_name like concat('%', @menuName, '%')";
}
if (Strings.isNotBlank(menu.getVisible())) {
sqlstr += " AND m.visible = @visible";
}
if (Strings.isNotBlank(menu.getStatus())) {
sqlstr += " AND m.status = @status";
}
sqlstr += " order by m.parent_id, m.order_num";
Sql sql = Sqls.create(sqlstr);
sql.params().set("userId" , userId);
sql.params().set("menuName" , menu.getMenuName());
sql.params().set("visible" , menu.getVisible());
sql.params().set("status" , menu.getStatus());
sql.setCallback(Sqls.callback.entities());
Entity<SysMenu> entity = dao().getEntity(SysMenu.class);
sql.setEntity(entity);
dao().execute(sql);
queryByJoin 可以用吗 但多个的条件怎么设置呢