diff --git a/src/main/java/dev/surl/surl/dao/UserAccess.kt b/src/main/java/dev/surl/surl/dao/UserAccess.kt index 07e7efb..acdb9b6 100644 --- a/src/main/java/dev/surl/surl/dao/UserAccess.kt +++ b/src/main/java/dev/surl/surl/dao/UserAccess.kt @@ -1,6 +1,5 @@ package dev.surl.surl.dao -import dev.surl.surl.common.Access import dev.surl.surl.dsl.UserAccesses import org.jetbrains.exposed.dao.LongEntity import org.jetbrains.exposed.dao.LongEntityClass @@ -19,11 +18,7 @@ class UserAccess(id: EntityID): LongEntity(id) { /** * 权限,枚举类型,自动转换为数据库存储的整数 */ - var access by UserAccesses.access.transform(toColumn = { - it.ordinal.toShort() - }, toReal = { - Access.entries[it.toInt()] - }) + var access by UserAccesses.access /** * 用户 diff --git a/src/main/java/dev/surl/surl/dsl/UserAccesses.kt b/src/main/java/dev/surl/surl/dsl/UserAccesses.kt index 1313846..c8a8e90 100644 --- a/src/main/java/dev/surl/surl/dsl/UserAccesses.kt +++ b/src/main/java/dev/surl/surl/dsl/UserAccesses.kt @@ -1,5 +1,6 @@ package dev.surl.surl.dsl +import dev.surl.surl.common.Access import org.jetbrains.exposed.dao.id.IdTable /** @@ -8,5 +9,9 @@ import org.jetbrains.exposed.dao.id.IdTable object UserAccesses: IdTable("user_access") { override val id = long("id").entityId() val user = reference("user", Users).index() - val access = short("access") + val access = short("access").transform(unwrap = { + it.ordinal.toShort() + }, wrap = { + Access.entries[it.toInt()] + }) } \ No newline at end of file