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

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.sop.common.enums.PrivilegeEnum;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 权限dto
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2022/9/16
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PrivilegeDto implements Serializable, Comparable<PrivilegeDto> {

    @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 List<PrivilegeDto> children = new ArrayList<>();

    @ApiModelProperty(value = "按钮权限集合")
    List<MenuDto> buttons;

    @ApiModelProperty(value = "链接权限集合")
    List<MenuDto> links;

    @ApiModelProperty(value = "数据列表权限集合")
    List<MenuDto> lists;

    @ApiModelProperty(value = "查询列表权限集合")
    List<MenuDto> conditions;

    public List<MenuDto> getButtons() {
        return buttons;
    }

    public void setButtons(List<MenuDto> buttons) {
        this.buttons = buttons;
    }

    public List<MenuDto> getLinks() {
        return links;
    }

    public void setLinks(List<MenuDto> links) {
        this.links = links;
    }

    public List<MenuDto> getLists() {
        return lists;
    }

    public void setLists(List<MenuDto> lists) {
        this.lists = lists;
    }

    public List<MenuDto> getConditions() {
        return conditions;
    }

    public void setConditions(List<MenuDto> conditions) {
        this.conditions = conditions;
    }

    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;
    }

    public PrivilegeEnum getType() {
        return type;
    }

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

    public Long getParentId() {
        return parentId;
    }

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

    public Integer getSequence() {
        return sequence;
    }

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

    public List<PrivilegeDto> getChildren() {
        return children;
    }

    public void setChildren(List<PrivilegeDto> children) {
        this.children = children;
    }

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