-
Notifications
You must be signed in to change notification settings - Fork 0
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
[SKRB-165] feat: 일반 사용자가 행사 참여 신청 현황 확인 기능을 위한 DTO 생성 #17
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e02aa32
feat: Event 도메인 수정
juno-junho 602be30
feat: 일반 사용자가 신청한 행사 현황 확인 dto 생성
juno-junho d6a0baf
feat: user controller 및 mock User service 생성
juno-junho 88912a3
chore: 공백 라인 제거
juno-junho f4f2133
fix: 불필요한 sort 정보 제거
juno-junho 39dbfa4
chore: endpoint 누락 값 추가
juno-junho 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 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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/spaceclub/user/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.spaceclub.user.controller; | ||
|
||
import com.spaceclub.event.domain.Event; | ||
import com.spaceclub.user.controller.dto.EventPageResponse; | ||
import com.spaceclub.user.controller.dto.EventResponse; | ||
import com.spaceclub.user.service.UserService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/api/users") | ||
@RequiredArgsConstructor | ||
public class UserController { | ||
|
||
private final UserService userService; | ||
|
||
@GetMapping("/{userId}/events") | ||
public EventPageResponse<EventResponse, Event> getAllEvents(@PathVariable Long userId, Pageable pageable) { | ||
Page<Event> eventPages = userService.findAllEventPages(userId, pageable); | ||
List<EventResponse> eventResponses = eventPages.getContent() | ||
.stream() | ||
.map(EventResponse::from) | ||
.toList(); | ||
|
||
return new EventPageResponse<>(eventResponses, eventPages); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/spaceclub/user/controller/dto/EventPageResponse.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,38 @@ | ||
package com.spaceclub.user.controller.dto; | ||
|
||
import org.springframework.data.domain.Page; | ||
|
||
import java.util.List; | ||
|
||
public record EventPageResponse<T, E>( | ||
List<T> data, | ||
PageableResponse<E> pageData | ||
) { | ||
|
||
public EventPageResponse(List<T> data, Page<E> page) { | ||
this(data, new PageableResponse<>(page)); | ||
} | ||
|
||
private record PageableResponse<E>( | ||
boolean first, | ||
boolean last, | ||
int pageNumber, | ||
int size, | ||
int totalPages, | ||
long totalElements | ||
) { | ||
|
||
public PageableResponse(Page<E> page) { | ||
this( | ||
page.isFirst(), | ||
page.isLast(), | ||
page.getNumber(), | ||
page.getSize(), | ||
page.getTotalPages(), | ||
page.getTotalElements() | ||
); | ||
} | ||
|
||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/spaceclub/user/controller/dto/EventResponse.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 com.spaceclub.user.controller.dto; | ||
|
||
import com.spaceclub.event.domain.Event; | ||
|
||
public record EventResponse(Long id, String title, String location, String host) { | ||
|
||
public static EventResponse from(Event event) { | ||
return new EventResponse( | ||
event.getId(), | ||
event.getEventInfo().getTitle(), | ||
event.getEventInfo().getLocation(), | ||
event.getClubHost() | ||
); | ||
} | ||
|
||
} |
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,13 @@ | ||
package com.spaceclub.user.service; | ||
|
||
import com.spaceclub.event.domain.Event; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public interface UserService { | ||
|
||
Page<Event> findAllEventPages(Long userId, Pageable pageable); | ||
|
||
} |
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.
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.
이 api endpoint 에는 버전 명시가 안되어있어요
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.
아하.. 성원님 그래서 이 다음 PR 테스트에서 수정했습니다..
이것 때문에 한두시간 날아갔어요