-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 투표 API 기초 엔티티 세팅 #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2f64b33
989eb32
805f0be
4842abd
eaadfbc
ffc3ad3
8ac9fd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.debatetimer.domain.poll; | ||
|
|
||
| public enum PollStatus { | ||
|
|
||
| PROGRESS, | ||
| DONE, | ||
| ; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.debatetimer.domain.poll; | ||
|
|
||
| public enum VoteTeam { | ||
|
|
||
| PROS, | ||
| CONS, | ||
| ; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.debatetimer.entity.poll; | ||
|
|
||
| import com.debatetimer.domain.poll.PollStatus; | ||
| import com.debatetimer.entity.customize.BaseTimeEntity; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Table(name = "poll") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class PollEntity extends BaseTimeEntity { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이럴꺼면 CustomizeTimeBox에도 Entity 붙여주세요
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @unifolio0 이건 다음에 작업하는 사람이 하는 걸로 합시다. 일단은 "투표 API 관련 엔티티"만 보는 건 어떨까요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CustomizeTimeBox에도 도메인 -엔티티 분리 작업 리팩터링하면서 Entity suffix 붙을 것 같아요. |
||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| private long tableId; | ||
coli-geonwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @NotNull | ||
| @Enumerated(EnumType.STRING) | ||
| private PollStatus status; | ||
|
|
||
| @NotBlank | ||
| private String prosTeamName; | ||
|
|
||
| @NotBlank | ||
| private String consTeamName; | ||
|
Comment on lines
+32
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CustomizeTable에서 검증했기 때문에 여기선 검증하지 않는 건가요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네, 그렇게 판단한 이유는 다음과 같아요. 일단, 최대한 도메인 검증에 대한 책임은 Entity 단에서 수행하지 않는 것을 지향합니다. 선거 엔티티가 각 팀 이름을 검증하는 것이 어색하게 느껴졌습니다. 만약 팀이름에 대한 검증로직이 해당 엔티티에 추가되면 중복 검증이 되어 관리포인트가 2가지로 생깁니다. 따라서 생성 루트 일원화를 통해 관리하는 것이 바람직하다고 판단했습니다. |
||
|
|
||
| private String agenda; | ||
| } | ||
coli-geonwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.debatetimer.entity.poll; | ||
|
|
||
| import com.debatetimer.domain.poll.VoteTeam; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Table(name = "vote") | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class VoteEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @NotNull | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "poll_id") | ||
| private PollEntity poll; | ||
|
|
||
| @NotNull | ||
| @Enumerated(EnumType.STRING) | ||
| private VoteTeam team; | ||
coli-geonwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @NotBlank | ||
| private String name; | ||
|
|
||
| @NotBlank | ||
| private String participantCode; | ||
| } | ||
coli-geonwoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| CREATE TABLE poll | ||
| ( | ||
| id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
| table_id BIGINT NOT NULL, | ||
| status ENUM ('PROGRESS','DONE') NOT NULL, | ||
| pros_team_name VARCHAR(255) NOT NULL, | ||
| cons_team_name VARCHAR(255) NOT NULL, | ||
| agenda VARCHAR(255) NOT NULL, | ||
| created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| modified_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | ||
| ); | ||
|
|
||
| CREATE TABLE vote | ||
| ( | ||
| id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
| poll_id BIGINT NOT NULL, | ||
| team ENUM ('CONS','PROS') NOT NULL, | ||
| name VARCHAR(255) NOT NULL, | ||
| participant_code VARCHAR(255) NOT NULL | ||
| ); | ||
|
|
||
| alter table vote | ||
| add constraint vote_to_poll | ||
| foreign key (poll_id) | ||
| references poll (id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
도메인 없이 일단 엔티티만 사용하는 건가요? 아니면 도메인은 다음 작업에서 구현하시는 건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[의견 🔈 ]
투표 API는 기존 도메인과 분리된 부분이기 때문에 영향 줄 부분이 크게 없다고 생각되어 API 뽑으면서 도메인까지 붙이겠습니다.