package de.thpeetz.kontor.admin.data;

import de.thpeetz.kontor.common.data.AbstractEntity;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
public class Assignment extends AbstractEntity {

    @ManyToOne
    @JoinColumn(name = "profile_id")
    @NotNull
    private Profile profile;

    @ManyToOne
    @JoinColumn(name = "permission_id")
    @NotNull
    private Permission permission;

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("Assignment{");
        sb.append("profile=").append(profile.getUserName());
        sb.append(", permission=").append(permission.getName());
        sb.append('}');
        return sb.toString();
    }
}
