package com.qmth.sop.business.bean.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.sop.common.enums.PrivilegeEnum;

import java.io.Serializable;
import java.util.Objects;

/**
 * @Description: 菜单dto
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2022/9/16
 */
public class MenuDto implements Serializable, Comparable<MenuDto> {

    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    private String name;

    private String url;

    private PrivilegeEnum type;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    private Integer sequence;

    private Boolean enable;

    public Integer getSequence() {
        return sequence;
    }

    public void setSequence(Integer sequence) {
        this.sequence = sequence;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public PrivilegeEnum getType() {
        return type;
    }

    public void setType(PrivilegeEnum type) {
        this.type = type;
    }

    public Long getParentId() {
        return Objects.isNull(parentId) ? -1L : parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public int compareTo(MenuDto o) {
        if (o.getSequence() < this.getSequence()) {
            return 1;
        } else if (o.getSequence() > this.getSequence()) {
            return -1;
        } else {
            return 0;
        }
    }
}
