package it.powerbyte.springbootstarter.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.time.Instant;

@Entity()
@Table(indexes = @Index(name = "ndxUsername", columnList = "username"))
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(unique=true)
    private String username;
    private String password;
    private String role;

    private String firstname;
    private String lastname;
    private String email;

    private Instant lastLogin;

    @Column(name = "created_date", nullable = true, updatable = false)
    @CreatedDate
    private Long createdDate;

    @Column(name = "modified_date", nullable = true)
    @LastModifiedDate
    private Long modifiedDate;

    @Column(name = "created_by")
    @CreatedBy
    private String createdBy;

    @Column(name = "modified_by")
    @LastModifiedBy
    private String modifiedBy;



}
