使用新的列转换方式
This commit is contained in:
parent
273a791fdf
commit
dcbccaabca
@ -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<Long>): LongEntity(id) {
|
||||
/**
|
||||
* 权限,枚举类型,自动转换为数据库存储的整数
|
||||
*/
|
||||
var access by UserAccesses.access.transform(toColumn = {
|
||||
it.ordinal.toShort()
|
||||
}, toReal = {
|
||||
Access.entries[it.toInt()]
|
||||
})
|
||||
var access by UserAccesses.access
|
||||
|
||||
/**
|
||||
* 用户
|
||||
|
@ -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<Long>("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()]
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user