-
Notifications
You must be signed in to change notification settings - Fork 1
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 #28 from TravelMate-KU/feat/matching
feat: matching 결과 조회 API 구현
- Loading branch information
Showing
19 changed files
with
601 additions
and
46 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
37 changes: 37 additions & 0 deletions
37
src/main/java/konkuk/travelmate/controller/MatchingController.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 konkuk.travelmate.controller; | ||
|
||
import konkuk.travelmate.form.response.VolunteerMatchingResponse; | ||
import konkuk.travelmate.service.MatchingService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.security.oauth2.core.user.OAuth2User; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
@Slf4j | ||
@Controller | ||
@RequestMapping("/matchings") | ||
@RequiredArgsConstructor | ||
public class MatchingController { | ||
|
||
private final MatchingService matchingService; | ||
|
||
@GetMapping | ||
private String showMatchResults(@AuthenticationPrincipal OAuth2User user, Model model) { | ||
|
||
log.info("[MatchingController.showMatchResults]"); | ||
String email = Objects.requireNonNull(user.getAttribute("email")).toString(); | ||
List<VolunteerMatchingResponse> matchings = matchingService.getMatchResults(email); | ||
model.addAttribute("matchings", matchings); | ||
|
||
return "volunteer_matching_result"; | ||
} | ||
|
||
|
||
} |
14 changes: 0 additions & 14 deletions
14
src/main/java/konkuk/travelmate/controller/TestController.java
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/java/konkuk/travelmate/controller/UserController.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
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
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
10 changes: 10 additions & 0 deletions
10
src/main/java/konkuk/travelmate/form/response/VolunteerMatchingResponse.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 konkuk.travelmate.form.response; | ||
|
||
import konkuk.travelmate.domain.RequestState; | ||
import konkuk.travelmate.domain.TravelType; | ||
|
||
import java.sql.Timestamp; | ||
|
||
public record VolunteerMatchingResponse(String disabledName, Timestamp startTime, Timestamp endTime, TravelType type, | ||
RequestState state, String disabledPhoneName, String disabledEmail) { | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/konkuk/travelmate/repository/MatchingRepository.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,7 +1,22 @@ | ||
package konkuk.travelmate.repository; | ||
|
||
import konkuk.travelmate.domain.Matching; | ||
import konkuk.travelmate.form.response.VolunteerMatchingResponse; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static javax.management.Query.in; | ||
|
||
public interface MatchingRepository extends JpaRepository<Matching, Long> { | ||
@Query("SELECT new konkuk.travelmate.form.response.VolunteerMatchingResponse(d.name, r.startTime, r.endTime, r.type, r.state, d.phoneNum, d.email) " + | ||
"FROM Request r JOIN r.disabled d " + | ||
"WHERE d.role = 0 AND r.requestId IN ( " + | ||
"SELECT m.request.requestId " + | ||
"FROM Matching m JOIN m.volunteer v " + | ||
"WHERE v.email = :email)") | ||
List<VolunteerMatchingResponse> findVolunteerMatchingResultsByEmail(@Param("email") String email); | ||
} |
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,15 +1,22 @@ | ||
package konkuk.travelmate.service; | ||
|
||
import konkuk.travelmate.form.response.VolunteerMatchingResponse; | ||
import konkuk.travelmate.repository.MatchingRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class MatchingService { | ||
|
||
private final MatchingRepository matchingRepository; | ||
|
||
public List<VolunteerMatchingResponse> getMatchResults(String email) { | ||
log.info("[MatchingService.getMatchResults]"); | ||
return matchingRepository.findVolunteerMatchingResultsByEmail(email); | ||
} | ||
} |
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
Oops, something went wrong.