package com.bio.bio_backend.domain.base.member.entity;

import com.bio.bio_backend.global.constants.AppConstants;
import com.bio.bio_backend.global.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

import org.hibernate.annotations.Comment;

@Entity
@Getter @Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(
    name = AppConstants.TABLE_PREFIX + "member",
    indexes = {
        @Index(name = "idx_member_user_id", columnList = "user_id")
    }
)
public class Member extends BaseEntity {

    @Column(name = "user_id", nullable = false, length = 100)
    @Comment("사용자 ID")
    private String userId;

    @Column(name = "password", nullable = false, length = 100)
    @Comment("비밀번호")
    private String password;

    @Column(name = "name", nullable = false, length = 100)
    @Comment("이름")
    private String name;

    @Column(name = "email", nullable = false, length = 255)
    @Comment("이메일")
    private String email;

    @Column(name = "use_flag", nullable = false)
    @Comment("사용 여부")
    @Builder.Default
    private Boolean useFlag = true;

    @Column(name = "refresh_token", length = 1024)
    @Comment("리프레시 토큰")
    private String refreshToken;

    @Column(name = "login_ip", length = 45)  // IPv6 지원을 위해 45자
    @Comment("로그인 IP")
    private String loginIp;

    @Column(name = "last_login_at")
    @Comment("마지막 로그인 일시")
    private LocalDateTime lastLoginAt;
    
}