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`.CurrentDateTime import org.jetbrains.exposed.sql.`java-time`.CurrentTimestamp import org.jetbrains.exposed.sql.`java-time`.datetime import java.time.LocalDateTime @TableComment("用户") object Users: IntIdTable(){ @TableComment("学号") val studentId:Column = varchar(name="student_id",length = 8).uniqueIndex() @TableComment("姓名") val name:Column = varchar(name="name",length = 10) @TableComment("密码") val password:Column = varchar(name="password",length = 32) } class User(id:EntityID):IntEntity(id){ companion object : IntEntityClass(Users) var studentId by Users.studentId var name by Users.name var password by Users.password } @TableComment("用户授权令牌") object UserTokens: IntIdTable(){ @TableComment("授权用户") val userId:Column> = reference("user_id",Users) @TableComment("令牌") val token:Column = varchar(name="token",length = 32) @TableComment("授权ip地址") val ip:Column = varchar(name="ip",length = 32) @TableComment("令牌创建时间") val createTime:Column = datetime("create_time").defaultExpression(CurrentTimestamp()) @TableComment("授权设备") val device:Column = varchar(name="device",length = 256) } class UserToken(id:EntityID):IntEntity(id){ companion object:IntEntityClass(UserTokens) var user by User referencedOn UserTokens.userId var token by UserTokens.token var ip by UserTokens.ip var createTime by UserTokens.createTime var device by UserTokens.device } @TableComment("留言") object LeaveMessages:IntIdTable(){ @TableComment("留言用户") val userId:Column> = reference("user_id",Users) @TableComment("留言内容") val message:Column = varchar(name = "message",length = 20) @TableComment("留言创建时间") val createTime:Column = datetime("create_time").defaultExpression(CurrentDateTime()) } class LeaveMessage(id:EntityID):IntEntity(id){ companion object:IntEntityClass(LeaveMessages) var user by User referencedOn LeaveMessages.userId var message by LeaveMessages.message var createTime by LeaveMessages.createTime } @TableComment("图片文件信息") object ImageFiles:IntIdTable(){ @TableComment("上传用户") val userId:Column = varchar(name = "user_id",length = 10) @TableComment("文件相对路径") val filepath:Column = varchar(name="filepath",length = 50) @TableComment("文件hash") val md5:Column = varchar(name="md5",length = 32) @TableComment("文件创建时间") val createTime:Column = datetime("create_time").defaultExpression(CurrentDateTime()) } class ImageFile(id:EntityID):IntEntity(id){ companion object:IntEntityClass(ImageFiles) var userId by ImageFiles.userId var filepath by ImageFiles.filepath var md5 by ImageFiles.md5 var createTime by ImageFiles.createTime } @TableComment("社团") object Associations:IntIdTable(){ @TableComment("社团名称") val name:Column =varchar(name = "name",length = 10) @TableComment("社团介绍") val desc:Column =varchar(name = "desc",length = 30) @TableComment("社团logo") val logo:Column> = reference("logo",ImageFiles) @TableComment("社团审核状态") val status:Column = bool(name="status").default(false) } class Association(id:EntityID):IntEntity(id){ companion object:IntEntityClass(Associations) var name by Associations.name var desc by Associations.desc var logo by ImageFile referencedOn Associations.logo var status by Associations.status } @TableComment("后台管理员") object Managers:IntIdTable(){ @TableComment("帐号") val account:Column = varchar(name="account",length=10) @TableComment("密码") val password:Column = varchar(name="password",length = 32) @TableComment("职务") val duty:Column = varchar(name="duty",length = 32) @TableComment("等级") val level:Column = integer("level") } class Manager(id:EntityID):IntEntity(id){ companion object:IntEntityClass(Managers) var account by Managers.account var password by Managers.password var duty by Managers.duty var level by Managers.level } @TableComment("审核记录") object CheckForms:IntIdTable(){ @TableComment("审核类型") val type:Column = varchar(name="type",length = 10) @TableComment("审核人") val managerId:Column> = reference("manager_id",Managers) @TableComment("审核理由") val cause:Column = varchar("cause",length = 30) @TableComment("审核对象") val target:Column = integer("target") @TableComment("审核时间") val createTime:Column = datetime("create_time").defaultExpression(CurrentDateTime()) } class CheckForm(id:EntityID):IntEntity(id){ companion object:IntEntityClass(CheckForms) var type by CheckForms.type val manager by Manager referrersOn CheckForms.managerId var cause by CheckForms.cause var target by CheckForms.target } @TableComment("通知记录") object Notifications:IntIdTable(){ @TableComment("通知标题") val title:Column = varchar(name="title",length = 10) @TableComment("通知内容") val content:Column = varchar(name="content",length = 30) @TableComment("接收者") val receiverId:Column = integer(name="receiver_id") @TableComment("接收客户端") val receiverClient:Column = varchar(name="receiver_client",length = 10) @TableComment("阅读状态") val read:Column = bool("read").default(false) @TableComment("拉取状态") val pull:Column = bool("pull").default(false) @TableComment("通知创建时间") val createTime:Column = datetime("create_time").defaultExpression(CurrentDateTime()) } class Notification(id:EntityID):IntEntity(id){ companion object:IntEntityClass(Notifications) var title by Notifications.title var content by Notifications.content var receiverId by Notifications.receiverId var receiverClient by Notifications.receiverClient var read by Notifications.read var pull by Notifications.pull var createTime by Notifications.createTime }