package ru.ldeloff.hedgehogcloud.entity;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.*;
import java.util.Set;

@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "roles")
public class RoleEntity extends BaseEntity implements GrantedAuthority {
    private String name;
    @Transient
    @ManyToMany
    private Set<UserEntity> users;

    public String getName() {
        return name;
    }
    @Override
    public String getAuthority() {
        return getName();
    }
}
