-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 트래킹 안내난이도 후기 등록 추가 #122
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8a7e9ee
feat: 코스 난이도 피드백 도메인 추가
pooreumjung e7e0cbe
chore: 코스 난이도 피드백 테이블 마이그레이션 추가
pooreumjung f3d8f37
feat: 코스 난이도 피드백 저장 API 추가
pooreumjung 333121f
test: 코스 난이도 피드백 저장 검증 추가
pooreumjung 8d971b5
fix: 코스 난이도 피드백 중복 저장 예외 처리
pooreumjung 318da2e
fix: 자유 기록 등산 기록 목록 조회 누락 수정
pooreumjung 5d1f9b8
refactor: 코스 난이도 피드백 산 중복 저장 제거
pooreumjung ac62631
fix: 난이도 피드백 저장 검증 범위 보강
pooreumjung 98ead33
fix: 난이도 피드백 코스 필수 예외 통일
pooreumjung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
...java/com/semosan/api/domain/hiking/dto/request/CreateCourseDifficultyFeedbackRequest.java
This file contains hidden or 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,9 @@ | ||
| package com.semosan.api.domain.hiking.dto.request; | ||
|
|
||
| import com.semosan.api.domain.hiking.enums.DifficultyFeedbackType; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record CreateCourseDifficultyFeedbackRequest( | ||
| @NotNull DifficultyFeedbackType comparison | ||
| ) { | ||
| } |
30 changes: 30 additions & 0 deletions
30
...ain/java/com/semosan/api/domain/hiking/dto/response/CourseDifficultyFeedbackResponse.java
This file contains hidden or 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,30 @@ | ||
| package com.semosan.api.domain.hiking.dto.response; | ||
|
|
||
| import com.semosan.api.domain.hiking.entity.CourseDifficultyFeedback; | ||
| import com.semosan.api.domain.hiking.enums.DifficultyFeedbackType; | ||
| import com.semosan.api.domain.mountain.enums.Difficulty; | ||
|
|
||
| public record CourseDifficultyFeedbackResponse( | ||
| Long feedbackId, | ||
| Long hikingRecordId, | ||
| Long mountainId, | ||
| String mountainName, | ||
| Long courseId, | ||
| String courseName, | ||
| Difficulty guideDifficulty, | ||
| DifficultyFeedbackType comparison | ||
| ) { | ||
|
|
||
| public static CourseDifficultyFeedbackResponse from(CourseDifficultyFeedback feedback) { | ||
| return new CourseDifficultyFeedbackResponse( | ||
| feedback.getId(), | ||
| feedback.getHikingRecord().getId(), | ||
| feedback.getCourse().getMountain().getId(), | ||
| feedback.getCourse().getMountain().getName(), | ||
| feedback.getCourse().getId(), | ||
| feedback.getCourse().getName(), | ||
| feedback.getGuideDifficulty(), | ||
| feedback.getComparison() | ||
| ); | ||
| } | ||
| } |
74 changes: 74 additions & 0 deletions
74
src/main/java/com/semosan/api/domain/hiking/entity/CourseDifficultyFeedback.java
This file contains hidden or 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,74 @@ | ||
| package com.semosan.api.domain.hiking.entity; | ||
|
|
||
| import com.semosan.api.common.base.BaseEntity; | ||
| import com.semosan.api.common.exception.GeneralException; | ||
| import com.semosan.api.common.status.ErrorStatus; | ||
| import com.semosan.api.domain.hiking.enums.DifficultyFeedbackType; | ||
| import com.semosan.api.domain.mountain.entity.Course; | ||
| import com.semosan.api.domain.mountain.enums.Difficulty; | ||
| import com.semosan.api.domain.user.entity.User; | ||
| import jakarta.persistence.*; | ||
| import lombok.*; | ||
|
|
||
| @Table( | ||
| name = "course_difficulty_feedbacks", | ||
| uniqueConstraints = { | ||
| @UniqueConstraint( | ||
| name = "uk_course_difficulty_feedback_hiking_record", | ||
| columnNames = "hiking_record_id" | ||
| ) | ||
| }, | ||
| indexes = { | ||
| @Index(name = "idx_course_difficulty_feedback_course_id", columnList = "course_id"), | ||
| @Index(name = "idx_course_difficulty_feedback_user_id", columnList = "user_id") | ||
| } | ||
| ) | ||
| @Getter | ||
| @Entity | ||
| @Builder(access = AccessLevel.PROTECTED) | ||
| @AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class CourseDifficultyFeedback extends BaseEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @OneToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "hiking_record_id", nullable = false) | ||
| private HikingRecord hikingRecord; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "user_id", nullable = false) | ||
| private User user; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "course_id", nullable = false) | ||
| private Course course; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "guide_difficulty", nullable = false, length = 20) | ||
| private Difficulty guideDifficulty; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "comparison", nullable = false, length = 20) | ||
| private DifficultyFeedbackType comparison; | ||
|
|
||
| public static CourseDifficultyFeedback create( | ||
| HikingRecord hikingRecord, | ||
| User user, | ||
| DifficultyFeedbackType comparison | ||
| ) { | ||
| Course course = hikingRecord.getCourse(); | ||
| if (course == null) { | ||
| throw new GeneralException(ErrorStatus.HIKING_RECORD_COURSE_REQUIRED); | ||
| } | ||
| return CourseDifficultyFeedback.builder() | ||
| .hikingRecord(hikingRecord) | ||
| .user(user) | ||
| .course(course) | ||
| .guideDifficulty(course.getDifficulty()) | ||
| .comparison(comparison) | ||
| .build(); | ||
| } | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
src/main/java/com/semosan/api/domain/hiking/enums/DifficultyFeedbackType.java
This file contains hidden or 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,7 @@ | ||
| package com.semosan.api.domain.hiking.enums; | ||
|
|
||
| public enum DifficultyFeedbackType { | ||
| SIMILAR, | ||
| EASIER, | ||
| HARDER | ||
| } |
9 changes: 9 additions & 0 deletions
9
...ain/java/com/semosan/api/domain/hiking/repository/CourseDifficultyFeedbackRepository.java
This file contains hidden or 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,9 @@ | ||
| package com.semosan.api.domain.hiking.repository; | ||
|
|
||
| import com.semosan.api.domain.hiking.entity.CourseDifficultyFeedback; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface CourseDifficultyFeedbackRepository extends JpaRepository<CourseDifficultyFeedback, Long> { | ||
|
|
||
| boolean existsByHikingRecord_Id(Long hikingRecordId); | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.