package com.vibevault.model;

import jakarta.persistence.*;

/**
 * 歌曲实体类
 * 
 * 需要实现：
 * - 将此类映射为数据库表 "songs"
 * - id 作为自增主键
 * - 每首歌曲属于一个歌单（多对一关系）
 */
@Entity
@Table(name = "songs")
public class Song {

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

    @Column(nullable = false)
    private String title;

    @Column(nullable = false)
    private String artist;

    @Column(nullable = false)
    private int durationInSeconds;

    private String audioUrl;

    @ManyToOne
    private Playlist playlist;

    public Song() {
    }

    public Song(String title, String artist, int durationInSeconds) {
        this.title = title;
        this.artist = artist;
        this.durationInSeconds = durationInSeconds;
    }

    public Song(String title, String artist, int durationInSeconds, String audioUrl) {
        this.title = title;
        this.artist = artist;
        this.durationInSeconds = durationInSeconds;
        this.audioUrl = audioUrl;
    }

    public Long getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public String getArtist() {
        return artist;
    }

    public int getDurationInSeconds() {
        return durationInSeconds;
    }

    public Playlist getPlaylist() {
        return playlist;
    }

    public void setPlaylist(Playlist playlist) {
        this.playlist = playlist;
    }

    public String getAudioUrl() {
        return audioUrl;
    }

    public void setAudioUrl(String audioUrl) {
        this.audioUrl = audioUrl;
    }
}
