You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.8 KiB
70 lines
1.8 KiB
package com.gyf.csams
|
|
|
|
import org.jetbrains.exposed.dao.IntEntity
|
|
import org.jetbrains.exposed.dao.IntEntityClass
|
|
import org.jetbrains.exposed.dao.id.EntityID
|
|
import org.jetbrains.exposed.dao.id.IntIdTable
|
|
import org.jetbrains.exposed.sql.Column
|
|
import org.jetbrains.exposed.sql.`java-time`.datetime
|
|
import java.time.LocalDateTime
|
|
|
|
/**
|
|
* 用户
|
|
*/
|
|
object Users: IntIdTable(){
|
|
/**
|
|
* 学号
|
|
*/
|
|
val studentId:Column<String> = varchar(name="student_id",length = 8).uniqueIndex()
|
|
/**
|
|
* 姓名
|
|
*/
|
|
val name:Column<String> = varchar(name="name",length = 10)
|
|
|
|
/**
|
|
* 密码,hash加密
|
|
*/
|
|
val password:Column<String> = varchar(name="password",length = 32)
|
|
}
|
|
|
|
class User(id:EntityID<Int>):IntEntity(id){
|
|
companion object : IntEntityClass<User>(Users)
|
|
var studentId by Users.studentId
|
|
var name by Users.name
|
|
var password by Users.password
|
|
}
|
|
|
|
/**
|
|
* 用户授权令牌
|
|
*/
|
|
object UserTokens: IntIdTable(){
|
|
/**
|
|
* 授权学号
|
|
*/
|
|
val studentId:Column<String> = reference("student_id",Users.studentId)
|
|
/**
|
|
* 令牌
|
|
*/
|
|
val token:Column<String> = varchar(name="token",length = 32)
|
|
/**
|
|
* 授权ip地址
|
|
*/
|
|
val ip:Column<String> = varchar(name="ip",length = 32)
|
|
/**
|
|
* 令牌创建时间
|
|
*/
|
|
val createTime:Column<LocalDateTime> = datetime("create_time").default(LocalDateTime.now())
|
|
/**
|
|
* 授权设备
|
|
*/
|
|
val device:Column<String> = varchar(name="device",length = 256)
|
|
}
|
|
|
|
class UserToken(id:EntityID<Int>):IntEntity(id){
|
|
companion object:IntEntityClass<UserToken>(UserTokens)
|
|
var studentId by UserTokens.studentId
|
|
var token by UserTokens.token
|
|
var ip by UserTokens.ip
|
|
var createTime by UserTokens.createTime
|
|
var device by UserTokens.device
|
|
} |