Skip to content

Commit 1975a44

Browse files
[Refactor] BlockListController to use proper request handling
Replaced direct parameter mapping with BlockReq DTO for blocking users and updated unblockUser to retrieve the blockedUserId from the URL path. These changes improve consistency, readability, and adherence to RESTful API design principles.
1 parent 33013f6 commit 1975a44

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/main/java/org/dfbf/soundlink/domain/blocklist/controller/BlockListController.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.swagger.v3.oas.annotations.Operation;
44
import io.swagger.v3.oas.annotations.tags.Tag;
55
import lombok.RequiredArgsConstructor;
6+
import org.dfbf.soundlink.domain.blocklist.dto.BlockReq;
67
import org.dfbf.soundlink.domain.blocklist.service.BlockListService;
78
import org.dfbf.soundlink.global.exception.ResponseResult;
89
import org.springframework.security.core.annotation.AuthenticationPrincipal;
@@ -22,21 +23,21 @@ public class BlockListController {
2223
)
2324
public ResponseResult blockUser(
2425
@AuthenticationPrincipal Long userId,
25-
@AuthenticationPrincipal Long blockUserId
26+
@RequestBody BlockReq req
2627
) {
27-
return blockListService.blockUser(userId, blockUserId);
28+
return blockListService.blockUser(userId, req.blockedUserId());
2829
}
2930

30-
@DeleteMapping
31+
@DeleteMapping("/{blockedUserId}")
3132
@Operation(
3233
summary = "유저 차단 해제",
3334
description = "차단한 유저를 해제합니다."
3435
)
3536
public ResponseResult unblockUser(
3637
@AuthenticationPrincipal Long userId,
37-
@AuthenticationPrincipal Long blockUserId
38+
@PathVariable Long blockedUserId
3839
) {
39-
return blockListService.unblockUser(userId, blockUserId);
40+
return blockListService.unblockUser(userId, blockedUserId);
4041
}
4142

4243
@GetMapping
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.dfbf.soundlink.domain.blocklist.dto;
2+
3+
public record BlockReq(
4+
Long blockedUserId
5+
) {
6+
}

0 commit comments

Comments
 (0)