package com.codenetworkz.blog.models;

import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "users")
public class User extends BaseModel{

    @Size(min = 5, max =  20, message = "First Name should be more then 5 and less then 50 character required.")
    private String firstName;

    @Size(min = 5, max =  20 , message = "Last Name should be  more then 5 and less then 50 character required.")
    private String lastName;

    @Email(message =  "valid Email required")
    @Column(unique = true)
    private String email;

    @Column(unique = true)
    private String username;

    private String passwordHash;

    @Column(length = 1, nullable = false)
    private Status teamsAccepted;

    @Size(max = 255, message = "About your information Required")
    private String bio;

    @Size(max = 255, message = "Profile Picture url Required")
    private String profilePictureUrl;

    @ManyToMany
    @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id") , inverseJoinColumns = @JoinColumn(name = "role_id"))
    private List<Role> roles;

}
