package com.example.demo.entrysData.model;

import java.util.Objects;

import com.example.demo.core.model.BaseEntity;
import com.example.demo.department.model.DepartmentEntity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

@Entity
@Table(name = "entrysData")
public class EntrysDataEntity extends BaseEntity {
    @Column(nullable = false, unique = true, length = 30)
    private String login;
    @Column(nullable = false, unique = false, length = 25)
    private String password;
    @Column(nullable = false, unique = false, length = 10)
    private String role;
    @ManyToOne
    @JoinColumn(name = "departmentId", nullable = false)
    private DepartmentEntity department;

    public EntrysDataEntity() {
    }

    public EntrysDataEntity(String login, String password, String role, DepartmentEntity department) {
        this.login = login;
        this.password = password;
        this.role = role;
        this.department = department;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    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;
    }

    public DepartmentEntity getDepartment() {
        return department;
    }

    public void setDepartment(DepartmentEntity department) {
        this.department = department;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, login);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null || getClass() != obj.getClass())
            return false;
        final EntrysDataEntity other = (EntrysDataEntity) obj;
        return Objects.equals(other.getId(), id)
                && Objects.equals(other.getLogin(), login)
                && Objects.equals(other.getPassword(), password)
                && Objects.equals(other.getRole(), role)
                && Objects.equals(other.getDepartment(), department);
    }
}
