Search in sources :

Example 1 with MenuDTO

use of com.hb0730.boot.admin.project.system.menu.model.dto.MenuDTO in project boot-admin by hb0730.

the class MenuServiceImpl method getChildrenByParenId.

@Override
@Nullable
public List<MenuDTO> getChildrenByParenId(@Nonnull Long id) {
    Assert.notNull(id, "id不为空");
    List<MenuEntity> entities = super.list();
    List<MenuDTO> menu = BeanUtil.copyToList(entities, MenuDTO.class);
    List<MenuDTO> result = Lists.newArrayList();
    for (MenuDTO dto : menu) {
        // 第一级
        if (dto.getParentId().equals(id)) {
            result.add(dto);
            for (MenuDTO item : menu) {
                if (dto.getId().equals(item.getParentId())) {
                    result.add(item);
                }
            }
        }
    }
    return result;
}
Also used : MenuEntity(com.hb0730.boot.admin.project.system.menu.model.entity.MenuEntity) TreeMenuDTO(com.hb0730.boot.admin.project.system.menu.model.dto.TreeMenuDTO) MenuDTO(com.hb0730.boot.admin.project.system.menu.model.dto.MenuDTO) Nullable(javax.annotation.Nullable)

Aggregations

MenuDTO (com.hb0730.boot.admin.project.system.menu.model.dto.MenuDTO)1 TreeMenuDTO (com.hb0730.boot.admin.project.system.menu.model.dto.TreeMenuDTO)1 MenuEntity (com.hb0730.boot.admin.project.system.menu.model.entity.MenuEntity)1 Nullable (javax.annotation.Nullable)1