Skip to content

Commit

Permalink
[merge]: 내 친구 목록에서 친구 삭제시 친구의 친구 목록에는 남아있는 버그 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
kanguk01 authored Nov 11, 2024
2 parents 878a2bb + 6a5a92d commit ed2c2fe
Show file tree
Hide file tree
Showing 23 changed files with 1,685 additions and 65 deletions.
95 changes: 95 additions & 0 deletions splanet-test.log
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,98 @@ eventType: API_REQUEST, userId: 2, deviceId: apiTestDeviceId, timestamp: 2024-11
eventType: LOGIN_SUCCESS, userId: 1, deviceId: testDeviceId, timestamp: 2024-11-12T01:09:31.692107, requestPath: /test/login, headers: User-Agent: TestAgent, Accept: */*
eventType: API_REQUEST, userId: 2, deviceId: apiTestDeviceId, timestamp: 2024-11-12T01:31:28.960904, requestPath: /test/api, headers: User-Agent: ApiTestAgent, Accept: application/json
eventType: LOGIN_SUCCESS, userId: 1, deviceId: testDeviceId, timestamp: 2024-11-12T01:31:28.972599, requestPath: /test/login, headers: User-Agent: TestAgent, Accept: */*
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:49.3028597, requestPath: /api/comments/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:49.5203791, requestPath: /api/comments/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:49.772894, requestPath: /api/comments, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:49.8690521, requestPath: /api/comments/1886, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:49.933985, requestPath: /api/comments/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:49.9962563, requestPath: /api/comments/409, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:50.0760239, requestPath: /api/comments/1892, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:50.250223, requestPath: /api/comments/412, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:50.3120036, requestPath: /api/comments, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:50.3747438, requestPath: /api/comments/414, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:52.1246169, requestPath: /api/friends/999/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:52.28604, requestPath: /api/friends/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:52.4156765, requestPath: /api/friends/1/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:52.6244195, requestPath: /api/friends/1904, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:52.8433793, requestPath: /api/friends, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:52.9487333, requestPath: /api/friends/1, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:53.0457083, requestPath: /api/friends, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:53.9521541, requestPath: /api/friends/requests, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.0340107, requestPath: /api/friends/requests/999/cancel, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.218513, requestPath: /api/friends/requests/158/accept, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.3053053, requestPath: /api/friends/requests, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.4208858, requestPath: /api/friends/requests/159/cancel, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.4540264, requestPath: /api/friends/requests/sent, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.5844674, requestPath: /api/friends/requests/160/cancel, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.6998971, requestPath: /api/friends/requests/161/reject, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.8226564, requestPath: /api/friends/requests, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:54.9297461, requestPath: /api/friends/requests/received, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:50:55.0453017, requestPath: /api/friends/requests/sent, headers:
eventType: API_REQUEST, userId: 2, deviceId: apiTestDeviceId, timestamp: 2024-11-12T01:51:11.4133233, requestPath: /test/api, headers: User-Agent: ApiTestAgent, Accept: application/json
eventType: LOGIN_SUCCESS, userId: 1, deviceId: testDeviceId, timestamp: 2024-11-12T01:51:11.4389194, requestPath: /test/login, headers: User-Agent: TestAgent, Accept: */*
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.1399193, requestPath: /api/payment/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.2281242, requestPath: /api/payment/57, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.3120922, requestPath: /api/payment/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.381132, requestPath: /api/payment/59, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.847827, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.9241445, requestPath: /api/plans/3, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:12.9484284, requestPath: /api/plans/3, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.008211, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.0400897, requestPath: /api/plans/4, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.0967577, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.1300244, requestPath: /api/plans/5, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.1877451, requestPath: /api/plans/9999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.2559353, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.3151272, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.4043286, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.4805706, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.5505545, requestPath: /api/plans/8, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.6053511, requestPath: /api/plans/9999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.6707081, requestPath: /api/plans/9, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.7459455, requestPath: /api/plans/10, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.8041065, requestPath: /api/plans/9999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.8724285, requestPath: /api/plans/9999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:13.9503133, requestPath: /api/plans/11, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:14.0083136, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:14.0726492, requestPath: /api/plans/12, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:14.1280526, requestPath: /api/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:14.9823068, requestPath: /api/subscription/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:15.0881529, requestPath: /api/subscription/me/subscribe, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:15.1681591, requestPath: /api/subscription/me/subscribe, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:15.2711891, requestPath: /api/subscriptions/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:15.4890487, requestPath: /api/teams/168/invite, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:15.6581786, requestPath: /api/teams/169/invite, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.3431456, requestPath: /api/teams/170/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.4168068, requestPath: /api/teams/170/plans/56, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.4852017, requestPath: /api/teams/171/plans/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.5630507, requestPath: /api/teams/172/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.6365126, requestPath: /api/teams/173/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.7654453, requestPath: /api/teams/174/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.8461776, requestPath: /api/teams/175/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.8868654, requestPath: /api/teams/175/plans/58, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.9186508, requestPath: /api/teams/175/plans/58, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:16.984638, requestPath: /api/teams/176/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:17.0113651, requestPath: /api/teams/176/plans/59, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:17.0769448, requestPath: /api/teams/177/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:17.1066412, requestPath: /api/teams/177/plans/60, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:17.1805787, requestPath: /api/teams/178/plans/999, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:17.2588973, requestPath: /api/teams/179/plans, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:17.2859849, requestPath: /api/teams/179/plans/61, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.0306386, requestPath: /api/users/create, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.0792517, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.1027003, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.1498642, requestPath: /api/users/create, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.1789634, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.1974601, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.2124668, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.2585632, requestPath: /api/users/create, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.2998102, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.3729508, requestPath: /api/users/create, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.5490552, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.6035407, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.6598154, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.7129503, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.7684137, requestPath: /api/users/me, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.8315305, requestPath: /api/users/create, headers:
eventType: API_REQUEST, userId: null, deviceId: null, timestamp: 2024-11-12T01:51:18.9064907, requestPath: /api/users/me, headers:
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ ResponseEntity<List<CommentResponse>> getComments(
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
ResponseEntity<String> createComment(
@Parameter(description = "작성자(인증된 유저)의 ID", required = true) @AuthenticationPrincipal Long writerId,
@Parameter(description = "대상 유저의 ID", required = true) @RequestParam Long userId,
@Parameter(description = "인증된 유저의 ID", required = true) @AuthenticationPrincipal Long userId,
@Parameter(description = "댓글 작성 요청 정보", required = true) @RequestBody CommentRequest request);

@PutMapping("/{commentId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public ResponseEntity<List<CommentResponse>> getComments(Long userId, Long userI
}

@Override
public ResponseEntity<String> createComment(Long writerId, Long userId, CommentRequest request) {
commentService.createComment(writerId, userId, request);
public ResponseEntity<String> createComment(Long userId, CommentRequest request) {
commentService.createComment(userId, request);
return ResponseEntity.ok("댓글이 성공적으로 작성되었습니다.");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.splanet.splanet.comment.dto;

public record CommentRequest(String content) {
public record CommentRequest(Long userId, String content) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ public List<CommentResponse> getComments(Long userId) {

// 댓글 작성
@Transactional
public void createComment(Long writerId, Long userId, CommentRequest request) {
User user = userRepository.findById(userId)
public void createComment(Long userId, CommentRequest request) {
User user = userRepository.findById(request.userId())
.orElseThrow(() -> new BusinessException(ErrorCode.USER_NOT_FOUND));
User writer = userRepository.findById(writerId)
User writer = userRepository.findById(userId)
.orElseThrow(() -> new BusinessException(ErrorCode.USER_NOT_FOUND));

if (user.getId().equals(writer.getId())) {
throw new BusinessException(ErrorCode.INVALID_COMMENT_ID);
}

Comment comment = Comment.builder()
.user(user)
.writer(writer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum ErrorCode {
INVITATION_ALREADY_PROCESSED("초대가 이미 처리되었습니다.", HttpStatus.BAD_REQUEST),
INVITATION_ALREADY_SENT("초대가 이미 존재합니다.", HttpStatus.BAD_REQUEST),
USER_ALREADY_IN_TEAM("해당 유저는 이미 팀에 속해 있습니다.", HttpStatus.BAD_REQUEST),
TEAM_NAME_NOT_FOUND("팀이름이 비어 있습니다.", HttpStatus.NOT_FOUND),

// friend
FRIEND_NOT_FOUND("친구가 아닙니다.",HttpStatus.NOT_FOUND),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,23 @@ public ResponseEntity<List<PlanResponseDto>> getFriendPlan(Long friendId, Long u
return ResponseEntity.ok(planResponseDtos);
}

// 친구 삭제(취소)하기

// 친구 삭제(취소)하기
@Transactional
public ResponseEntity<Map<String, String>> unfriend(Long friendId, Long userId) {
// 내 친구 목록에 존재하는지
if (!friendRepository.existsByUserIdAndFriendId(userId, friendId)) {
throw new BusinessException(ErrorCode.FRIEND_NOT_FOUND);
}

// 내가 내 친구 목록에서 친구 삭제
friendRepository.deleteByRequesterIdAndReceiverId(userId, friendId);

// 친구의 친구 목록에서도 나를 삭제
friendRepository.deleteByRequesterIdAndReceiverId(friendId, userId);

// 그 친구 관련 친구 요청도 있으면, 삭제
List<FriendRequest> pendingRequests = friendRequestRepository.findPendingRequestsByReceiverId(userId, friendId, FriendRequest.Status.PENDING);
for (FriendRequest request : pendingRequests) {
friendRequestRepository.delete(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ResponseEntity<SubscriptionResponse> getSubscription(
ResponseEntity<String> cancelSubscription(
@Parameter(description = "JWT 인증으로 전달된 사용자 ID", required = true) @AuthenticationPrincipal Long userId);

@PostMapping("/payment")
@PostMapping("/subscribe")
@Operation(summary = "구독", description = "사용자가 구독을 구매합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "구독이 성공적으로 구매되었습니다.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.splanet.splanet.team.api;
package com.splanet.splanet.team.controller;

import com.splanet.splanet.team.dto.TeamDto;
import com.splanet.splanet.team.dto.TeamInvitationDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.splanet.splanet.team.controller;

import com.splanet.splanet.team.api.TeamApi;
import com.splanet.splanet.team.controller.TeamApi;
import com.splanet.splanet.team.dto.TeamDto;
import com.splanet.splanet.team.dto.TeamInvitationDto;
import com.splanet.splanet.team.dto.TeamMemberDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
import com.splanet.splanet.team.entity.Team;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface TeamRepository extends JpaRepository<Team, Long> {
}
Optional<Team> findByTeamName(String teamName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TeamService(TeamRepository teamRepository, UserRepository userRepository,
@Transactional
public TeamDto createTeam(String teamName, Long userId) {
if (teamName == null || teamName.isBlank()) {
throw new BusinessException(ErrorCode.INVALID_INPUT_VALUE);
throw new BusinessException(ErrorCode.TEAM_NAME_NOT_FOUND);
}

User user = findUserById(userId);
Expand Down
Loading

0 comments on commit ed2c2fe

Please sign in to comment.