Skip to content

Commit

Permalink
feat:增加dbConvertor模块,实现hoj-problem表
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoyuanyu committed Nov 1, 2024
1 parent 526c47b commit 1431444
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dbConvertor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cn.kzoj.dbConvertor

dbConvertor模块用于从hoj数据库迁移到kzoj数据库
23 changes: 23 additions & 0 deletions dbConvertor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
kotlin("jvm") version libs.versions.kotlin
}

group = "cn.kzoj"
version = "0.0.1"

repositories {
mavenCentral()
}

dependencies {
dependencies {
implementation(project(":dto"))
implementation(project(":persistence"))

implementation(libs.bundles.exposed)
implementation(libs.hikaricp)
implementation(libs.kotlinx.datetime)
implementation(libs.logback.classic)
implementation(libs.mysql.connector)
}
}
5 changes: 5 additions & 0 deletions dbConvertor/src/main/kotlin/cn/kzoj/dbConvertor/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cn.kzoj.dbConvertor

fun main(args: Array<String>) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package cn.kzoj.dbConvertor.hojData

fun configureDatabase() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package cn.kzoj.dbConvertor.hojData.problem

import org.jetbrains.exposed.dao.IntEntity
import org.jetbrains.exposed.dao.IntEntityClass
import org.jetbrains.exposed.dao.id.EntityID

@Suppress("Unused")
class ProblemDAO(id: EntityID<Int>) : IntEntity(id) {
companion object: IntEntityClass<ProblemDAO>(ProblemTable)

var problemId by ProblemTable.problemId
var title by ProblemTable.title
var author by ProblemTable.author
var problemType by ProblemTable.problemType
var timeLimit by ProblemTable.timeLimit
var memoryLimit by ProblemTable.memoryLimit
var stackLimit by ProblemTable.stackLimit
var problemDescription by ProblemTable.problemDescription
var inputDescription by ProblemTable.inputDescription
var outputDescription by ProblemTable.outputDescription
var examples by ProblemTable.examples
var isRemoteJudge by ProblemTable.isRemoteJudge
var problemSource by ProblemTable.problemSource
var difficulty by ProblemTable.difficulty
var hint by ProblemTable.hint
var authority by ProblemTable.authority
var oiScore by ProblemTable.oiScore
var isCodeSharable by ProblemTable.isCodeSharable
var judgeMode by ProblemTable.judgeMode
var judgeCaseMode by ProblemTable.judgeCaseMode
var spjCode by ProblemTable.spjCode
var spjLanguage by ProblemTable.spjLanguage
var removeEndBlankChar by ProblemTable.removeEndBlankChar
var openCaseResult by ProblemTable.openCaseResult
var isCaseUploaded by ProblemTable.isCaseUploaded
var caseVersion by ProblemTable.caseVersion
var lastModifiedByUser by ProblemTable.lastModifiedByUser
var isInGroup by ProblemTable.isInGroup
var groupId by ProblemTable.groupId
var dateCreated by ProblemTable.dateCreated
var dateLastModified by ProblemTable.dateLastModified
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cn.kzoj.dbConvertor.hojData.problem

import kotlinx.datetime.LocalDateTime
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.Column
import org.jetbrains.exposed.sql.kotlin.datetime.datetime

object ProblemTable: IntIdTable("problem_") {

val problemId: Column<String> = text("problem_id")

val title: Column<String> = text("title")

val author: Column<String> = text("author")

val problemType: Column<Int> = integer("problem_type")

val timeLimit: Column<Long> = long("time_limit")

val memoryLimit: Column<Long> = long("memory_limit")

val stackLimit: Column<Long> = long("stack_limit")

val problemDescription: Column<String> = text("problem_description")

val inputDescription: Column<String> = text("input_description")

val outputDescription: Column<String> = text("output_description")

val examples: Column<String> = text("examples")

val isRemoteJudge: Column<Boolean> = bool("is_remote_judge")

val problemSource: Column<String> = text("problem_source")

val difficulty: Column<Int> = integer("difficulty")

val hint: Column<String> = text("hint")

val authority: Column<Int> = integer("authority")

val oiScore: Column<Int> = integer("oi_score")

val isCodeSharable: Column<Boolean> = bool("is_code_sharable")

val judgeMode: Column<String> = text("judge_mode")

val judgeCaseMode: Column<String> = text("judge_case_mode")

val spjCode: Column<String?> = text("spj_code").nullable()

val spjLanguage: Column<String?> = text("spj_language").nullable()

val removeEndBlankChar: Column<Boolean> = bool("remove_end_blank_char")

val openCaseResult: Column<Boolean> = bool("open_case_result")

val isCaseUploaded: Column<Boolean> = bool("is_case_uploaded")

val caseVersion: Column<String> = text("case_version")

val lastModifiedByUser: Column<String> = text("last_modified_by_user")

val isInGroup: Column<Boolean> = bool("is_in_group")

val groupId: Column<Int?> = integer("group_id").nullable()

val dateCreated: Column<LocalDateTime> = datetime("date_created")

val dateLastModified: Column<LocalDateTime> = datetime("date_last_modified")
}
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ plugins {
}
rootProject.name = "KZOJ"

include("app", "dto", "judge", "persistence")
include("app", "dto", "judge", "persistence")
include("dbConvertor")

0 comments on commit 1431444

Please sign in to comment.