package com.alterdekim.game.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="roles")
public class Role
{
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable=false, unique=true)
    @Enumerated(EnumType.STRING)
    private RoleType name;

    @ManyToMany(mappedBy="roles")
    private List<User> users;

    public Role(RoleType name) {
        this.name = name;
    }

    public enum RoleType {
        RoleUser,
        RoleAdmin
    }
}
