Skip to content

Commit

Permalink
post-game relation activated (#627)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohbahadiroglu authored Dec 23, 2023
1 parent c45584c commit 9656a87
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class PostDTO(
var downvotes: Int = 0,
var totalComments: Int = 0,
var category: PostCategory = PostCategory.DISCUSSION,
///var relatedGame: GameDTO? = null,
var relatedGame: GameDTO? = null,
var tags: List<TagDTO>? = null
)

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ data class CreatePostRequest(
val content: String,
@JsonProperty("category")
val category: PostCategory,
@JsonProperty("gameId")
val gameId: Long? = null,
@JsonProperty("tags")
val tags: List<String>? = emptyList()
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ data class UpdatePostRequest(
val content: String?,
@JsonProperty("category")
val category: PostCategory?,
@JsonProperty("gameId")
val gameId: Long?,
@JsonProperty("tags")
val tags: List<String>?
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PostService(
content = post.content,
category = post.category,
user = user,
relatedGame = post.gameId?.let { gameService.getGame(it) },
postTags = tagService.createAndReturnTagsFromTagNames(post.tags) ?: emptyList()
)
return postRepository.save(newPost)
Expand All @@ -60,6 +61,7 @@ class PostService(
post.title = updatedPost.title ?: post.title
post.content = updatedPost.content ?: post.content
post.category = updatedPost.category ?: post.category
post.relatedGame = updatedPost.gameId?.let { gameService.getGame(it) } ?: post.relatedGame
post.postTags = tagService.createAndReturnTagsFromTagNames(updatedPost.tags) ?: post.postTags
// TODO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ object ConverterDTO {
downvotes = post.downvotes,
totalComments = post.totalComments,
category = post.category,
relatedGame = post.relatedGame?.let { convertToGameDTO(it) },
tags = convertBulkToTagDTO(post.postTags)
)
}
Expand Down

0 comments on commit 9656a87

Please sign in to comment.