Skip to content

Commit 0f76c39

Browse files
authored
Merge pull request #227 from Central-MakeUs/release
Release
2 parents 33865c4 + 40403f1 commit 0f76c39

File tree

13 files changed

+218
-72
lines changed

13 files changed

+218
-72
lines changed

โ€Žsrc/main/java/com/example/ForDay/domain/friend/controller/FriendController.javaโ€Ž

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import com.example.ForDay.domain.friend.dto.request.AddFriendReqDto;
44
import com.example.ForDay.domain.friend.dto.request.BlockFriendReqDto;
5-
import com.example.ForDay.domain.friend.dto.response.AddFriendResDto;
6-
import com.example.ForDay.domain.friend.dto.response.BlockFriendResDto;
7-
import com.example.ForDay.domain.friend.dto.response.DeleteFriendResDto;
8-
import com.example.ForDay.domain.friend.dto.response.GetFriendListResDto;
5+
import com.example.ForDay.domain.friend.dto.request.ReportFriendReqDto;
6+
import com.example.ForDay.domain.friend.dto.response.*;
97
import com.example.ForDay.domain.friend.service.FriendService;
108
import com.example.ForDay.global.oauth.CustomUserDetails;
119
import jakarta.validation.Valid;
@@ -40,6 +38,13 @@ public BlockFriendResDto blockFriend(@RequestBody @Valid BlockFriendReqDto reqDt
4038
return friendService.blockFriend(reqDto, user);
4139
}
4240

