72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
import { DateTime } from 'luxon'
|
|
import { BaseModel, belongsTo, column, hasMany } from '@adonisjs/lucid/orm'
|
|
import User from './user.js'
|
|
import type { BelongsTo, HasMany } 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
|
|
|
|
@belongsTo(() => User, { foreignKey: 'studentId' })
|
|
declare student: BelongsTo<typeof User>
|
|
|
|
@column({ serializeAs: null })
|
|
declare studentId: number
|
|
|
|
@belongsTo(() => Examiner)
|
|
declare examiner: BelongsTo<typeof Examiner>
|
|
|
|
@column({ serializeAs: null })
|
|
declare examinerId: number
|
|
|
|
// @computed()
|
|
// get examinerName(): string {
|
|
// return this.examiner?.name
|
|
// }
|
|
|
|
// Bjcolle data
|
|
@column({ serializeAs: null })
|
|
declare bjsecret: string
|
|
|
|
@column({ serializeAs: null })
|
|
declare bjid: string
|
|
|
|
// Colle data
|
|
@belongsTo(() => Subject)
|
|
declare subject: BelongsTo<typeof Subject>
|
|
|
|
@column({ serializeAs: null })
|
|
declare subjectId: number
|
|
|
|
@belongsTo(() => Room)
|
|
declare room: BelongsTo<typeof Room>
|
|
|
|
@column({ serializeAs: null })
|
|
declare roomId: number
|
|
|
|
@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
|
|
}
|