-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: 미션, 미션 기록 도메인 생성 #60
Changes from 35 commits
e98faa9
7ecebce
8d496c3
5b56730
40f085d
d465407
8860817
b944071
6c47d4b
dfab6a7
c85648e
3d9e218
c2b070e
526c065
09f88b9
e863e07
72b68d0
0cc03e5
0a29dfb
3f9842f
42357f2
2e5eb11
05e4375
7241500
3a3a235
d2fad9e
49e9c32
a47fece
976d3db
c5354f9
bf1e020
a720e5d
88aeeb2
4f2f401
f0290d2
06247bc
432469a
32fc20b
f5ebc86
7e174c2
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,6 @@ | ||
package com.depromeet.domain.mission.dao; | ||
|
||
import com.depromeet.domain.mission.domain.Mission; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MissionRepository extends JpaRepository<Mission, Long> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.depromeet.domain.mission.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ArchiveStatus { | ||
NONE("미완료"), | ||
ARCHIVED("완료"); | ||
|
||
private final String value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.depromeet.domain.mission.domain; | ||
|
||
import com.depromeet.domain.common.model.BaseTimeEntity; | ||
import com.depromeet.domain.member.domain.Member; | ||
import com.depromeet.domain.missionRecord.domain.MissionRecord; | ||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
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.OneToMany; | ||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.Comment; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Mission extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "mission_id") | ||
private Long id; | ||
|
||
@Comment("미션 이름") | ||
@Column(nullable = false, length = 20) | ||
private String name; | ||
|
||
@Comment("미션 내용") | ||
@Column(columnDefinition = "text", nullable = false) | ||
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.
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. 아 기획방향 확정전에 남았던 코드네요 text 없이 수정해두겠습니다! |
||
private String content; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private MissionCategory category; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private MissionVisibility visibility; | ||
|
||
@Comment("미션 정렬값") | ||
@Column(name = "sort", nullable = false) | ||
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.
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. 넵넵 맞습니다 저번에 필드명을 order로 할까 했었다가 수정을 못했네요 저 부분도 수정해놓겠습니다! |
||
private Integer sort; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
private LocalDateTime startedAt; | ||
|
||
private LocalDateTime finishedAt; | ||
|
||
@Enumerated(EnumType.STRING) | ||
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. 엔티티 칼럼 순서도 맞춰주면 좋을 것 같습니다 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. ++ 생성자 파라미터에도 순서변경이 있으면 반영 부탁드립니다 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. @uwoobeat 엔티티 칼럼 순서는 어떤 기준인가용? 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. @uwoobeat |
||
private ArchiveStatus archiveStatus; | ||
|
||
@OneToMany(mappedBy = "mission", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private final List<MissionRecord> missionRecords = new ArrayList<>(); | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
private Mission( | ||
String name, | ||
String content, | ||
MissionCategory category, | ||
MissionVisibility visibility, | ||
Integer sort, | ||
LocalDateTime startedAt, | ||
LocalDateTime finishedAt, | ||
ArchiveStatus archiveStatus, | ||
Member member) { | ||
this.name = name; | ||
this.content = content; | ||
this.category = category; | ||
this.visibility = visibility; | ||
this.sort = sort; | ||
this.startedAt = startedAt; | ||
this.finishedAt = finishedAt; | ||
this.archiveStatus = archiveStatus; | ||
this.member = member; | ||
} | ||
|
||
public static Mission createMission( | ||
String name, | ||
String content, | ||
MissionCategory category, | ||
MissionVisibility visibility, | ||
Integer sort, | ||
LocalDateTime startedAt, | ||
LocalDateTime finishedAt, | ||
Member member) { | ||
return Mission.builder() | ||
.name(name) | ||
.content(content) | ||
.category(category) | ||
.visibility(visibility) | ||
.sort(sort) | ||
.member(member) | ||
.startedAt(startedAt) | ||
.finishedAt(finishedAt) | ||
.archiveStatus(ArchiveStatus.NONE) | ||
.build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.depromeet.domain.mission.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum MissionCategory { | ||
EXERCISE("운동"), | ||
STUDY("공부"), | ||
READING("글 읽기"), | ||
WRITING("글 쓰기"), | ||
WATCHING("영상 보기 / 팟캐스트 듣기"), | ||
ETC("기타"); | ||
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. 23.12.22 기준 카테고리 목록이 |
||
|
||
private final String value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.depromeet.domain.mission.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum MissionVisibility { | ||
ALL("전체 공개"), | ||
FOLLOWER("팔로워에게 공개"), | ||
NONE("비공개"); | ||
|
||
private final String value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.depromeet.domain.missionRecord.dao; | ||
|
||
import com.depromeet.domain.missionRecord.domain.MissionRecord; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MissionRecordRepository extends JpaRepository<MissionRecord, Long> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.depromeet.domain.missionRecord.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ImageUploadStatus { | ||
NONE("업로드 없음"), | ||
PENDING("업로드 중"), | ||
COMPLETE("업로드 완료"); | ||
|
||
private final String value; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.depromeet.domain.missionRecord.domain; | ||
|
||
import com.depromeet.domain.common.model.BaseTimeEntity; | ||
import com.depromeet.domain.mission.domain.Mission; | ||
import jakarta.persistence.Column; | ||
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 java.time.LocalDateTime; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.Comment; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class MissionRecord extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "mission_record_id") | ||
private Long id; | ||
|
||
private Integer duration; | ||
|
||
@Comment("미션 일지") | ||
private String remark; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ImageUploadStatus uploadStatus; | ||
|
||
@Comment("인증 사진") | ||
@Column(nullable = false) | ||
private String imageUrl; | ||
|
||
private LocalDateTime startedAt; | ||
|
||
private LocalDateTime finishedAt; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "mission_id") | ||
private Mission mission; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
private MissionRecord( | ||
Integer duration, | ||
String remark, | ||
ImageUploadStatus uploadStatus, | ||
String imageUrl, | ||
LocalDateTime startedAt, | ||
LocalDateTime finishedAt, | ||
Mission mission) { | ||
this.duration = duration; | ||
this.remark = remark; | ||
this.uploadStatus = uploadStatus; | ||
this.imageUrl = imageUrl; | ||
this.startedAt = startedAt; | ||
this.finishedAt = finishedAt; | ||
this.mission = mission; | ||
} | ||
|
||
public static MissionRecord createMissionRecord( | ||
Integer duration, | ||
String remark, | ||
LocalDateTime startedAt, | ||
LocalDateTime finishedAt, | ||
String imageUrl, | ||
Mission mission) { | ||
return MissionRecord.builder() | ||
.duration(duration) | ||
.remark(remark) | ||
.uploadStatus(ImageUploadStatus.NONE) | ||
.startedAt(startedAt) | ||
.finishedAt(finishedAt) | ||
.imageUrl(imageUrl) | ||
.mission(mission) | ||
.build(); | ||
} | ||
} |
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.
final이 왜 들어가야하는지 궁금합니다 !
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.
final은 회원별 미션에 대해서 가변성을 막기 위해 추가했습니다
혹시나 mission에 대한 수정 이력이 발생하지 않도록 했었습니다!
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.
아 final을 추가함으로서 단점도 알아봤는데 lazy loading 이슈가 존재할 수도 있다네요
final은 빼도록 하겠습니다!