-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature : Post 객체 구현 및 관련 기능 구현 완료 #188
feature : Post 객체 구현 및 관련 기능 구현 완료
- Loading branch information
Showing
28 changed files
with
485 additions
and
70 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/main/java/com/book_everywhere/common/dto/CountDto.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 com.book_everywhere.common.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
public class CountDto<T> { | ||
private List<T> data; | ||
private int count; | ||
|
||
public CountDto(List<T> data) { | ||
this.data = data; | ||
this.count = data.size(); | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
src/main/java/com/book_everywhere/domain/book/service/BookServiceImpl.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
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
4 changes: 2 additions & 2 deletions
4
src/main/java/com/book_everywhere/domain/mark/dto/BookmarkDto.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,12 +1,12 @@ | ||
package com.book_everywhere.domain.mark.dto; | ||
|
||
import com.book_everywhere.domain.pin.dto.PinRespDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class BookmarkDto { | ||
Long id; | ||
Long pinId; | ||
PinRespDto pinRespDto; | ||
} |
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
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
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
10 changes: 5 additions & 5 deletions
10
src/main/java/com/book_everywhere/domain/pin/service/VisitServiceImpl.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
70 changes: 70 additions & 0 deletions
70
src/main/java/com/book_everywhere/domain/post/controller/PostController.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,70 @@ | ||
package com.book_everywhere.domain.post.controller; | ||
|
||
import com.book_everywhere.common.dto.CMRespDto; | ||
import com.book_everywhere.common.dto.CountDto; | ||
import com.book_everywhere.domain.post.facade.PostFacade; | ||
import com.book_everywhere.domain.post.dto.PostReqDto; | ||
import com.book_everywhere.domain.post.dto.PostRespDto; | ||
import com.book_everywhere.domain.post.service.PostService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class PostController { | ||
|
||
private final PostService postService; | ||
private final PostFacade postFacade; | ||
|
||
//전체 장소 리뷰 조회 | ||
@Operation(summary = "모든 큐레이팅 조회", description = "모든 큐레이팅 조회 return = List<PostRespDto>") | ||
@GetMapping("/api/posts") | ||
public CMRespDto<?> findAllPosts() { | ||
List<PostRespDto> result = postService.모든_장소_리뷰_조회(); | ||
return new CMRespDto<>(HttpStatus.OK, result, "모든 장소 리뷰 조회 성공!"); | ||
} | ||
|
||
//단일 장소 리뷰 조회 | ||
@Operation(summary = "단일 큐레이팅 조회", description = "단일 큐레이팅 조회 return = PostRespDto") | ||
@GetMapping("/api/post/{postId}") | ||
public CMRespDto<?> findPost(@PathVariable Long postId) { | ||
PostRespDto result = postService.장소_리뷰_조회(postId); | ||
return new CMRespDto<>(HttpStatus.OK,result,"단일 장소 리뷰 조회 성공!"); | ||
} | ||
|
||
//유저 장소 리뷰 조회 | ||
@Operation(summary = "유저의 모든 큐레이팅 조회", description = "유저의 모든 큐레이팅을 개수와 함께 조회합니다. return = CountDto<List<PostRespDto>>") | ||
@GetMapping("/api/user/post/{socialId}") | ||
public CMRespDto<?> findUserPosts(@PathVariable Long socialId) { | ||
List<PostRespDto> postRespDtos = postService.유저의_모든_장소_리뷰_조회(socialId); | ||
CountDto<?> result = new CountDto<>(postRespDtos); | ||
return new CMRespDto<>(HttpStatus.OK, result, "유저의 장소 리뷰 조회 성공!"); | ||
} | ||
|
||
//유저 큐레이팅 생성 (임시) | ||
@Operation(summary = "큐레이팅 생성", description = "새 큐레이팅을 저장합니다.") | ||
@PostMapping("/api/post") | ||
public CMRespDto<?> savePost(@Valid @RequestBody PostReqDto postReqDto) { | ||
postFacade.장소_리뷰_등록(postReqDto); //#@! 이미지 관련 부분 및 태그 부분 구현이 필요합니다. | ||
return new CMRespDto<>(HttpStatus.OK, null, "큐레이팅 저장 성공!"); | ||
} | ||
|
||
//해당 장소의 모든 리뷰 조회 | ||
@Operation(summary = "장소의 모든 큐레이팅 조회", description = "장소의 모든 큐레이팅을 조회합니다. return = List<PostRespDto>") | ||
@GetMapping("/api/pin/post") | ||
public CMRespDto<?> findAllPostInPin(@RequestParam("address") String address) { | ||
List<PostRespDto> result = postService.장소의_모든_리뷰_조회(address); | ||
return new CMRespDto<>(HttpStatus.OK, result, "해당 장소의 모든 리뷰 조회 성공!"); | ||
} | ||
|
||
//#@!유저의 좋아요 장소 리뷰 조회 | ||
|
||
//#@!유저 장소 리뷰 수정 | ||
|
||
//#@!유저 장소 리뷰 삭제 | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/book_everywhere/domain/post/dto/PostReqDto.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,46 @@ | ||
package com.book_everywhere.domain.post.dto; | ||
|
||
import com.book_everywhere.domain.auth.entity.User; | ||
import com.book_everywhere.domain.pin.dto.PinRespDto; | ||
import com.book_everywhere.domain.pin.entity.Pin; | ||
import com.book_everywhere.domain.post.entity.Post; | ||
import com.book_everywhere.domain.post.entity.PostImage; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
//장소 리뷰 등록 요청용 Dto | ||
public class PostReqDto { | ||
private Long socialId; | ||
//@Valid 어노테이션 사용하기 | ||
@NotBlank | ||
@Size(max = 20, message = "제목은 20자 이하로 입력해주세요.") | ||
private String title; | ||
@NotNull | ||
@Size(max = 1500, message = "내용은 1500자 이하로 입력해주세요") | ||
private String content; | ||
private List<String> imageUrls; | ||
private PinRespDto pinRespDto; | ||
|
||
// 리뷰 임시저장 or 발행 여부 | ||
@NotNull(message = "발행 여부를 정확히해주세요.") | ||
private boolean isPublishing; | ||
|
||
//태그 생성을 위한 dto필요 | ||
|
||
public Post toEntity(User user, Pin pin) { | ||
return Post.builder() | ||
.title(title) | ||
.content(content) | ||
.user(user) | ||
.pin(pin) | ||
//#@!이미지 관련 코드가 필요합니다. | ||
.build(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/book_everywhere/domain/post/dto/PostRespDto.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,21 @@ | ||
package com.book_everywhere.domain.post.dto; | ||
|
||
import com.book_everywhere.domain.pin.dto.PinRespDto; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class PostRespDto { | ||
private Long postId; | ||
private String title; | ||
private String content; | ||
private List<String> post_imageUrl; | ||
private PinRespDto pinRespDto; | ||
private boolean isPublishing; | ||
} |
Oops, something went wrong.