55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
import { DateTime } from 'luxon'
|
|
import { BaseModel, column, hasMany, hasOne } from '@adonisjs/lucid/orm'
|
|
import User from './user.js'
|
|
import type { HasMany, HasOne } from '@adonisjs/lucid/types/relations'
|
|
import Subject from './subject.js'
|
|
import Room from './room.js'
|
|
import ColleAttachment from './colle_attachment.js'
|
|
import Examiner from './examiner.js'
|
|
|
|
export default class Colle extends BaseModel {
|
|
@column({ isPrimary: true })
|
|
declare id: number
|
|
|
|
@hasOne(() => User)
|
|
declare student: HasOne<typeof User>
|
|
|
|
@hasOne(() => Examiner)
|
|
declare examiner: HasOne<typeof Examiner>
|
|
|
|
// Bjcolle data
|
|
@column()
|
|
declare bjsecret: string
|
|
|
|
@column()
|
|
declare bjid: string
|
|
|
|
// Colle data
|
|
@hasOne(() => Subject)
|
|
declare subject: HasOne<typeof Subject>
|
|
|
|
@hasOne(() => Room)
|
|
declare room: HasOne<typeof Room>
|
|
|
|
@column()
|
|
declare grade: number
|
|
|
|
@column()
|
|
declare content: string
|
|
|
|
@column()
|
|
declare comment: string
|
|
|
|
@hasMany(() => ColleAttachment)
|
|
declare attachments: HasMany<typeof ColleAttachment>
|
|
|
|
// Time data
|
|
@column.dateTime()
|
|
declare date: DateTime
|
|
|
|
@column.dateTime({ autoCreate: true })
|
|
declare createdAt: DateTime
|
|
|
|
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
|
declare updatedAt: DateTime
|
|
}
|