add table comment

This commit is contained in:
Valentin CZERYBA 2023-01-09 21:24:39 +01:00
parent 040be10c68
commit 127ed20959
4 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,65 @@
package com.covas.Entity;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.CascadeType;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.GenericGenerator;
import com.covas.Enum.Type;
import io.quarkus.hibernate.orm.panache.PanacheEntityBase;
@Entity
@Table(name = "comment")
@NamedQueries({
@NamedQuery(name = "Comment.bySearch", query = "from CommentEntity u where u.comment like :comment"),
})
public class CommentEntity extends PanacheEntityBase implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
public UUID id;
@Column(columnDefinition="TEXT")
public String comment;
@Column(nullable = false)
public LocalDateTime created_at;
@Column(nullable = false)
public LocalDateTime updated_at;
@ColumnDefault("null")
public LocalDateTime deleted_at;
@ColumnDefault("1")
public Short status;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "users_id", referencedColumnName = "id")
public UsersEntity users;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "publishers_id", referencedColumnName = "id")
public PublisherEntity publishers;
public static List<CommentEntity> findByUsers(String uuid){
return find("users_id", uuid).list();
}
}

View File

@ -60,6 +60,10 @@ public class PublisherEntity extends PanacheEntityBase implements Serializable {
@JoinColumn(name = "users_id", referencedColumnName = "id")
public UsersEntity users;
@OneToMany(mappedBy = "publishers")
public Collection<CommentEntity> comment;
public static List<PublisherEntity> findByUsers(String uuid){
return find("users_id", uuid).list();
}

View File

@ -77,6 +77,9 @@ public class UsersEntity extends PanacheEntityBase implements Serializable {
@OneToMany(mappedBy = "users")
public Collection<PublisherEntity> publisher;
@OneToMany(mappedBy = "users")
public Collection<CommentEntity> comment;
public static UsersEntity findByPseudo(String pseudo){
return find("pseudo", pseudo).firstResult();
}

View File

@ -1,6 +1,6 @@
package com.covas.Enum;
public enum Type {
VIDEO, PHOTO, TEXT, URL
VIDEO, PHOTO, TEXT, URL, EVENT
}