add table comment
This commit is contained in:
parent
040be10c68
commit
127ed20959
65
src/main/java/com/covas/Entity/CommentEntity.java
Normal file
65
src/main/java/com/covas/Entity/CommentEntity.java
Normal 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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.covas.Enum;
|
||||
|
||||
public enum Type {
|
||||
VIDEO, PHOTO, TEXT, URL
|
||||
VIDEO, PHOTO, TEXT, URL, EVENT
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user