From 7f36ec2d7ecfeca7718a8f48d374b8d8a3d223b4 Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Sat, 27 Jul 2019 08:17:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D0=BC=D0=B5=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../social/core/domain/content/ContentType.java | 4 +++- .../sadtech/social/core/domain/content/Mail.java | 4 ++++ .../social/core/domain/content/Message.java | 8 ++++++++ .../core/domain/content/attachment/Attachment.java | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) 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;