-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a71cac7
commit 6f42eb4
Showing
13 changed files
with
81 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mz2mo.domain.emoji | ||
|
||
data class Emoji( | ||
val id: String, | ||
val emoji: String, | ||
val name: String, | ||
val usable: Boolean | ||
) |
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.mz2mo.domain.vote | ||
|
||
data class CreateVote( | ||
val emojiId: String, | ||
val userId: String, | ||
val musicId: String | ||
) |
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,5 @@ | ||
package com.mz2mo.domain.vote | ||
|
||
fun interface QueryVoteUseCase { | ||
fun getVotes(musicId: String): List<Vote> | ||
} |
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,8 @@ | ||
package com.mz2mo.domain.vote | ||
|
||
data class Vote( | ||
val id: String, | ||
val emojiId: String, | ||
val userId: String, | ||
val musicId: String | ||
) |
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,25 @@ | ||
package com.mz2mo.domain.vote | ||
|
||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.PostMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/votes") | ||
class VoteController( | ||
private val voteService: VoteService | ||
) { | ||
@PostMapping | ||
fun vote(createVote: CreateVote): Vote { | ||
return voteService.vote(createVote) | ||
} | ||
|
||
@GetMapping("/by-music/{musicId}") | ||
fun getVotes( | ||
@PathVariable("musicId") musicId: String | ||
): List<Vote> { | ||
return voteService.getVotes(musicId) | ||
} | ||
} |
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.mz2mo.domain.vote | ||
|
||
import org.springframework.stereotype.Service | ||
import java.util.UUID | ||
|
||
@Service | ||
class VoteService : QueryVoteUseCase, VoteUseCase { | ||
private val votes = mutableListOf<Vote>() | ||
|
||
override fun getVotes(musicId: String): List<Vote> = | ||
votes.filter { it.musicId == musicId } | ||
|
||
override fun vote(createVote: CreateVote): Vote { | ||
val vote = Vote( | ||
id = UUID.randomUUID().toString(), | ||
emojiId = createVote.emojiId, | ||
userId = createVote.userId, | ||
musicId = createVote.musicId | ||
) | ||
votes.add(vote) | ||
return vote | ||
} | ||
} |
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,5 @@ | ||
package com.mz2mo.domain.vote | ||
|
||
fun interface VoteUseCase { | ||
fun vote(createVote: CreateVote): Vote | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.