feat: improved SubscriptionRepository
This commit is contained in:
parent
5a39f49824
commit
613d16ef62
1 changed files with 31 additions and 0 deletions
|
@ -46,6 +46,27 @@ object SubscriptionRepository {
|
|||
return dataList
|
||||
}
|
||||
|
||||
fun getAllChannel(channelId: Long): List<SubscriptionData> {
|
||||
val dataList = mutableListOf<SubscriptionData>()
|
||||
transaction {
|
||||
SubscriptionsTable.select {
|
||||
SubscriptionsTable.channelId eq channelId
|
||||
}.forEach {
|
||||
dataList.add(
|
||||
SubscriptionData(
|
||||
it[SubscriptionsTable.id],
|
||||
it[SubscriptionsTable.serverId],
|
||||
it[SubscriptionsTable.channelId],
|
||||
EmbedUtil.getColorFromString(it[SubscriptionsTable.subscriptionColor]),
|
||||
it[SubscriptionsTable.subscriptionName],
|
||||
it[SubscriptionsTable.feedUrl]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
return dataList
|
||||
}
|
||||
|
||||
|
||||
fun get(channelId: Long, feedName: String): SubscriptionData? {
|
||||
var data: SubscriptionData? = null
|
||||
|
@ -66,6 +87,16 @@ object SubscriptionRepository {
|
|||
return data
|
||||
}
|
||||
|
||||
fun existsWithUrl(channelId: Long, feedUrl: String): Boolean {
|
||||
var exists = false
|
||||
transaction {
|
||||
exists = SubscriptionsTable.select {
|
||||
(SubscriptionsTable.channelId eq channelId) and (SubscriptionsTable.feedUrl eq feedUrl)
|
||||
}.count() > 0
|
||||
}
|
||||
return exists
|
||||
}
|
||||
|
||||
fun exists(channelId: Long, feedName: String): Boolean {
|
||||
var exists = false
|
||||
transaction {
|
||||
|
|
Loading…
Reference in a new issue