-
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 #125 from snuhcs-course/feat/back-builder
Feat/back builder
- Loading branch information
Showing
21 changed files
with
352 additions
and
187 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
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
52 changes: 35 additions & 17 deletions
52
springboot/src/main/kotlin/com/goliath/emojihub/springboot/domain/post/dto/PostDto.kt
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,30 +1,48 @@ | ||
package com.goliath.emojihub.springboot.domain.post.dto | ||
|
||
import kotlin.streams.asSequence | ||
|
||
data class PostDto( | ||
var id: String = "", | ||
var created_by: String = "", | ||
var content: String = "", | ||
var created_at: String = "", | ||
var modified_at: String = "", | ||
var reactions: MutableList<ReactionWithEmojiUnicode> = mutableListOf(), | ||
) { | ||
constructor(username: String, content: String, dateTime: String) : this() { | ||
val source = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | ||
val outputStrLength: Long = 20 | ||
id = java.util.Random().ints(outputStrLength, 0, source.length) | ||
.asSequence() | ||
.map(source::get) | ||
.joinToString("") | ||
created_by = username | ||
this.content = content | ||
created_at = dateTime | ||
modified_at = dateTime | ||
} | ||
} | ||
) | ||
|
||
data class ReactionWithEmojiUnicode( | ||
var id: String = "", | ||
var emoji_unicode: String = "" | ||
) | ||
) | ||
|
||
class PostDtoBuilder { | ||
private val postDto: PostDto = PostDto() | ||
|
||
fun id(id: String): PostDtoBuilder { | ||
postDto.id = id | ||
return this | ||
} | ||
|
||
fun createdBy(createdBy: String): PostDtoBuilder { | ||
postDto.created_by = createdBy | ||
return this | ||
} | ||
|
||
fun content(content: String): PostDtoBuilder { | ||
postDto.content = content | ||
return this | ||
} | ||
|
||
fun createdAt(createdAt: String): PostDtoBuilder { | ||
postDto.created_at = createdAt | ||
return this | ||
} | ||
|
||
fun modifiedAt(modifiedAt: String): PostDtoBuilder { | ||
postDto.modified_at = modifiedAt | ||
return this | ||
} | ||
|
||
fun build(): PostDto { | ||
return postDto | ||
} | ||
} |
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
45 changes: 32 additions & 13 deletions
45
...ngboot/src/main/kotlin/com/goliath/emojihub/springboot/domain/reaction/dto/ReactionDto.kt
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,24 +1,43 @@ | ||
package com.goliath.emojihub.springboot.domain.reaction.dto | ||
|
||
import kotlin.streams.asSequence | ||
|
||
data class ReactionDto( | ||
var id: String = "", | ||
var created_by: String = "", | ||
var post_id: String = "", | ||
var emoji_id: String = "", | ||
var created_at: String = "" | ||
) { | ||
constructor(username: String, post_id: String, emoji_id: String, dateTime: String) : this() { | ||
val source = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | ||
val outputStrLength: Long = 20 | ||
id = java.util.Random().ints(outputStrLength, 0, source.length) | ||
.asSequence() | ||
.map(source::get) | ||
.joinToString("") | ||
created_by = username | ||
this.post_id = post_id | ||
this.emoji_id = emoji_id | ||
created_at = dateTime | ||
) | ||
|
||
class ReactionDtoBuilder { | ||
private val reactionDto: ReactionDto = ReactionDto() | ||
|
||
fun id(id: String): ReactionDtoBuilder { | ||
reactionDto.id = id | ||
return this | ||
} | ||
|
||
fun createdBy(createdBy: String): ReactionDtoBuilder { | ||
reactionDto.created_by = createdBy | ||
return this | ||
} | ||
|
||
fun postId(postId: String): ReactionDtoBuilder { | ||
reactionDto.post_id = postId | ||
return this | ||
} | ||
|
||
fun emojiId(emojiId: String): ReactionDtoBuilder { | ||
reactionDto.emoji_id = emojiId | ||
return this | ||
} | ||
|
||
fun createdAt(createdAt: String): ReactionDtoBuilder { | ||
reactionDto.created_at = createdAt | ||
return this | ||
} | ||
|
||
fun build(): ReactionDto { | ||
return reactionDto | ||
} | ||
} |
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
Oops, something went wrong.