-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: UMC 5주차 누락된 코드 복원 및 수정사항 반영 #3
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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/example/UMC/domain/enums/entity/MissionStatus.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/example/UMC/domain/likes/entity/LikeCategory.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
4 changes: 2 additions & 2 deletions
4
src/main/java/com/example/UMC/domain/likes/entity/UserLikeFood.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
6 changes: 3 additions & 3 deletions
6
src/main/java/com/example/UMC/domain/mission/entity/Mission.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
8 changes: 4 additions & 4 deletions
8
src/main/java/com/example/UMC/domain/mission/entity/UserMission.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
26 changes: 25 additions & 1 deletion
26
src/main/java/com/example/UMC/domain/mission/repository/MissionRepository.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 |
|---|---|---|
| @@ -1,2 +1,26 @@ | ||
| package com.example.UMC.domain.mission.repository;public interface MissionRepository { | ||
| package com.example.UMC.domain.mission.repository; | ||
|
|
||
| import com.example.UMC.domain.mission.entity.Mission; | ||
| import com.example.UMC.domain.store.entity.Region; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface MissionRepository extends JpaRepository<Mission, Long> { | ||
|
|
||
| /** | ||
| * 4. 홈 화면용 미션 목록 조회 | ||
| * - 현재 지역(region)에서 도전 가능한 미션 | ||
| * - 페이징 포함 | ||
| */ | ||
| @Query(""" | ||
| SELECT m | ||
| FROM Mission m | ||
| JOIN FETCH m.store s | ||
| WHERE s.region = :region | ||
| ORDER BY m.endsAt ASC | ||
| """) | ||
| Page<Mission> findAllByRegion(@Param("region") Region region, Pageable pageable); | ||
| } |
29 changes: 28 additions & 1 deletion
29
src/main/java/com/example/UMC/domain/mission/repository/UserMissionRepository.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 |
|---|---|---|
| @@ -1,2 +1,29 @@ | ||
| package com.example.UMC.domain.mission.repository;public interface UserMissionRepository { | ||
| package com.example.UMC.domain.mission.repository; | ||
|
|
||
|
|
||
| import com.example.UMC.domain.mission.entity.UserMission; | ||
| import com.example.UMC.domain.user.entity.User; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface UserMissionRepository extends JpaRepository<UserMission, Long> { | ||
|
|
||
| /** | ||
| * 3. 내 미션 목록 조회 (진행 중 / 완료 포함) | ||
| * - 페이징 지원 | ||
| * - User 기준 | ||
| */ | ||
| @Query(""" | ||
| SELECT um | ||
| FROM UserMission um | ||
| JOIN FETCH um.mission m | ||
| JOIN FETCH m.store s | ||
| WHERE um.user = :user | ||
| ORDER BY um.completeAt DESC | ||
| """) | ||
| Page<UserMission> findAllByUser(@Param("user") User user, Pageable pageable); | ||
| } | ||
|
|
6 changes: 3 additions & 3 deletions
6
src/main/java/com/example/UMC/domain/notification/entity/Notification.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
10 changes: 5 additions & 5 deletions
10
src/main/java/com/example/UMC/domain/review/entity/Review.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
5 changes: 2 additions & 3 deletions
5
src/main/java/com/example/UMC/domain/review/entity/ReviewImage.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
6 changes: 3 additions & 3 deletions
6
src/main/java/com/example/UMC/domain/review/entity/ReviewReply.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
22 changes: 21 additions & 1 deletion
22
src/main/java/com/example/UMC/domain/review/repository/ReviewRepository.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 |
|---|---|---|
| @@ -1,2 +1,22 @@ | ||
| package com.example.UMC.domain.review.repository;public class ReviewRepository { | ||
| package com.example.UMC.domain.review.repository; | ||
|
|
||
| import com.example.UMC.domain.review.entity.Review; | ||
| import com.example.UMC.domain.store.entity.Store; | ||
| import org.springframework.data.jpa.repository.EntityGraph; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface ReviewRepository extends JpaRepository<Review, Long> { | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * 1. 리뷰 조회 | ||
| * 특정 가게(store)의 리뷰를 최신순으로 조회 | ||
| * (작성자(User) 엔티티까지 한 번에 가져오기) | ||
| */ | ||
| @EntityGraph(attributePaths = {"user"}) // Review의 user 필드 fetch join | ||
| List<Review> findAllByStoreOrderByCreatedAtDesc(Store store); | ||
|
|
||
| } | ||
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
4 changes: 2 additions & 2 deletions
4
src/main/java/com/example/UMC/domain/user/entity/Agreement.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
19 changes: 10 additions & 9 deletions
19
src/main/java/com/example/UMC/domain/user/entity/User.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
33 changes: 32 additions & 1 deletion
33
src/main/java/com/example/UMC/domain/user/repository/DashboardRepository.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 |
|---|---|---|
| @@ -1,2 +1,33 @@ | ||
| package com.example.UMC.domain.user.repository;public interface HomeDashboardRepository { | ||
| package com.example.UMC.domain.user.repository; | ||
|
|
||
| import com.example.UMC.domain.user.entity.User; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import org.springframework.data.jpa.repository.Query; | ||
| import org.springframework.data.repository.query.Param; | ||
|
|
||
| public interface DashboardRepository extends JpaRepository<User, Long> { | ||
|
|
||
| /** | ||
| * 4. 홈화면 대시보드 조회 | ||
| * - 최근 리뷰한 가게 지역 + 포인트 + 알람 여부 + 완료 미션 수 | ||
| */ | ||
| @Query(""" | ||
|
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. 해당 부분 서브쿼리가 아닌 조인으로도 구현 가능할 것 같습니다. |
||
| SELECT | ||
| s.region.name, | ||
| u.point, | ||
| CASE WHEN EXISTS ( | ||
| SELECT n FROM Notification n | ||
| WHERE n.user = u AND n.isRead = false | ||
| ) THEN true ELSE false END AS alram, | ||
| (SELECT COUNT(um) | ||
| FROM UserMission um | ||
| WHERE um.user = u | ||
| AND um.status = com.example.UMC.domain.enums.entity.MissionStatus.COMPLETE) | ||
| FROM User u | ||
| JOIN Review r ON r.user = u | ||
| JOIN Store s ON r.store = s | ||
| WHERE u.id = :userId | ||
| ORDER BY r.createdAt DESC | ||
| """) | ||
| Object findDashboardInfo(@Param("userId") Long userId); | ||
| } | ||
22 changes: 21 additions & 1 deletion
22
src/main/java/com/example/UMC/domain/user/repository/UserRepository.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 |
|---|---|---|
| @@ -1,2 +1,22 @@ | ||
| package com.example.UMC.domain.user.repository;public interface UserRepository { | ||
| package com.example.UMC.domain.user.repository; | ||
|
|
||
|
|
||
| import com.example.UMC.domain.user.entity.User; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| public interface UserRepository extends JpaRepository<User, Long> { | ||
|
|
||
| /** | ||
| * 2.마이페이지 조회용 — user_id로 단일 유저 조회 | ||
| * (CASE, JOIN 없이 단순 조회만) | ||
| */ | ||
| Optional<User> findById(Long userId); | ||
|
|
||
| // 기준으로 조회 (로그인/마이페이지 공용으로 활용 가능) | ||
| Optional<User> findByEmail(String email); | ||
|
|
||
| // 이름 + 이메일 같이 조건 조회 (확장형) | ||
| Optional<User> findByNameAndEmail(String name, String email); | ||
| } |
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
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.
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.
fetch join하는 jpql query를 직접 작성해보면 좋을 것 같습니다