package easydo.technology.system.dto;

import easydo.technology.base.CommonDto;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.Objects;

/**
 * @author jinjin
 * @date 2020-09-25
 */
@Getter
@Setter
public class MenuDto extends CommonDto {
    private static final long serialVersionUID = 1L;

    private Long id;

    private Long pid;

    private List<MenuDto> children;

    private Integer subCount;

    private Integer type;

    private String title;

    private String componentName;

    private String component;

    private Integer menuSort;

    private String icon;

    private String path;

    private Boolean iFrame;

    private Boolean cache;

    private Boolean hidden;

    private String permission;

    private String platformType;

    public Boolean getHasChildren() {
        return subCount > 0;
    }

    public Boolean getLeaf() {
        return subCount <= 0;
    }

    public String getLabel() {
        return title;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MenuDto menuDto = (MenuDto) o;
        return Objects.equals(id, menuDto.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

}
