package com.apobates.forum.core.entity;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

/**
 * 轮播图
 *
 * @author xiaofanku
 * @since 20200614
 */
@Entity
@Table(name = "apo_topic_carousel", uniqueConstraints = { @UniqueConstraint(columnNames = {"title"})})
public class TopicCarousel implements Serializable{
    private static final long serialVersionUID = -1581434329680631553L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private int id;
    //建议用英文
    private String title;
    //描述
    private String summary;
    //true可用,false禁用
    private boolean status;
    
    //empty constructor for JPA instantiation
    public TopicCarousel() {
        super();
    }
    
    public TopicCarousel(String title, String summary, boolean status) {
        this.id = 0;
        this.title = title;
        this.summary = summary;
        this.status = status;
    }
    
    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getTitle() {
        return title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    
    public String getSummary() {
        return summary;
    }
    
    public void setSummary(String summary) {
        this.summary = summary;
    }
    
    public boolean isStatus() {
        return status;
    }
    
    public void setStatus(boolean status) {
        this.status = status;
    }
    
    @Override
    public int hashCode() {
        int hash = 5;
        hash = 41 * hash + Objects.hashCode(this.title);
        return hash;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final TopicCarousel other = (TopicCarousel) obj;
        if (!Objects.equals(this.title, other.title)) {
            return false;
        }
        return true;
    }
    
    @Transient
    public static TopicCarousel empty() {
        return new TopicCarousel("", "", true);
    }
}