package com.izouma.jmrh.security;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
public class DataCenterAuthority implements Serializable {
    public enum NAMES {
        ROLE_USER, ROLE_DEV, ROLE_ADMIN, ROLE_INTERACT, ROLE_NOTICE, ROLE_POLICY, ROLE_SUPPLY
    }

    @Id
    @Size(max = 50)
    @NotNull
    @Column(length = 50)
    private String name;


    @ApiModelProperty(name = "名称")
    private String nameDesc;

    @ApiModelProperty(name = "描述")
    private String description;

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

        DataCenterAuthority authority = (DataCenterAuthority) o;

        return Objects.equals(name, authority.name);
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }

    public DataCenterAuthority(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Authority{" +
                "name='" + name + '\'' +
                "}";
    }
}
