Skip to content
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

Merged
merged 40 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e98faa9
feat: mission domain 추가
char-yb Dec 12, 2023
7ecebce
feat: mission repository 추가 및 spotless 적용
char-yb Dec 12, 2023
8d496c3
feat: missionRecord domain 추가
char-yb Dec 12, 2023
5b56730
feat: mission DomainTest 작성
char-yb Dec 12, 2023
40f085d
fix: Mission DomainTest 수정
char-yb Dec 12, 2023
d465407
fix: Comment Annotation 활용 및 Spotless Apply
char-yb Dec 13, 2023
8860817
fix: Spotless Apply
char-yb Dec 13, 2023
b944071
fix: sonar --no-daemon test
char-yb Dec 13, 2023
6c47d4b
Merge branch 'develop' into feature/54-mission-domain
char-yb Dec 14, 2023
dfab6a7
fix: mission 도메인 수정 반영
char-yb Dec 14, 2023
c85648e
fix: spotlessApply
char-yb Dec 14, 2023
3d9e218
feat: MissionVisibility 값 추가
char-yb Dec 17, 2023
c2b070e
fix: spotlessApply
char-yb Dec 17, 2023
526c065
fix: 도메인 테스트 MissionVisibility 수정
char-yb Dec 17, 2023
09f88b9
feat: Mission Sort 값 파라미터 전달로 수정
char-yb Dec 18, 2023
e863e07
feat: Mission Sort 값 파라미터 전달로 수정
char-yb Dec 18, 2023
72b68d0
fix: spotlessApply
char-yb Dec 18, 2023
0cc03e5
feat: service gitkeep
char-yb Dec 18, 2023
0a29dfb
feat: sonar New Code Test
char-yb Dec 18, 2023
3f9842f
feat: sonar New Code Test
char-yb Dec 18, 2023
42357f2
feat: sonar New Code Test
char-yb Dec 18, 2023
2e5eb11
feat: sonar New Code Test
char-yb Dec 18, 2023
05e4375
feat: sonar BuildDir test
char-yb Dec 18, 2023
7241500
fix: set_pending 주석
char-yb Dec 18, 2023
3a3a235
fix: set_pending 주석 해제
char-yb Dec 18, 2023
d2fad9e
fix: sonar down
char-yb Dec 18, 2023
49e9c32
fix: sonar up
char-yb Dec 18, 2023
a47fece
fix: sonar down
char-yb Dec 18, 2023
976d3db
fix: sonar up
char-yb Dec 18, 2023
c5354f9
fix: set-pending test
char-yb Dec 19, 2023
bf1e020
feat: mission Domain 추가 사항 적용
char-yb Dec 20, 2023
a720e5d
feat: 미션, 미션 기록 수정사항 반영
char-yb Dec 21, 2023
88aeeb2
feat: 미션, 미션 기록 column 수정
char-yb Dec 21, 2023
4f2f401
fix: spotlessApply
char-yb Dec 21, 2023
f0290d2
develop merge
char-yb Dec 22, 2023
06247bc
fix: mission 도메인 column 수정 반영
char-yb Dec 22, 2023
432469a
fix: spotlessApply
char-yb Dec 22, 2023
32fc20b
fix: mission 도메인 column 수정 반영
char-yb Dec 22, 2023
f5ebc86
fix: 엔티티 column 순서 변경
char-yb Dec 22, 2023
7e174c2
fix: mission content nullable true
char-yb Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/develop_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Java
uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ sonar {
property 'sonar.sources', 'src'
property 'sonar.language', 'java'
property 'sonar.sourceEncoding', 'UTF-8'
property 'sonar.test.exclusions', jacocoExcludePatterns.join(',')
property 'sonar.exclusions', jacocoExcludePatterns.join(',')
property 'sonar.test.inclusions', '**/*Test.java'
property 'sonar.java.coveragePlugin', 'jacoco'
property 'sonar.coverage.jacoco.xmlReportPaths', jacocoDir.get().file("jacoco/index.xml").asFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.depromeet.domain.member.domain;

import com.depromeet.domain.common.model.BaseTimeEntity;
import com.depromeet.domain.mission.domain.Mission;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Embedded;
import jakarta.persistence.Entity;
Expand All @@ -9,7 +11,10 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
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;
Expand Down Expand Up @@ -38,6 +43,9 @@ public class Member extends BaseTimeEntity {

private LocalDateTime lastLoginAt;

@OneToMany(mappedBy = "member", cascade = CascadeType.ALL)
private final List<Mission> missions = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final이 왜 들어가야하는지 궁금합니다 !

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final은 회원별 미션에 대해서 가변성을 막기 위해 추가했습니다
혹시나 mission에 대한 수정 이력이 발생하지 않도록 했었습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 final을 추가함으로서 단점도 알아봤는데 lazy loading 이슈가 존재할 수도 있다네요
final은 빼도록 하겠습니다!


@Builder(access = AccessLevel.PRIVATE)
private Member(
Profile profile,
Expand Down
Empty file.
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;
}
112 changes: 112 additions & 0 deletions src/main/java/com/depromeet/domain/mission/domain/Mission.java
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columnDefinition = "text"이 왜 필요한지 설명해주실 수 있나용 ??

Copy link
Member Author

Choose a reason for hiding this comment

The 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name = "sort"값을 지정안해주어도 필드명에 따라 자동으로 sort로 들어가지 않나요??

Copy link
Member Author

Choose a reason for hiding this comment

The 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엔티티 칼럼 순서도 맞춰주면 좋을 것 같습니다
pk -> 일반 컬럼 -> enum -> 일대다/다대일

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ 생성자 파라미터에도 순서변경이 있으면 반영 부탁드립니다

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uwoobeat 엔티티 칼럼 순서는 어떤 기준인가용?
따로 가이드가 있나 해서 여쭤봅니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uwoobeat
pk -> 일반 컬럼 -> enum -> 시간(localDateTime) 컬럼 -> 일대다/다대일 컬럼 이렇게 진행해도 될까요??

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("기타");
Copy link
Member

Choose a reason for hiding this comment

The 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;
}
Empty file.
Empty file.
Empty file.
Empty file.
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();
}
}
Empty file.
Empty file.
Empty file.
Loading