package com.kalyshev.yan.user.model;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.util.Objects;

@Entity
@Table(name = "user_u")
public class User {
    @Id
    @GeneratedValue
    private Long id;
    private String login;
    private String fio;
    private String phone;
    private String password;
    private String role;
    public User() {
    }
    public User(String login, String fio, String phone, String password, String role) {
        this.login = login;
        this.fio = fio;
        this.phone = phone;
        this.password = password;
        this.role = role;
    }
    public User(Long id, String login, String fio, String phone, String password, String role) {
        this.id = id;
        this.login = login;
        this.fio = fio;
        this.phone = phone;
        this.password = password;
        this.role = role;
    }

    public Long getId() {
        return id;
    }
    public String getLogin() {
        return login;
    }
    public void setLogin(String login) {
        this.login = login;
    }
    public String getFio() {
        return fio;
    }
    public void setFio(String fio) {
        this.fio = fio;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getRole() {
        return role;
    }
    public void setRole(String role) {
        this.role = role;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof User))
            return false;
        User user = (User) o;
        return Objects.equals(id, user.id) &&
                Objects.equals(this.login, user.login) &&
                Objects.equals(this.fio, user.fio) &&
                Objects.equals(this.phone, user.phone) &&
                Objects.equals(this.password, user.password) &&
                Objects.equals(this.role, user.role);
    }
    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", login='" + login + '\'' +
                ", fio='" + fio + '\'' +
                ", phone='" + phone + '\'' +
                ", password='" + password + '\'' +
                ", role='" + role + '\'' +
                '}';
    }
}
