-
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.
KKUMI-113 [FEATURE] #66 mongoDB 설정 추가, PostView 추가
mongoDB 설정, repository 추가 mongoDB의 document와 연결할 PostView 추가
- Loading branch information
Showing
6 changed files
with
90 additions
and
1 deletion.
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
7 changes: 7 additions & 0 deletions
7
src/main/java/com/swmarastro/mykkumiserver/post/PostMongoRepository.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,7 @@ | ||
package com.swmarastro.mykkumiserver.post; | ||
|
||
import com.swmarastro.mykkumiserver.post.domain.PostView; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
|
||
public interface PostMongoRepository extends MongoRepository<PostView, Long> { | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/swmarastro/mykkumiserver/post/domain/PostView.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.swmarastro.mykkumiserver.post.domain; | ||
|
||
import com.swmarastro.mykkumiserver.category.domain.Category; | ||
import com.swmarastro.mykkumiserver.post.dto.PostImageDto; | ||
import com.swmarastro.mykkumiserver.post.richtext.PostContentObject; | ||
import com.swmarastro.mykkumiserver.user.User; | ||
import com.swmarastro.mykkumiserver.post.dto.Writer; | ||
import jakarta.persistence.Id; | ||
import lombok.*; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@Builder | ||
@Document(collection="postview") | ||
@NoArgsConstructor(access = AccessLevel.PUBLIC) | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PostView { | ||
|
||
@Id | ||
private Long id; | ||
private String category; | ||
private String subCategory; | ||
private Writer writer; | ||
private List<PostContentObject> content; | ||
private List<PostImageDto> images; | ||
|
||
public static PostView of(Post post, Category category, User writer, List<PostImageDto> images) { | ||
Writer postWriter = Writer.builder() | ||
.uuid(writer.getUuid().toString()) | ||
.profileImage(writer.getProfileImage()) | ||
.nickname(writer.getNickname()) | ||
.build(); | ||
|
||
return PostView.builder() | ||
.id(post.getId()) | ||
.category(category.getName()) | ||
.subCategory(post.getSubCategory().getName()) | ||
.writer(postWriter) | ||
.content(post.getContent()) | ||
.images(images) | ||
.build(); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/swmarastro/mykkumiserver/post/dto/Writer.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.swmarastro.mykkumiserver.post.dto; | ||
|
||
import com.swmarastro.mykkumiserver.user.User; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class Writer { | ||
private String uuid; | ||
private String profileImage; | ||
private String nickname; | ||
|
||
static public Writer of(User user) { | ||
return Writer.builder() | ||
.uuid(user.getUuid().toString()) | ||
.profileImage(user.getProfileImage()) | ||
.nickname(user.getNickname()) | ||
.build(); | ||
} | ||
} |
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,7 @@ | ||
spring: | ||
config: | ||
import: | ||
- 'aws-secretsmanager:local/mykkumi/mysql' | ||
- 'aws-secretsmanager:dev/mykkumi/s3' | ||
- 'aws-secretsmanager:dev/mykkumi/jwt' | ||
- 'aws-secretsmanager:dev/mykkumi/oauth' |
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