-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: 사용자별 메시지 송/수신기록 조회 API (#117)
- Loading branch information
Showing
6 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/slvtwn/khu/toyouserver/application/RollingPaperCommandFacade.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,21 @@ | ||
package slvtwn.khu.toyouserver.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import slvtwn.khu.toyouserver.dto.RollingPaperExchangeCountResponse; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class RollingPaperCommandFacade { | ||
|
||
private final RollingPaperService rollingPaperService; | ||
private final UserService userService; | ||
|
||
public RollingPaperExchangeCountResponse getExchangeCount(Long userId) { | ||
return RollingPaperExchangeCountResponse.of( | ||
userService.getProfile(userId).name(), | ||
rollingPaperService.countSentRollingPapers(userId), | ||
rollingPaperService.countReceivedRollingPapers(userId) | ||
); | ||
} | ||
} |
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
src/main/java/slvtwn/khu/toyouserver/dto/RollingPaperExchangeCountResponse.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 slvtwn.khu.toyouserver.dto; | ||
|
||
public record RollingPaperExchangeCountResponse(String userName, Long sentCount, Long receivedCount) { | ||
public static RollingPaperExchangeCountResponse of(String userName, Long sentCount, Long receivedCount) { | ||
return new RollingPaperExchangeCountResponse(userName, sentCount, receivedCount); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/slvtwn/khu/toyouserver/presentation/RollingPaperFolderController.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,24 @@ | ||
package slvtwn.khu.toyouserver.presentation; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import slvtwn.khu.toyouserver.application.RollingPaperCommandFacade; | ||
import slvtwn.khu.toyouserver.common.authentication.UserAuthentication; | ||
import slvtwn.khu.toyouserver.common.response.ToyouResponse; | ||
import slvtwn.khu.toyouserver.dto.RollingPaperExchangeCountResponse; | ||
|
||
@RequestMapping("/rollingpapers/folders") | ||
@RequiredArgsConstructor | ||
@RestController | ||
public class RollingPaperFolderController { | ||
|
||
private final RollingPaperCommandFacade rollingPaperCommandFacade; | ||
|
||
@GetMapping("/info") | ||
public ToyouResponse<RollingPaperExchangeCountResponse> findRollingPaperExchangeCount( | ||
@UserAuthentication Long userId) { | ||
return ToyouResponse.from(rollingPaperCommandFacade.getExchangeCount(userId)); | ||
} | ||
} |