Skip to content

Commit

Permalink
[Fix]: merge conflict 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
onpyeong committed Jan 16, 2024
2 parents d17559d + 27c3d77 commit 3ad48e9
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum SuccessCode {

// friend
ADD_FRIEND_SUCCESS(HttpStatus.OK, "공유 요청에 성공했습니다."),
GET_FRIEND_LIST_SUCCESS(HttpStatus.OK, "친구 리스트 조회에 성공했습니다."),
HANDLE_FRIEND_REQUEST_SUCCESS(HttpStatus.OK, "공유 응답에 성공했습니다."),
UPDATE_FRIEND_NAME_SUCCESS(HttpStatus.OK, "멤버 이름 수정에 성공했습니다."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.sobok.SobokSobok.friend.infrastructure.SendFriendRepository;
import io.sobok.SobokSobok.friend.ui.dto.AddFriendRequest;
import io.sobok.SobokSobok.friend.ui.dto.AddFriendResponse;
import io.sobok.SobokSobok.friend.ui.dto.FriendListResponse;
import io.sobok.SobokSobok.friend.ui.dto.HandleFriendRequest;
import io.sobok.SobokSobok.friend.ui.dto.HandleFriendRequestResponse;
import io.sobok.SobokSobok.friend.ui.dto.UpdateFriendName;
Expand All @@ -24,6 +25,8 @@
import io.sobok.SobokSobok.notice.infrastructure.NoticeQueryRepository;
import io.sobok.SobokSobok.notice.infrastructure.NoticeRepository;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -83,6 +86,20 @@ public AddFriendResponse addFriend(Long userId, AddFriendRequest request) {
.build();
}

@Transactional(readOnly = true)
public List<FriendListResponse> getFriendList(Long userId) {
UserServiceUtil.existsUserById(userRepository, userId);

return friendRepository.findAllBySenderId(userId)
.stream().map(friend ->
FriendListResponse.builder()
.friendId(friend.getId())
.memberId(friend.getReceiverId())
.friendName(friend.getFriendName())
.build()
).collect(Collectors.toList());
}

@Transactional(noRollbackFor = {ConflictException.class})
public HandleFriendRequestResponse updateNoticeStatus(Long userId, Long noticeId,
HandleFriendRequest request) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.sobok.SobokSobok.friend.infrastructure;

import io.sobok.SobokSobok.friend.domain.Friend;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;

public interface FriendRepository extends JpaRepository<Friend, Long> {

List<Friend> findAllBySenderId(Long senderId);

Integer countBySenderId(Long senderId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
import io.sobok.SobokSobok.friend.application.FriendService;
import io.sobok.SobokSobok.friend.ui.dto.AddFriendRequest;
import io.sobok.SobokSobok.friend.ui.dto.AddFriendResponse;
import io.sobok.SobokSobok.friend.ui.dto.FriendListResponse;
import io.sobok.SobokSobok.friend.ui.dto.HandleFriendRequest;
import io.sobok.SobokSobok.friend.ui.dto.HandleFriendRequestResponse;
import io.sobok.SobokSobok.friend.ui.dto.UpdateFriendName;
import io.sobok.SobokSobok.friend.ui.dto.UpdateFriendNameResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
Expand Down Expand Up @@ -67,6 +70,22 @@ public ResponseEntity<ApiResponse<HandleFriendRequestResponse>> handleFriendRequ
));
}

@GetMapping("")
@Operation(
summary = "친구 리스트 조회 API 메서드",
description = "친구 리스트를 조회하는 메서드입니다."
)
public ResponseEntity<ApiResponse<List<FriendListResponse>>> getFriendList(
@AuthenticationPrincipal User user
) {
return ResponseEntity
.status(HttpStatus.OK)
.body(ApiResponse.success(
SuccessCode.GET_FRIEND_LIST_SUCCESS,
friendService.getFriendList(user.getId())
));
}

@PutMapping("/{friendId}/name")
@Operation(
summary = "공유 친구 이름 수정 API 메서드",
Expand All @@ -76,7 +95,7 @@ public ResponseEntity<ApiResponse<UpdateFriendNameResponse>> updateFriendName(
@AuthenticationPrincipal User user,
@PathVariable Long friendId,
@RequestBody @Valid UpdateFriendName request
){
) {
return ResponseEntity
.status(HttpStatus.OK)
.body(ApiResponse.success(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.sobok.SobokSobok.friend.ui.dto;

import lombok.Builder;

@Builder
public record FriendListResponse(
Long friendId,
Long memberId,
String friendName
) {

}

0 comments on commit 3ad48e9

Please sign in to comment.