All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.haoxuer.discover.user.rest.convert.MenuBasicSimpleConvert Maven / Gradle / Ivy

There is a newer version: 3.3.18-20230117
Show newest version
package com.haoxuer.discover.user.rest.convert;

import com.haoxuer.discover.config.utils.ConverResourceUtils;
import com.haoxuer.discover.data.rest.core.Conver;
import com.haoxuer.discover.user.api.domain.simple.MenuSimple;
import com.haoxuer.discover.user.data.entity.Menu;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;


@Data
public class MenuBasicSimpleConvert implements Conver {

    private int fetch;

    @Override
    public MenuSimple conver(Menu source) {
        MenuSimple result = new MenuSimple();

        result.setId(source.getId());
        result.setLabel(source.getName());
        result.setValue("" + source.getId());
        result.setName(source.getName());
        result.setIcon(source.getIcon());
        result.setPath(source.getPath());
        result.setPermission(source.getPermission());
        result.setCatalog(source.getCatalog());
        result.setIds(source.getIds());
        if (fetch != 0 && source.getChildrens() != null && source.getChildrens().size() > 0) {
            List menus =   ConverResourceUtils.converList(source.getChildrens(), this);
            List simples = menus.stream().filter(item -> item.getCatalog() == 0).collect(Collectors.toList());
            result.setChildren(simples);
        }
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy