-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from HyeJiJUN11/feature/18-friendAPI
feat: 친구 관련 API 구현
- Loading branch information
Showing
26 changed files
with
862 additions
and
143 deletions.
There are no files selected for viewing
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
83 changes: 83 additions & 0 deletions
83
src/main/java/com/potatocake/everymoment/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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.potatocake.everymoment.controller; | ||
|
||
import com.potatocake.everymoment.dto.SuccessResponse; | ||
import com.potatocake.everymoment.dto.response.FriendListResponse; | ||
import com.potatocake.everymoment.dto.response.OneFriendDiariesResponse; | ||
import com.potatocake.everymoment.service.FriendService; | ||
import java.time.LocalDate; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("api/friends") | ||
public class FriendController { | ||
private final FriendService friendService; | ||
|
||
public FriendController(FriendService friendService) { | ||
this.friendService = friendService; | ||
} | ||
|
||
//특정 친구 일기 전체 조회 | ||
@GetMapping("/{id}/diaries") | ||
public ResponseEntity<SuccessResponse<OneFriendDiariesResponse>> getOneFriendDiaries( | ||
@PathVariable Long id, | ||
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date, | ||
@RequestParam(defaultValue = "0") int key, | ||
@RequestParam(defaultValue = "10") int size) { | ||
OneFriendDiariesResponse diaries = friendService.OneFriendDiariesResponse(id, date, key, size); | ||
SuccessResponse<OneFriendDiariesResponse> response = SuccessResponse.<OneFriendDiariesResponse>builder() | ||
.code(HttpStatus.OK.value()) | ||
.message("success") | ||
.info(diaries) | ||
.build(); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
//내 친구 목록 조회 | ||
@GetMapping("/friends") | ||
public ResponseEntity<SuccessResponse<FriendListResponse>> getFriendList( | ||
@RequestParam(required = false) String nickname, | ||
@RequestParam(required = false) String email, | ||
@RequestParam(defaultValue = "0") int key, | ||
@RequestParam(defaultValue = "10") int size) { | ||
FriendListResponse friendList = friendService.getFriendList(nickname, email, key, size); | ||
SuccessResponse<FriendListResponse> response = SuccessResponse.<FriendListResponse>builder() | ||
.code(HttpStatus.OK.value()) | ||
.message("success") | ||
.info(friendList) | ||
.build(); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
//내 친구 삭제 | ||
@DeleteMapping("/{id}") | ||
public ResponseEntity<SuccessResponse<Void>> deleteFriend(@PathVariable Long id) { | ||
friendService.deleteFriend(id); | ||
SuccessResponse<Void> response = SuccessResponse.<Void>builder() | ||
.code(HttpStatus.OK.value()) | ||
.message("success") | ||
.info(null) | ||
.build(); | ||
return ResponseEntity.ok(response); | ||
} | ||
|
||
//친한 친구 설정 | ||
@PatchMapping("/{id}/bookmark") | ||
public ResponseEntity<SuccessResponse<Void>> toggleCloseFriend(@PathVariable Long id) { | ||
friendService.toggleCloseFriend(id); | ||
SuccessResponse<Void> response = SuccessResponse.<Void>builder() | ||
.code(HttpStatus.OK.value()) | ||
.message("success") | ||
.info(null) | ||
.build(); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/potatocake/everymoment/dto/request/DiaryFilterRequest.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,19 @@ | ||
package com.potatocake.everymoment.dto.request; | ||
|
||
import java.time.LocalDate; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class DiaryFilterRequest { | ||
private String keyword; | ||
private String emoji; | ||
private Long category; | ||
private LocalDate date; | ||
private LocalDate from; | ||
private LocalDate until; | ||
private Boolean bookmark; | ||
private int key; | ||
private int size; | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/potatocake/everymoment/dto/response/FriendDiariesResponse.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,12 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class FriendDiariesResponse { | ||
private List<FriendDiarySimpleResponse> diaries; | ||
private Integer next; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/potatocake/everymoment/dto/response/FriendDiaryResponse.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,23 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class FriendDiaryResponse { | ||
private Long id; | ||
private List<CategoryResponse> categories; | ||
private String locationName; | ||
private String emoji; | ||
private List<FileResponse> file; | ||
private String content; | ||
private Integer likeCount; | ||
private LocalDateTime createAt; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/potatocake/everymoment/dto/response/FriendDiarySimpleResponse.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,23 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class FriendDiarySimpleResponse { | ||
private Long id; | ||
private String locationName; | ||
private String address; | ||
private boolean isBookmark; | ||
private boolean isPublic; | ||
private String emoji; | ||
private ThumbnailResponse thumbnailResponse; | ||
private String content; | ||
private LocalDateTime createAt; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/potatocake/everymoment/dto/response/FriendListResponse.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,12 @@ | ||
package com.potatocake.everymoment.dto.response; | ||
|
||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class FriendListResponse { | ||
private List<FriendProfileResponse> friends; | ||
private Integer next; | ||
} |
Oops, something went wrong.