package de.thpeetz.kontor.models.comics;

import java.util.Date;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import lombok.Getter;
import lombok.Setter;

@Entity
@Table(name = "issue_work")
@Getter
@Setter
public class IssueWork {

    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    private String id;

    @Version
    private int version;

    @Column(name = "created_date")
    private Date createdDate;

    @Column(name = "last_modified_date")
    private Date lastModifiedDate;

    @ManyToOne
    @JoinColumn(name = "issue_id", nullable = false)
    private Issue issue;

    @ManyToOne
    @JoinColumn(name = "artist_id", nullable = false)
    private Artist artist;

    @ManyToOne
    @JoinColumn(name = "work_type_id", nullable = false)
    private Worktype workType;

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("IssueWork{");
        sb.append("issue=").append(issue);
        sb.append(", artist=").append(artist);
        sb.append(", workType=").append(workType);
        sb.append('}');
        return sb.toString();
    }
}
