-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
32 changed files
with
571 additions
and
31 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/sopt/org/motivooServer/domain/common/BaseTimeEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package sopt.org.motivooServer.domain.common; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public abstract class BaseTimeEntity { | ||
|
||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseFrequency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package sopt.org.motivooServer.domain.health.entity; | ||
|
||
public enum ExerciseFrequency { | ||
|
||
// 1회 미만 | 1~2회 | 3~4회 | 5회 이상 | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseTime.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package sopt.org.motivooServer.domain.health.entity; | ||
|
||
public enum ExerciseTime { | ||
|
||
// 30분 미만 | 30분~1시간 | 1시간~2시간 | 2시간 이상 | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package sopt.org.motivooServer.domain.health.entity; | ||
|
||
public enum ExerciseType { | ||
|
||
// 고강도 | 중강도 | 저강도 | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package sopt.org.motivooServer.domain.health.entity; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.ElementCollection; | ||
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.JoinColumn; | ||
import jakarta.persistence.OneToOne; | ||
import sopt.org.motivooServer.domain.common.BaseTimeEntity; | ||
import sopt.org.motivooServer.domain.user.entity.User; | ||
|
||
@Entity | ||
public class Health extends BaseTimeEntity { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "health_id") | ||
private Long id; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@Column(nullable = false) | ||
private Boolean isExercise; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private ExerciseType exerciseType; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private ExerciseFrequency exerciseFrequency; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private ExerciseTime exerciseTime; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
@ElementCollection | ||
private List<HealthNote> healthNotes = new ArrayList<>(); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/sopt/org/motivooServer/domain/health/entity/HealthNote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package sopt.org.motivooServer.domain.health.entity; | ||
|
||
import static sopt.org.motivooServer.domain.health.exception.HealthExceptionType.*; | ||
|
||
import java.util.Arrays; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import sopt.org.motivooServer.domain.health.exception.HealthException; | ||
|
||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public enum HealthNote { | ||
|
||
WAIST("허리"), | ||
KNEE("무릎"), | ||
NECK("목"), | ||
WRIST("손목"), | ||
SHOULDER("어깨"), | ||
ANKLE("발목"); | ||
|
||
private final String value; | ||
|
||
public static HealthNote of(String value) { | ||
return Arrays.stream(HealthNote.values()) | ||
.filter(healthNote -> value.equals(healthNote.value)) | ||
.findFirst() | ||
.orElseThrow(() -> new HealthException(INVALID_HEALTH_NOTE)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/sopt/org/motivooServer/domain/health/exception/HealthException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sopt.org.motivooServer.domain.health.exception; | ||
|
||
import sopt.org.motivooServer.global.advice.BusinessException; | ||
import sopt.org.motivooServer.global.advice.BusinessExceptionType; | ||
|
||
public class HealthException extends BusinessException { | ||
|
||
public HealthException(BusinessExceptionType exceptionType) { | ||
super(exceptionType); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/sopt/org/motivooServer/domain/health/exception/HealthExceptionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package sopt.org.motivooServer.domain.health.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import sopt.org.motivooServer.global.advice.BusinessExceptionType; | ||
|
||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public enum HealthExceptionType implements BusinessExceptionType { | ||
|
||
/** | ||
* 400 Bad Request | ||
*/ | ||
INVALID_HEALTH_NOTE(HttpStatus.BAD_REQUEST, "유효하지 않는 건강 주의사항입니다."), | ||
|
||
/** | ||
* 404 Not Found | ||
*/ | ||
HEALTH_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 건강정보입니다.") | ||
|
||
|
||
; | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public HttpStatus status() { | ||
return this.status; | ||
} | ||
|
||
@Override | ||
public String message() { | ||
return this.message; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/sopt/org/motivooServer/domain/mission/entity/CompletedStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package sopt.org.motivooServer.domain.mission.entity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public enum CompletedStatus { | ||
|
||
SUCCESS("성공"), | ||
FAIL("실패"), | ||
IN_PROGRESS("진행중"); | ||
|
||
private final String value; | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/sopt/org/motivooServer/domain/mission/entity/Mission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package sopt.org.motivooServer.domain.mission.entity; | ||
|
||
import jakarta.persistence.Column; | ||
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 sopt.org.motivooServer.domain.common.BaseTimeEntity; | ||
|
||
@Entity | ||
public class Mission extends BaseTimeEntity { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "mission_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String content; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private MissionType type; | ||
|
||
@Column(columnDefinition = "TEXT") | ||
private String descriptionUrl; | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/sopt/org/motivooServer/domain/mission/entity/MissionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package sopt.org.motivooServer.domain.mission.entity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public enum MissionType { | ||
|
||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package sopt.org.motivooServer.domain.mission.entity; | ||
|
||
import jakarta.persistence.Column; | ||
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.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToOne; | ||
import lombok.Getter; | ||
import sopt.org.motivooServer.domain.common.BaseTimeEntity; | ||
import sopt.org.motivooServer.domain.user.entity.User; | ||
|
||
@Getter | ||
@Entity | ||
public class UserMission extends BaseTimeEntity { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "user_mission_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Double completedRate; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Column(nullable = false) | ||
private CompletedStatus completedStatus; | ||
|
||
@Column(columnDefinition = "TEXT") | ||
private String imgUrl; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "mission_id", nullable = false) | ||
private Mission mission; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
//== 연관관계 메서드 ==// | ||
public void setUser(User user) { | ||
this.user = user; | ||
|
||
if (!user.getUserMissions().contains(this)) { | ||
user.getUserMissions().add(this); | ||
} | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package sopt.org.motivooServer.domain.mission.exception; | ||
|
||
import sopt.org.motivooServer.global.advice.ErrorType; | ||
import sopt.org.motivooServer.global.advice.BusinessException; | ||
import sopt.org.motivooServer.global.advice.BusinessExceptionType; | ||
|
||
public class MissionException extends BusinessException { | ||
|
||
public MissionException(ErrorType errorType) { | ||
super(errorType); | ||
public MissionException(BusinessExceptionType exceptionType) { | ||
super(exceptionType); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/sopt/org/motivooServer/domain/parentchild/entity/Parentchild.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package sopt.org.motivooServer.domain.parentchild.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import sopt.org.motivooServer.domain.common.BaseTimeEntity; | ||
|
||
@Entity | ||
public class Parentchild extends BaseTimeEntity { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "parentchild_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Boolean isMatched; | ||
|
||
@Column(nullable = false) | ||
private String inviteCode; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sopt.org.motivooServer.domain.parentchild.exception; | ||
|
||
import sopt.org.motivooServer.global.advice.BusinessException; | ||
import sopt.org.motivooServer.global.advice.BusinessExceptionType; | ||
|
||
public class ParentchildException extends BusinessException { | ||
|
||
public ParentchildException(BusinessExceptionType exceptionType) { | ||
super(exceptionType); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...in/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildExceptionType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package sopt.org.motivooServer.domain.parentchild.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import sopt.org.motivooServer.global.advice.BusinessExceptionType; | ||
|
||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) | ||
public enum ParentchildExceptionType implements BusinessExceptionType { | ||
|
||
/** | ||
* 404 Not Found | ||
*/ | ||
PARENTCHILD_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 부모-자녀 관계입니다.") | ||
|
||
|
||
; | ||
|
||
private final HttpStatus status; | ||
private final String message; | ||
|
||
@Override | ||
public HttpStatus status() { | ||
return this.status; | ||
} | ||
|
||
@Override | ||
public String message() { | ||
return this.message; | ||
} | ||
} |
Oops, something went wrong.