Skip to content

Commit

Permalink
refactor(coffeechat) : 커피챗이 수락 상태일 때 상대방의 연락처도 반환
Browse files Browse the repository at this point in the history
  • Loading branch information
Woongbin06 committed Apr 26, 2024
1 parent 8ca098c commit 02bf7b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.sickgyun.server.auth.repository.AuthRepository;
import com.sickgyun.server.coffeechat.presentation.dto.AcceptResponse;
import com.sickgyun.server.coffeechat.presentation.dto.CoffeeChatRequest;
import com.sickgyun.server.coffeechat.presentation.dto.CoffeeChatResponse;
import com.sickgyun.server.coffeechat.presentation.dto.MySentCoffeeChatResponse;
import com.sickgyun.server.coffeechat.presentation.dto.ReceivedCoffeeChatResponse;
import com.sickgyun.server.coffeechat.service.CommandCoffeeChatService;
import com.sickgyun.server.coffeechat.service.QueryCoffeeChatService;
Expand Down Expand Up @@ -75,9 +75,9 @@ public List<ReceivedCoffeeChatResponse> getReceiveCoffeeChat() {

@GetMapping("/my/send")
@LoginRequired
public List<CoffeeChatResponse> getSendPendingChat() {
public List<MySentCoffeeChatResponse> getSendPendingChat() {
return queryCoffeeChatService.getByFromUser(authRepository.getCurrentUser()).stream()
.map(CoffeeChatResponse::from)
.map(MySentCoffeeChatResponse::from)
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
import com.sickgyun.server.coffeechat.domain.value.State;
import com.sickgyun.server.user.presentation.dto.UserResponse;

public record CoffeeChatResponse(
public record MySentCoffeeChatResponse(
Long id,
State state,
String message,
ContactResponse contact,
UserResponse toUser,
UserResponse fromUser
) {

public static CoffeeChatResponse from(CoffeeChat coffeeChat) {
return new CoffeeChatResponse(
public static MySentCoffeeChatResponse from(CoffeeChat coffeeChat) {
return new MySentCoffeeChatResponse(
coffeeChat.getId(),
coffeeChat.getState(),
coffeeChat.getMessage(),
coffeeChat.getState().equals(State.ACCEPT) ? ContactResponse.from(coffeeChat.getToUser().getContact()) : null,
UserResponse.from(coffeeChat.getToUser()),
UserResponse.from(coffeeChat.getFromUser())
);
Expand Down

0 comments on commit 02bf7b0

Please sign in to comment.