mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-08-07 21:01:14 +00:00
add POST /user endpoints.
- POST /user {"chzzkUrl": String} to add chzzk account to bots. - and it post event UserRegisterEvent
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package space.mori.chzzk_bot.common.events
|
||||
|
||||
data class UserRegisterEvent(
|
||||
val chzzkId: String
|
||||
): Event {
|
||||
val TAG = javaClass.simpleName
|
||||
}
|
@@ -7,16 +7,31 @@ import space.mori.chzzk_bot.common.models.User
|
||||
import space.mori.chzzk_bot.common.models.Users
|
||||
|
||||
object UserService {
|
||||
fun saveUser(username: String, token: String, discordID: Long): User {
|
||||
fun saveUser(username: String, naverId: String): User {
|
||||
return transaction {
|
||||
User.new {
|
||||
this.username = username
|
||||
this.token = token
|
||||
this.discord = discordID
|
||||
this.naverId = naverId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateUser(user: User, chzzkId: String, username: String): User {
|
||||
return transaction {
|
||||
user.token = chzzkId
|
||||
user.username = username
|
||||
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
fun updateUser(user: User, discordID: Long): User {
|
||||
return transaction {
|
||||
user.discord = discordID
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
fun getUser(id: Int): User? {
|
||||
return transaction {
|
||||
User.findById(id)
|
||||
|
Reference in New Issue
Block a user