-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from mju-likelion/feature/refactor-calculate-u…
…ser-grade-#71 Feature/#71 설문조사 응답을 이용한 유저 등급 계산 로직 리팩토링
- Loading branch information
Showing
10 changed files
with
51 additions
and
34 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
...u/repository/CustomPlannerRepository.java → ...tory/planner/CustomPlannerRepository.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
3 changes: 1 addition & 2 deletions
3
...pository/CustomPlannerRepositoryImpl.java → .../planner/CustomPlannerRepositoryImpl.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
2 changes: 1 addition & 1 deletion
2
...out_mju/repository/PlannerRepository.java → ...repository/planner/PlannerRepository.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
7 changes: 7 additions & 0 deletions
7
...ain/java/com/example/mutsideout_mju/repository/usersurvey/CustomUserSurveyRepository.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,7 @@ | ||
package com.example.mutsideout_mju.repository.usersurvey; | ||
|
||
import java.util.UUID; | ||
|
||
public interface CustomUserSurveyRepository { | ||
long countValidSurveyResponse(UUID userId); | ||
} |
31 changes: 31 additions & 0 deletions
31
...java/com/example/mutsideout_mju/repository/usersurvey/CustomUserSurveyRepositoryImpl.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,31 @@ | ||
package com.example.mutsideout_mju.repository.usersurvey; | ||
|
||
|
||
import com.example.mutsideout_mju.entity.SurveyOption; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
|
||
import java.util.UUID; | ||
|
||
import static com.example.mutsideout_mju.entity.QUserSurvey.userSurvey; | ||
|
||
public class CustomUserSurveyRepositoryImpl implements CustomUserSurveyRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public CustomUserSurveyRepositoryImpl(EntityManager entityManager) { | ||
this.queryFactory = new JPAQueryFactory(entityManager); | ||
} | ||
|
||
@Override | ||
public long countValidSurveyResponse(UUID userId) { | ||
return queryFactory | ||
.selectFrom(userSurvey) | ||
.where(userSurvey.user.id.eq(userId), | ||
userSurvey.survey.number.between(1, 3) | ||
.and(userSurvey.surveyOption.in(SurveyOption.NORMAL, SurveyOption.YES)) | ||
.or(userSurvey.survey.number.between(4, 6) | ||
.and(userSurvey.surveyOption.eq(SurveyOption.YES)))) | ||
.fetchCount(); | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
..._mju/repository/UserSurveyRepository.java → ...tory/usersurvey/UserSurveyRepository.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,14 +1,13 @@ | ||
package com.example.mutsideout_mju.repository; | ||
package com.example.mutsideout_mju.repository.usersurvey; | ||
|
||
import com.example.mutsideout_mju.entity.UserSurvey; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
public interface UserSurveyRepository extends JpaRepository<UserSurvey, UUID> { | ||
public interface UserSurveyRepository extends JpaRepository<UserSurvey, UUID>, CustomUserSurveyRepository { | ||
List<UserSurvey> findByUserId(UUID userId); | ||
|
||
boolean existsByUserId(UUID userId); | ||
List<UserSurvey> findByUserIdAndSurveyIdIn(UUID userId, List<UUID> surveyIds); | ||
} |
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
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
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