diff --git a/backend/src/main/java/online/wesal/wesal/entity/Attendee.java b/backend/src/main/java/online/wesal/wesal/entity/Attendee.java new file mode 100644 index 0000000..6e57ae9 --- /dev/null +++ b/backend/src/main/java/online/wesal/wesal/entity/Attendee.java @@ -0,0 +1,67 @@ +package online.wesal.wesal.entity; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import java.time.LocalDateTime; + +@Entity +@Table(name = "attendees", + uniqueConstraints = @UniqueConstraint(columnNames = {"invitation_id", "user_id"})) +public class Attendee { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "invitation_id", nullable = false) + @NotNull + private Invitation invitation; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + @NotNull + private User user; + + @Column(nullable = false) + private LocalDateTime joinedAt = LocalDateTime.now(); + + public Attendee() {} + + public Attendee(Invitation invitation, User user) { + this.invitation = invitation; + this.user = user; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Invitation getInvitation() { + return invitation; + } + + public void setInvitation(Invitation invitation) { + this.invitation = invitation; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public LocalDateTime getJoinedAt() { + return joinedAt; + } + + public void setJoinedAt(LocalDateTime joinedAt) { + this.joinedAt = joinedAt; + } +} \ No newline at end of file diff --git a/backend/src/main/java/online/wesal/wesal/entity/Invitation.java b/backend/src/main/java/online/wesal/wesal/entity/Invitation.java new file mode 100644 index 0000000..4414901 --- /dev/null +++ b/backend/src/main/java/online/wesal/wesal/entity/Invitation.java @@ -0,0 +1,138 @@ +package online.wesal.wesal.entity; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Positive; +import java.time.LocalDateTime; + +@Entity +@Table(name = "invitations") +public class Invitation { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + @NotBlank + private String title; + + @Column(nullable = false, columnDefinition = "TEXT") + @NotBlank + private String description; + + private LocalDateTime dateTime; + + private String location; + + @Column(nullable = false) + @Positive + private Integer maxParticipants; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "tag_id", nullable = false) + @NotNull + private Tag tag; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "creator_id", nullable = false) + @NotNull + private User creator; + + @Column(nullable = false) + private Integer currentAttendees = 0; + + @Column(nullable = false) + private LocalDateTime createdAt = LocalDateTime.now(); + + public Invitation() {} + + public Invitation(String title, String description, Integer maxParticipants, Tag tag, User creator) { + this.title = title; + this.description = description; + this.maxParticipants = maxParticipants; + this.tag = tag; + this.creator = creator; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LocalDateTime getDateTime() { + return dateTime; + } + + public void setDateTime(LocalDateTime dateTime) { + this.dateTime = dateTime; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public Integer getMaxParticipants() { + return maxParticipants; + } + + public void setMaxParticipants(Integer maxParticipants) { + this.maxParticipants = maxParticipants; + } + + public Tag getTag() { + return tag; + } + + public void setTag(Tag tag) { + this.tag = tag; + } + + public User getCreator() { + return creator; + } + + public void setCreator(User creator) { + this.creator = creator; + } + + public LocalDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(LocalDateTime createdAt) { + this.createdAt = createdAt; + } + + public Integer getCurrentAttendees() { + return currentAttendees; + } + + public void setCurrentAttendees(Integer currentAttendees) { + this.currentAttendees = currentAttendees; + } +} \ No newline at end of file diff --git a/backend/src/main/java/online/wesal/wesal/entity/Tag.java b/backend/src/main/java/online/wesal/wesal/entity/Tag.java new file mode 100644 index 0000000..766a010 --- /dev/null +++ b/backend/src/main/java/online/wesal/wesal/entity/Tag.java @@ -0,0 +1,65 @@ +package online.wesal.wesal.entity; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotBlank; + +@Entity +@Table(name = "tags") +public class Tag { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, unique = true) + @NotBlank + private String name; + + @Column(nullable = false) + @NotBlank + private String colorHex; + + @Column(nullable = false) + @NotBlank + private String iconName; + + public Tag() {} + + public Tag(String name, String colorHex, String iconName) { + this.name = name; + this.colorHex = colorHex; + this.iconName = iconName; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getColorHex() { + return colorHex; + } + + public void setColorHex(String colorHex) { + this.colorHex = colorHex; + } + + public String getIconName() { + return iconName; + } + + public void setIconName(String iconName) { + this.iconName = iconName; + } +} \ No newline at end of file