-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
72 deletions.
There are no files selected for viewing
37 changes: 32 additions & 5 deletions
37
src/main/java/UMC/campusNote/friend/controller/FriendController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,54 @@ | ||
package UMC.campusNote.friend.controller; | ||
|
||
import UMC.campusNote.auth.jwt.JwtProvider; | ||
import UMC.campusNote.common.ApiResponse; | ||
|
||
import UMC.campusNote.friend.dto.FriendRequestDTO; | ||
import UMC.campusNote.friend.dto.FriendResponseDTO; | ||
import UMC.campusNote.friend.service.FriendService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.Parameters; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/friend") | ||
@RequestMapping("/api/v1/friends") | ||
public class FriendController { | ||
|
||
private final FriendService friendService; | ||
|
||
@PostMapping | ||
@Operation(summary = "친구 추가 기능 API", description = "친구 관계를 추가하는 API입니다.") | ||
private ApiResponse addFriend(@Valid @RequestBody FriendRequestDTO.AddFriendReqDTO addFriendReqDto){ | ||
|
||
friendService.addFriend(addFriendReqDto); | ||
|
||
return ApiResponse.onSuccess(null); | ||
} | ||
|
||
|
||
@GetMapping("/{userId}") | ||
@Operation(summary = "친구 조회 기능 API", description = "유저의 친구를 조회하는 API입니다.") | ||
@Parameters({ | ||
@Parameter(name = "userId", description = "유저 id 입니다.") | ||
}) | ||
private ApiResponse<List<FriendResponseDTO.friendListDTO>> friendList(@PathVariable("userId") Long userId){ | ||
List<FriendResponseDTO.friendListDTO> friendList = friendService.findFriendList(userId); | ||
|
||
return ApiResponse.onSuccess(friendList); | ||
} | ||
|
||
@DeleteMapping("/{userId}/{friendId}") | ||
@Operation(summary = "친구 삭제 기능 API", description = "") | ||
private ApiResponse deleteFriend(@PathVariable("userId") Long userId, @PathVariable("friendId") Long friendId){ | ||
friendService.deleteFriend(userId, friendId); | ||
|
||
return ApiResponse.onSuccess(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
src/main/java/UMC/campusNote/friend/dto/AddFriendReqDto.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/main/java/UMC/campusNote/friend/dto/FriendResponseDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package UMC.campusNote.friend.dto; | ||
|
||
import lombok.*; | ||
|
||
public class FriendResponseDTO { | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
@Builder | ||
public static class friendListDTO{ | ||
private Long friendId; | ||
private String name; | ||
private String img; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
src/test/java/UMC/campusNote/friend/controller/FriendControllerTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters