diff --git a/src/main/java/org/sadtech/social/core/domain/content/ContentType.java b/src/main/java/org/sadtech/social/core/domain/content/ContentType.java index 88635a2..4c14165 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/ContentType.java +++ b/src/main/java/org/sadtech/social/core/domain/content/ContentType.java @@ -7,6 +7,8 @@ package org.sadtech.social.core.domain.content; */ public enum ContentType { - MAIL, BOARD_COMMENT, EMPTY + MAIL, + BOARD_COMMENT, + EMPTY } diff --git a/src/main/java/org/sadtech/social/core/domain/content/Mail.java b/src/main/java/org/sadtech/social/core/domain/content/Mail.java index 248a6b3..f0b9a58 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/Mail.java +++ b/src/main/java/org/sadtech/social/core/domain/content/Mail.java @@ -5,7 +5,9 @@ import lombok.EqualsAndHashCode; import org.sadtech.social.core.domain.content.attachment.Attachment; import org.sadtech.social.core.utils.Description; +import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.OneToMany; import javax.persistence.Table; import java.util.List; @@ -20,6 +22,8 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) public class Mail extends Message { + @OneToMany + @Column(name = "attachment") @Description("Вложения к сообщению") private List attachments; diff --git a/src/main/java/org/sadtech/social/core/domain/content/Message.java b/src/main/java/org/sadtech/social/core/domain/content/Message.java index 2b4566a..459eae3 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/Message.java +++ b/src/main/java/org/sadtech/social/core/domain/content/Message.java @@ -4,7 +4,10 @@ import com.sun.istack.internal.NotNull; import lombok.Data; import org.sadtech.social.core.utils.Description; +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 java.time.LocalDateTime; @@ -23,17 +26,22 @@ public abstract class Message { @Description("Идентификатор сообщения") private Integer id; + @Column(name = "type") + @Enumerated(value = EnumType.STRING) @Description("Тип сообщения") protected ContentType type; @NotNull + @Column(name = "create_date") @Description("Дата создания") private LocalDateTime createDate; @NotNull + @Column(name = "person_id") @Description("Идентификатор пользователя, отправившего сообщение") private Integer personId; + @Column(name = "text") @Description("Текстовое сообщение") private String text; diff --git a/src/main/java/org/sadtech/social/core/domain/content/attachment/Attachment.java b/src/main/java/org/sadtech/social/core/domain/content/attachment/Attachment.java index e288600..e2c2666 100644 --- a/src/main/java/org/sadtech/social/core/domain/content/attachment/Attachment.java +++ b/src/main/java/org/sadtech/social/core/domain/content/attachment/Attachment.java @@ -3,14 +3,28 @@ package org.sadtech.social.core.domain.content.attachment; import lombok.EqualsAndHashCode; import org.sadtech.social.core.utils.Description; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + /** * Абстрактная сущность, для всех вложений к сообщениям от пользователей. * * @author upagge [08/07/2019] */ +@Entity @EqualsAndHashCode public abstract class Attachment { + @Id + @GeneratedValue + private Integer id; + + @Column(name = "type") + @Enumerated(value = EnumType.STRING) @Description("Тип сущности") protected AttachmentType type;