41+
@Override
42+
@PostMapping("/report")
43+
public ReportFriendResDto reportFriend(@RequestBody @Valid ReportFriendReqDto reqDto,
44+
@AuthenticationPrincipal CustomUserDetails user) {
45+
return friendService.reportFriend(reqDto, user);
46+
}
47+
4348
@Override
4449
@GetMapping
4550
public GetFriendListResDto getFriendList(@RequestParam(name = "lastUserId", required = false) String lastUserId,

โ€Žsrc/main/java/com/example/ForDay/domain/friend/controller/FriendControllerDocs.javaโ€Ž

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import com.example.ForDay.domain.friend.dto.request.AddFriendReqDto;
44
import com.example.ForDay.domain.friend.dto.request.BlockFriendReqDto;
5-
import com.example.ForDay.domain.friend.dto.response.AddFriendResDto;
6-
import com.example.ForDay.domain.friend.dto.response.BlockFriendResDto;
7-
import com.example.ForDay.domain.friend.dto.response.DeleteFriendResDto;
8-
import com.example.ForDay.domain.friend.dto.response.GetFriendListResDto;
5+
import com.example.ForDay.domain.friend.dto.request.ReportFriendReqDto;
6+
import com.example.ForDay.domain.friend.dto.response.*;
7+
import com.example.ForDay.global.common.error.ErrorResponse;
98
import com.example.ForDay.global.oauth.CustomUserDetails;
109
import io.swagger.v3.oas.annotations.Operation;
1110
import io.swagger.v3.oas.annotations.Parameter;
@@ -22,7 +21,9 @@
2221

2322

2423
@Tag(name = "Friend", description = "์นœ๊ตฌ ๊ด€๊ณ„ ๊ด€๋ฆฌ API")
25-
public interface FriendControllerDocs {
24+
public interface
25+
26+
FriendControllerDocs {
2627

2728
@Operation(
2829
summary = "์นœ๊ตฌ ๋งบ๊ธฐ (ํŒ”๋กœ์šฐ)",
@@ -114,4 +115,40 @@ GetFriendListResDto getFriendList(
114115
@Parameter(description = "ํ•œ ํŽ˜์ด์ง€์— ์กฐํšŒํ•  ์œ ์ € ์ˆ˜", example = "20")
115116
@RequestParam(name = "size", required = false, defaultValue = "20") Integer size,
116117
@AuthenticationPrincipal CustomUserDetails user);
118+
119+
@Operation(
120+
summary = "์นœ๊ตฌ ์‹ ๊ณ ",
121+
description = "ํŠน์ • ์‚ฌ์šฉ์ž๋ฅผ ์‹ ๊ณ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฏธ ์‹ ๊ณ ํ•œ ๊ฒฝ์šฐ์—๋„ 200 OK๋กœ ์‘๋‹ตํ•ฉ๋‹ˆ๋‹ค."
122+
)
123+
@ApiResponses(value = {
124+
@ApiResponse(
125+
responseCode = "200",
126+
description = "์‹ ๊ณ  ์„ฑ๊ณต ๋˜๋Š” ์ด๋ฏธ ์‹ ๊ณ ๋œ ์ƒํƒœ"
127+
),
128+
@ApiResponse(
129+
responseCode = "400",
130+
description = "์ž๊ธฐ ์ž์‹  ์‹ ๊ณ ",
131+
content = @Content(
132+
mediaType = "application/json",
133+
schema = @Schema(implementation = ErrorResponse.class)
134+
)
135+
),
136+
@ApiResponse(
137+
responseCode = "404",
138+
description = "์กด์žฌํ•˜์ง€ ์•Š๋Š” ์‚ฌ์šฉ์ž",
139+
content = @Content(
140+
mediaType = "application/json",
141+
schema = @Schema(implementation = ErrorResponse.class)
142+
)
143+
)
144+
})
145+
public ReportFriendResDto reportFriend(
146+
@RequestBody
147+
@Valid
148+
@Parameter(description = "์‹ ๊ณ  ์š”์ฒญ ์ •๋ณด", required = true)
149+
ReportFriendReqDto reqDto,
150+
@AuthenticationPrincipal
151+
@Parameter(hidden = true) // Swagger์— ํ‘œ์‹œ ์•ˆ ํ•จ
152+
CustomUserDetails user
153+
);
117154
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example.ForDay.domain.friend.dto.request;
2+
3+
import jakarta.validation.constraints.NotBlank;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
@Data
9+
@AllArgsConstructor
10+
@NoArgsConstructor
11+
public class ReportFriendReqDto {
12+
@NotBlank(message = "์‚ฌ์šฉ์ž ID๋Š” ํ•„์ˆ˜์ž…๋‹ˆ๋‹ค.")
13+
private String userId;
14+
private String reason;
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.example.ForDay.domain.friend.dto.response;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
7+
@Data
8+
@NoArgsConstructor
9+
@AllArgsConstructor
10+
public class ReportFriendResDto {
11+
private String message;
12+
private String nickname;
13+
private String userId;
14+
}

โ€Žsrc/main/java/com/example/ForDay/domain/friend/repository/FriendRelationRepository.javaโ€Ž

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import java.util.Optional;
1111

1212
public interface FriendRelationRepository extends JpaRepository<FriendRelation, Long>, FriendRelationRepositoryCustom {
13-
Optional<FriendRelation> findByRequesterIdAndTargetUserId(String id, String id1);
14-
1513
boolean existsByRequesterIdAndTargetUserIdAndRelationStatus(String id, String id1, FriendRelationStatus friendRelationStatus);
1614

1715
@Query("SELECT COUNT(f) > 0 FROM FriendRelation f " +
@@ -34,4 +32,15 @@ boolean existsByFriendship(
3432
"WHERE (f.requester.id = :uid1 AND f.targetUser.id = :uid2) " +
3533
"OR (f.requester.id = :uid2 AND f.targetUser.id = :uid1)")
3634
List<FriendRelation> findAllRelationsBetween(@Param("uid1") String uid1, @Param("uid2") String uid2);
35+
36+
@Query("""
37+
SELECT fr
38+
FROM FriendRelation fr
39+
WHERE (fr.requester.id = :currentUserId AND fr.targetUser.id = :targetUserId)
40+
OR (fr.requester.id = :targetUserId AND fr.targetUser.id = :currentUserId)
41+
""")
42+
List<FriendRelation> findBothDirections(@Param("currentUserId") String currentUserId,
43+
@Param("targetUserId") String targetUserId);
44+
45+
Optional<FriendRelation> findByRequesterIdAndTargetUserId(String requesterId, String targetUserId);
3746
}

โ€Žsrc/main/java/com/example/ForDay/domain/friend/repository/FriendRelationRepositoryImpl.javaโ€Ž

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.Set;
1818

1919
@RequiredArgsConstructor
20-
public class FriendRelationRepositoryImpl implements FriendRelationRepositoryCustom{
20+
public class FriendRelationRepositoryImpl implements FriendRelationRepositoryCustom {
2121
private final JPAQueryFactory queryFactory;
2222
private QUser user = QUser.user;
2323
private QFriendRelation relation = QFriendRelation.friendRelation;
@@ -57,13 +57,14 @@ public List<GetFriendListResDto.UserInfoDto> findMyFriendList(String currentUser
5757
public List<String> findAllBlockedIdsByUserId(String userId) {
5858
QFriendRelation friendRelation = QFriendRelation.friendRelation;
5959

60-
// 1. ๋‚ด๊ฐ€ ์ฐจ๋‹จํ•œ ์‚ฌ๋žŒ๋“ค
60+
// 1. ๋‚ด๊ฐ€ ์ฐจ๋‹จํ•˜๊ฑฐ๋‚˜ ์‹ ๊ณ ํ•œ ์‚ฌ๋žŒ๋“ค
6161
List<String> blockedByMe = queryFactory
6262
.select(friendRelation.targetUser.id)
6363
.from(friendRelation)
6464
.where(friendRelation.requester.id.eq(userId)
65-
.and(friendRelation.relationStatus.eq(FriendRelationStatus.BLOCK)))
66-
.fetch();
65+
.and(friendRelation.relationStatus.eq(FriendRelationStatus.BLOCK))
66+
.or(friendRelation.relationStatus.eq(FriendRelationStatus.REPORT)))
67+
.fetch();
6768

6869
// 2. ๋‚˜๋ฅผ ์ฐจ๋‹จํ•œ ์‚ฌ๋žŒ๋“ค
6970
List<String> blockedMe = queryFactory

0 commit comments

Comments
ย (0)