From dcbccaabca90f31f4537d85af38dfa68f4b0e7b4 Mon Sep 17 00:00:00 2001 From: 05412 Date: Mon, 5 Aug 2024 15:10:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=96=B0=E7=9A=84=E5=88=97?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/dev/surl/surl/dao/UserAccess.kt | 7 +------ src/main/java/dev/surl/surl/dsl/UserAccesses.kt | 7 ++++++- 2 files changed, 7 insertions(+), 7 deletions(-) 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