package com.example.volunteer.model;

import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * ============================================================================
 * (a) 实体模型 / Entity model — Volunteer（志愿者）
 * ============================================================================
 *
 * 【题目 / Question (a)】
 * EN — Design and write the Java code for the entity models – Volunteer, Event and
 *      Signup. You may need to add more attributes and methods wherever necessary.
 *      You do NOT need to write the respective getters and setters in the exam.
 * 中 — 设计并写出实体模型 Volunteer、Event、Signup 的 Java 代码；可按需增加属性与方法。
 *      考试中不需要写 getter/setter（本工程为了能真正运行，全部写全）。
 *
 * 【关系 / Relationship】
 * EN — One volunteer has many sign-ups; the foreign key lives in the signup table.
 *      The inverse side uses mappedBy = "volunteer".
 * 中 — 一个志愿者有多条报名记录；外键在 signup 表；反向端用 mappedBy = "volunteer"。
 *
 * 生成表 / Generated table:
 *   volunteer(id, name, email, phone)
 *   signup(..., volunteer_id)   ← 外键在这里
 */
@Entity
public class Volunteer {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String name;
    private String email;
    private String phone;

    /** 反向端：不写库，只用于导航。mappedBy 的值是 Signup 类里的字段名。 */
    @OneToMany(mappedBy = "volunteer")
    private List<Signup> signups = new ArrayList<>();

    public Volunteer() { }

    public Volunteer(String name, String email, String phone) {
        this.name = name;
        this.email = email;
        this.phone = phone;
    }

    // ------------------------------------------------------------------ getters / setters

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getName() { return name; }
    public void setName(String name) { this.name = name; }

    public String getEmail() { return email; }
    public void setEmail(String email) { this.email = email; }

    public String getPhone() { return phone; }
    public void setPhone(String phone) { this.phone = phone; }

    public List<Signup> getSignups() { return signups; }
    public void setSignups(List<Signup> signups) { this.signups = signups; }
}
