Skip to content

Commit

Permalink
fix: 修复错误
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Sep 15, 2024
1 parent 292de7c commit 05c9ad1
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/main/kotlin/subit/console/command/TestDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ object TestDatabase: Command, KoinComponent
"Prohibits" to dao<Prohibits>(),
"Reports" to dao<Reports>(),
"Stars" to dao<Stars>(),
"Tags" to dao<Tags>(),
"Users" to dao<Users>(),
"WordMarkings" to dao<WordMarkings>(),
)
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/subit/dataClasses/Post.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package subit.dataClasses
import kotlinx.serialization.Serializable
import org.koin.core.component.KoinComponent
import subit.dataClasses.PostFullBasicInfo.Companion.SUB_CONTENT_LENGTH
import subit.database.Tags

@Serializable
data class PostVersionInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ object MemoryDatabaseImpl: IDatabase, KoinComponent
singleOf(::ProhibitsImpl).bind<Prohibits>()
singleOf(::ReportsImpl).bind<Reports>()
singleOf(::StarsImpl).bind<Stars>()
singleOf(::TagsImpl).bind<Tags>()
singleOf(::UsersImpl).bind<Users>()
singleOf(::WordMarkingsImpl).bind<WordMarkings>()
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/subit/database/memoryImpl/PostsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PostsImpl: Posts, KoinComponent
parent: PostId?,
state: State,
top: Boolean
): PostId?
): PostId
{
val id = (map.size + 1).toPostId()
map[id] = PostInfo(
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/subit/database/sqlImpl/BannedWordsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.update
import subit.dataClasses.Slice
import subit.dataClasses.Slice.Companion.asSlice
import subit.database.BannedWords
import subit.database.sqlImpl.utils.asSlice

Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/subit/database/sqlImpl/PostVersionsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import org.jetbrains.exposed.sql.kotlin.datetime.timestamp
import org.koin.core.component.KoinComponent
import subit.dataClasses.*
import subit.dataClasses.Slice
import subit.dataClasses.Slice.Companion.asSlice
import subit.database.sqlImpl.utils.singleOrNull
import subit.database.PostVersions
import subit.database.sqlImpl.utils.asSlice
import subit.database.sqlImpl.utils.singleOrNull

class PostVersionsImpl: DaoSqlImpl<PostVersionsImpl.PostVersionsTable>(PostVersionsTable), PostVersions, KoinComponent
{
Expand Down
5 changes: 1 addition & 4 deletions src/main/kotlin/subit/database/sqlImpl/PostsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlinx.datetime.Instant
import org.intellij.lang.annotations.Language
import org.jetbrains.exposed.dao.id.IdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.coalesce
import org.jetbrains.exposed.sql.SqlExpressionBuilder.div
import org.jetbrains.exposed.sql.SqlExpressionBuilder.minus
import org.jetbrains.exposed.sql.SqlExpressionBuilder.plus
Expand All @@ -22,18 +21,16 @@ import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import subit.dataClasses.*
import subit.dataClasses.Slice
import subit.dataClasses.Slice.Companion.asSlice
import subit.database.sqlImpl.utils.singleOrNull
import subit.database.*
import subit.database.Posts.PostListSort.*
import subit.database.sqlImpl.PostVersionsImpl.PostVersionsTable
import subit.database.sqlImpl.PostsImpl.PostsTable.view
import subit.database.sqlImpl.utils.asSlice
import subit.database.sqlImpl.utils.singleOrNull
import subit.router.home.AdvancedSearchData
import subit.utils.toInstant
import subit.utils.toTimestamp
import java.sql.ResultSet
import java.time.OffsetDateTime
import kotlin.reflect.typeOf
import kotlin.time.Duration.Companion.days

Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/subit/database/sqlImpl/PrivateChatsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import org.jetbrains.exposed.sql.kotlin.datetime.CurrentTimestamp
import org.jetbrains.exposed.sql.kotlin.datetime.timestamp
import subit.dataClasses.PrivateChat
import subit.dataClasses.Slice
import subit.dataClasses.Slice.Companion.asSlice
import subit.database.sqlImpl.utils.singleOrNull
import subit.dataClasses.UserId
import subit.database.PrivateChats
import subit.database.sqlImpl.utils.asSlice
import subit.database.sqlImpl.utils.singleOrNull

class PrivateChatsImpl: DaoSqlImpl<PrivateChatsImpl.PrivateChatsTable>(PrivateChatsTable), PrivateChats
{
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/subit/database/sqlImpl/ProhibitsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.jetbrains.exposed.sql.kotlin.datetime.timestamp
import org.jetbrains.exposed.sql.selectAll
import subit.dataClasses.Prohibit
import subit.dataClasses.Slice
import subit.dataClasses.Slice.Companion.asSlice
import subit.dataClasses.UserId
import subit.database.Prohibits
import subit.database.sqlImpl.utils.asSlice
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/subit/database/sqlImpl/StarsImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.jetbrains.exposed.sql.kotlin.datetime.CurrentTimestamp
import org.jetbrains.exposed.sql.kotlin.datetime.timestamp
import subit.dataClasses.PostId
import subit.dataClasses.Slice
import subit.dataClasses.Slice.Companion.asSlice
import subit.dataClasses.Star
import subit.dataClasses.UserId
import subit.database.Stars
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/subit/router/Comment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ private suspend fun Context.commentPost()
val posts = get<Posts>()

val parent = posts.getPostInfo(postId) ?: return call.respond(HttpStatus.NotFound.subStatus("目标帖子不存在"))
withPermission { checkCanComment(parent) }
val block = get<Blocks>().getBlock(parent.block) ?: return call.respond(HttpStatus.NotFound.subStatus("目标板块不存在"))
withPermission {
checkCanComment(parent)
if (newComment.anonymous) checkCanAnonymous(block)
}

val commentId = posts.createPost(
parent = postId,
Expand Down
6 changes: 4 additions & 2 deletions src/main/kotlin/subit/router/Tag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

package subit.router.tags

import io.github.smiley4.ktorswaggerui.dsl.routing.*
import io.github.smiley4.ktorswaggerui.dsl.routing.delete
import io.github.smiley4.ktorswaggerui.dsl.routing.get
import io.github.smiley4.ktorswaggerui.dsl.routing.post
import io.github.smiley4.ktorswaggerui.dsl.routing.route
import io.ktor.server.application.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import kotlinx.serialization.Serializable
import subit.dataClasses.PostId
Expand Down

0 comments on commit 05c9ad1

Please sign in to comment.