File size: 25,313 Bytes
ab82ffd
 
 
987726a
 
ab82ffd
 
987726a
ab82ffd
 
 
987726a
 
 
0722970
987726a
 
 
 
 
132b9f0
ebcbdce
ab82ffd
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
 
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
 
 
987726a
 
 
 
 
 
 
 
 
b03de03
ebcbdce
1db0b85
987726a
ab82ffd
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
 
 
5d4252b
 
 
 
ebcbdce
ab82ffd
 
 
 
 
c0722d3
 
 
 
 
 
5d4252b
 
 
ebcbdce
ab82ffd
 
 
 
c0722d3
 
 
92a54e4
 
 
c0722d3
 
 
 
 
 
 
92a54e4
 
 
 
 
 
 
c0722d3
 
 
 
5d4252b
 
 
 
 
 
 
 
 
 
 
 
 
ab82ffd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
50f4397
ab82ffd
99b262f
 
ab82ffd
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
 
 
5d4252b
51688a8
ab82ffd
 
 
 
 
 
5d4252b
ab82ffd
 
 
 
 
 
 
 
5d4252b
51688a8
ab82ffd
 
 
 
853717a
ab82ffd
 
 
 
5d4252b
ab82ffd
132b9f0
 
 
 
 
 
 
 
d0e1b44
 
 
 
 
 
 
5d4252b
51688a8
ab82ffd
 
 
 
5d4252b
ab82ffd
 
 
 
 
 
 
 
 
 
5d4252b
ab82ffd
 
51688a8
ab82ffd
 
853717a
ab82ffd
 
 
 
 
51688a8
5fc40a1
 
 
 
 
 
 
 
c32f786
c0722d3
51688a8
b03de03
ebcbdce
ab82ffd
 
 
 
 
51688a8
ab82ffd
 
 
 
 
 
38100fe
c32f786
b03de03
ebcbdce
ab82ffd
 
 
 
 
51688a8
ab82ffd
 
 
 
c32f786
b03de03
ebcbdce
ab82ffd
 
 
 
 
 
 
aa6ea88
5fc40a1
 
38100fe
 
 
ab82ffd
 
 
 
 
 
aa6ea88
5fc40a1
 
 
38100fe
 
 
ab82ffd
 
 
 
 
 
aa6ea88
5fc40a1
 
 
 
38100fe
ab82ffd
 
 
 
483bf6a
5fc40a1
51688a8
5fc40a1
 
 
 
 
 
 
 
 
483bf6a
51688a8
38100fe
 
 
 
 
 
 
 
 
 
 
 
 
5d4252b
51688a8
5fc40a1
 
 
 
38100fe
 
5d4252b
38100fe
5d4252b
51688a8
5fc40a1
 
 
 
5d4252b
5fc40a1
 
38100fe
 
5d4252b
38100fe
5d4252b
51688a8
5fc40a1
 
 
 
5d4252b
5fc40a1
 
 
 
 
 
 
 
38100fe
 
5d4252b
38100fe
5d4252b
51688a8
5fc40a1
 
5d4252b
38100fe
 
5d4252b
c0722d3
 
 
 
 
9fea8b6
c0722d3
 
 
 
 
 
 
 
 
 
 
 
 
 
9fea8b6
c0722d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
package models

import (
	"time"

	"github.com/google/uuid"
	"github.com/lib/pq"
	"gorm.io/gorm"
)

type Account struct {
	Id                uuid.UUID      `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	Username          string         `gorm:"uniqueIndex" json:"username,omitempty"`
	Email             string         `gorm:"uniqueIndex" json:"email,omitempty"`
	FullName          *string        `json:"full_name,omitempty" gorm:"-"`
	Role              string         `json:"role,omitempty"`
	Password          string         `json:"-"`
	IsEmailVerified   bool           `json:"is_email_verified,omitempty"`
	IsDetailCompleted bool           `json:"is_detail_completed,omitempty"`
	CreatedAt         time.Time      `json:"created_at,omitempty"`
	AccountDetail     *AccountDetail `gorm:"foreignKey:AccountId;references:Id" json:"-"`
	DeletedAt         gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
}

func (Account) TableName() string { return "account" }

type AccountDetail struct {
	Id          uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AccountId   uuid.UUID `json:"account_id,omitempty"`
	FullName    *string   `json:"full_name,omitempty"`
	SchoolName  *string   `json:"school_name,omitempty"`
	Province    *string   `json:"province,omitempty"`
	City        *string   `json:"city,omitempty"`
	Avatar      *string   `json:"avatar,omitempty"`
	PhoneNumber *string   `json:"phone_number,omitempty"`
	Account     *Account  `gorm:"foreignKey:AccountId" json:"account,omitempty"`
}

func (AccountDetail) TableName() string { return "account_details" }

type EmailVerification struct {
	Id        uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	Token     uint      `json:"token,omitempty"`
	AccountId uuid.UUID `json:"account_id,omitempty"`
	IsExpired bool      `json:"is_expired,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	ExpiredAt time.Time `json:"expired_at,omitempty"`
	Account   *Account  `gorm:"foreignKey:AccountId" json:"account,omitempty"`
}

func (EmailVerification) TableName() string { return "email_verification" }

type ExternalAuth struct {
	Id            uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	OauthID       string    `json:"oauth_id,omitempty"`
	AccountId     uuid.UUID `json:"account_id,omitempty"`
	OauthProvider string    `json:"oauth_provider,omitempty"`
}

func (ExternalAuth) TableName() string { return "external_auth" }

type FCM struct {
	Id        uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AccountId uuid.UUID `json:"account_id,omitempty"`
	FCMToken  string    `json:"fcm_token,omitempty"`
}

func (FCM) TableName() string { return "fcm" }

type ForgotPassword struct {
	Id        uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	Token     uint      `json:"token,omitempty"`
	AccountId uuid.UUID `json:"account_id,omitempty"`
	IsExpired bool      `json:"is_expired,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	ExpiredAt time.Time `json:"expired_at,omitempty"`
}

func (ForgotPassword) TableName() string { return "forgot_password" }

type Events struct {
	Id             uuid.UUID      `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_event"`
	Title          string         `json:"title,omitempty"`
	Slug           string         `json:"slug,omitempty"`
	StartEvent     time.Time      `json:"start_event,omitempty"`
	EndEvent       time.Time      `json:"end_event,omitempty"`
	Overview       string         `json:"overview,omitempty"`
	ImgBanner      string         `json:"img_banner,omitempty"`
	EventCode      string         `json:"event_code,omitempty"`
	IsPublic       bool           `json:"is_public,omitempty"`
	CreatedAt      time.Time      `json:"created_at,omitempty"`
	DeletedAt      gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
	Price          float64        `json:"price"`
	RegisterStatus int            `gorm:"-" json:"register_status"`
}

func (Events) TableName() string { return "events" }

type Announcement struct {
	Id        uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_announcement"`
	Title     string    `json:"title,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	Message   string    `json:"message,omitempty"`
	Publisher string    `json:"publisher,omitempty"`
	EventId   uuid.UUID `json:"id_event,omitempty"`
}

func (Announcement) TableName() string { return "announcement" }

type ProblemSet struct {
	Id          uuid.UUID      `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_problem_set"`
	Title       string         `json:"title,omitempty"`
	Description string         `json:"description,omitempty"`
	CreatedAt   time.Time      `json:"created_at,omitempty"`
	DeletedAt   gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
}

func (ProblemSet) TableName() string { return "problem_set" }

type Exam struct {
	Id            uuid.UUID         `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_exam"`
	Slug          string            `json:"slug,omitempty"`
	Title         string            `json:"title,omitempty"`
	Description   string            `json:"description,omitempty"`
	Duration      time.Duration     `json:"duration,omitempty"`
	Randomize     uint              `json:"randomize,omitempty"`
	Configuration ExamConfiguration `gorm:"foreignKey:ExamId;references:Id" json:"configuration,omitempty"`
	Proctoring    ExamProctoring    `gorm:"foreignKey:ExamId;references:Id" json:"proctoring,omitempty"`
	CreatedAt     time.Time         `json:"created_at,omitempty"`
	DeletedAt     gorm.DeletedAt    `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
}

func (Exam) TableName() string { return "exam" }

type ExamConfiguration struct {
	Id          uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_result"`
	ExamId      uuid.UUID `json:"id_exam,omitempty"`
	AllowRetake bool      `json:"allow_retake"`
	AllowReview bool      `json:"allow_review"`
	EnableTimer bool      `json:"enable_timer"`
}

func (ExamConfiguration) TableName() string { return "exam_configuration" }

type ExamProctoring struct {
	Id                 uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_result"`
	ExamId             uuid.UUID `json:"id_exam,omitempty"`
	EnableWebCam       bool      `json:"enable_webcam"`
	EnableVAD          bool      `json:"enable_vad"`
	EnableTabBlock     bool      `json:"enable_tab_block"`
	RequiredFullScreen bool      `json:"enable_full_screen"`
	EnableEyeTracking  bool      `json:"enable_eye_tracking"`
	DisableCopyPaste   bool      `json:"disable_copy_paste"`
	EnableExamBrowser  bool      `json:"enable_exam_browser"`
}

func (ExamProctoring) TableName() string { return "exam_proctoring" }

type EventExamProctoringLogs struct {
	Id                uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_result"`
	EventId           uuid.UUID `json:"id_event,omitempty"`
	ExamId            uuid.UUID `json:"id_exam,omitempty"`
	AccountId         uuid.UUID `json:"id_account,omitempty"`
	ViolationScore    uint      `json:"violation_score,omitempty"`
	ViolationCategory string    `json:"violation_category,omitempty"`
	Attachement       string    `json:"attachement,omitempty"`
	CreatedAt         time.Time `json:"created_at,omitempty"`
}

func (EventExamProctoringLogs) TableName() string { return "exam_event_proctoring_logs" }

type OptionCategory struct {
	Id         uint   `gorm:"primaryKey" json:"id"`
	OptionName string `json:"option_name,omitempty"`
	OptionSlug string `json:"option_slug,omitempty"`
}

func (OptionCategory) TableName() string { return "option_category" }

type OptionValues struct {
	Id               uint   `gorm:"primaryKey" json:"id"`
	OptionCategoryId uint   `json:"option_category_id,omitempty"`
	OptionValue      string `json:"option_value,omitempty"`
}

func (OptionValues) TableName() string { return "option_values" }

type RegionProvince struct {
	Id   uint   `json:"id"`
	Name string `json:"name,omitempty"`
	Code string `json:"code,omitempty"`
}

func (RegionProvince) TableName() string { return "region_provinces" }

type RegionCity struct {
	Id         uint   `json:"id"`
	Type       string `json:"type,omitempty"`
	Name       string `json:"name,omitempty"`
	Code       string `json:"code,omitempty"`
	FullCode   string `json:"full_code,omitempty"`
	ProvinceId uint   `json:"province_id,omitempty"`
}

func (RegionCity) TableName() string { return "region_cities" }

type Options struct {
	OptionCategory OptionCategory `json:"option_category,omitempty"`
	OptionValues   []OptionValues `json:"option_values,omitempty"`
}

func (Options) TableName() string { return "options" }

type EventAssign struct {
	Id         uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_assign"`
	AccountId  uuid.UUID `json:"id_account,omitempty"`
	EventId    uuid.UUID `json:"id_event,omitempty"`
	AssignedAt time.Time `json:"assigned_at,omitempty"`

	Account *Account `gorm:"foreignKey:AccountId" json:"account,omitempty"`
	Event   *Events  `gorm:"foreignKey:EventId" json:"event,omitempty"`
}

func (EventAssign) TableName() string { return "event_assign" }

type Questions struct {
	Id           uuid.UUID      `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_question"`
	Type         string         `json:"type,omitempty"`
	Question     string         `json:"question,omitempty"`
	Options      pq.StringArray `gorm:"type:text[]" json:"options,omitempty"`
	AnsKey       pq.StringArray `gorm:"type:text[]" json:"ans_key,omitempty"`
	CorrMark     float64        `json:"corr_mark,omitempty"`
	IncorrMark   float64        `json:"incorr_mark,omitempty"`
	NullMark     float64        `json:"null_mark,omitempty"`
	CreatedAt    time.Time      `json:"created_at,omitempty"`
	ProblemSetId uuid.UUID      `json:"id_problem_set,omitempty"`
	ProblemSet   *ProblemSet    `gorm:"foreignKey:ProblemSetId" json:"problem_set,omitempty"`
	Solution     string         `json:"solution,omitempty"`
}

func (Questions) TableName() string { return "questions" }

type ProblemSetExamAssign struct {
	Id           uuid.UUID   `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_problem_set_exam_assign"`
	ExamId       uuid.UUID   `json:"id_exam,omitempty"`
	ProblemSetId uuid.UUID   `json:"id_problem_set,omitempty"`
	Exam         *Exam       `gorm:"foreignKey:ExamId" json:"exam,omitempty"`
	ProblemSet   *ProblemSet `gorm:"foreignKey:ProblemSetId" json:"problem_set,omitempty"`
}

func (ProblemSetExamAssign) TableName() string { return "problem_set_exam_assign" }

type EventExamAssign struct {
	Id      uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_exam_event_assign"`
	EventId uuid.UUID `json:"id_event,omitempty"`
	ExamId  uuid.UUID `json:"id_exam,omitempty"`
	Exam    *Exam     `gorm:"foreignKey:ExamId" json:"exam,omitempty"`
	Event   *Events   `gorm:"foreignKey:EventId" json:"event,omitempty"`
}

func (EventExamAssign) TableName() string { return "exam_event_assign" }

type CPQuestionVerdict struct {
	TimeExecution float32 `json:"time_exec"`
	MemoryUsage   float32 `json:"memory"`
	Verdict       string  `json:"verdict"`
	Score         float32 `json:"score"`
}

type EventExamAnswer struct {
	Id               uuid.UUID         `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AttemptId        uuid.UUID         `json:"id_attempt,omitempty" gorm:"index"`
	QuestionId       uuid.UUID         `json:"id_question,omitempty" gorm:"index"`
	Answers          pq.StringArray    `gorm:"type:text[]" json:"answer,omitempty"`
	Score            float32           `json:"score"`
	EventExamAttempt *EventExamAttempt `gorm:"foreignKey:AttemptId;references:Id" json:"exam_attempt,omitempty"`
	CreatedAt        time.Time         `json:"created_at,omitempty"`
	UpdatedAt        time.Time         `json:"updated_at,omitempty"`
}

func (EventExamAnswer) TableName() string { return "exam_event_answer" }

type ExamScoreboardEntry struct {
	AccountId       uuid.UUID
	Username        string
	FullName        string
	Score           float32
	DurationSeconds int64
}

type EventScoreboardEntry struct {
	AccountId  uuid.UUID
	Username   string
	FullName   string
	TotalScore float32
}

type EventExamAttempt struct {
	Id        uuid.UUID         `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_attempt"`
	AccountId uuid.UUID         `json:"id_account,omitempty"`
	EventId   uuid.UUID         `json:"id_event,omitempty"`
	ExamId    uuid.UUID         `json:"id_exam,omitempty"`
	Questions []Questions       `gorm:"-" json:"questions,omitempty"`
	Answers   []EventExamAnswer `gorm:"foreignKey:AttemptId;references:Id" json:"answers,omitempty"`
	Account   *Account          `gorm:"foreignKey:AccountId" json:"account,omitempty"`
	Event     *Events           `gorm:"foreignKey:EventId" json:"event,omitempty"`
	Exam      *Exam             `gorm:"foreignKey:ExamId" json:"exam,omitempty"`
	RemTime   int               `json:"remaining_time,omitempty"`
	Mark      float32           `json:"mark,omitempty"`
	CreatedAt time.Time         `json:"created_at,omitempty"`
	DueAt     time.Time         `json:"due_at,omitempty"`
	Submitted bool              `json:"submitted,omitempty"`
}

func (EventExamAttempt) TableName() string { return "exam_event_attempt" }

type Result struct {
	Id               uuid.UUID         `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_result"`
	AttemptId        uuid.UUID         `json:"id_attempt,omitempty"`
	FinalScore       float32           `json:"final_score"`
	EventExamAttempt *EventExamAttempt `gorm:"foreignKey:AttemptId;references:Id" json:"exam_attempt,omitempty"`
}

func (Result) TableName() string { return "result" }

type Academy struct {
	Id              uuid.UUID         `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	Title           string            `json:"title,omitempty"`
	Slug            string            `gorm:"unique" json:"slug,omitempty"`
	Code            string            `gorm:"unique" json:"code,omitempty"`
	IsPublic        bool              `json:"is_public,omitempty"`
	Description     string            `json:"description,omitempty"`
	ImageUrl        string            `json:"image_url,omitempty"`
	MaterialsCount  int64             `json:"materials_count,omitempty"`
	Materials       []AcademyMaterial `gorm:"foreignKey:AcademyId;references:Id" json:"materials,omitempty"`
	AcademyProgress AcademyProgress   `gorm:"foreignKey:AcademyId;references:Id" json:"academy_progress,omitempty"`
	Price           float64           `json:"price,omitempty"`
	RegisterStatus  int               `gorm:"-" json:"register_status"`
	CreatedAt       time.Time         `json:"created_at,omitempty"`
	DeletedAt       gorm.DeletedAt    `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
}

func (Academy) TableName() string { return "academy" }

type AcademyMaterial struct {
	Id                      uuid.UUID               `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
	AcademyId               uuid.UUID               `json:"academy_id,omitempty"`
	Title                   string                  `json:"title,omitempty"`
	Slug                    string                  `gorm:"unique" json:"slug,omitempty"`
	Description             string                  `json:"description,omitempty"`
	Order                   uint                    `json:"order,omitempty"`
	ContentsCount           int64                   `json:"contents_count,omitempty"`
	Contents                []AcademyContent        `gorm:"foreignKey:MaterialId;references:Id" json:"contents,omitempty"`
	AcademyMaterialProgress AcademyMaterialProgress `gorm:"foreignKey:MaterialId;references:Id" json:"academy_material_progress,omitempty"`
	CreatedAt               time.Time               `json:"created_at,omitempty"`
	DeletedAt               gorm.DeletedAt          `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
}

func (AcademyMaterial) TableName() string { return "academy_materials" }

type AcademyContent struct {
	Id                     uuid.UUID              `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id"`
	MaterialId             uuid.UUID              `json:"material_id,omitempty"`
	Title                  string                 `json:"title,omitempty"`
	Order                  uint                   `json:"order,omitempty"`
	Contents               string                 `json:"contents,omitempty"`
	AcademyContentProgress AcademyContentProgress `gorm:"foreignKey:ContentId;references:Id" json:"academy_content_progress,omitempty"`
	CreatedAt              time.Time              `json:"created_at,omitempty"`
	DeletedAt              gorm.DeletedAt         `json:"deleted_at,omitempty" gorm:"index" swag:"-"`
}

func (AcademyContent) TableName() string { return "academy_contents" }

// Progress

type AcademyProgress struct {
	Id                      uuid.UUID  `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id,omitempty"`
	AccountId               uuid.UUID  `gorm:"type:uuid;uniqueIndex:idx_account_academy" json:"account_id,omitempty"`
	AcademyId               uuid.UUID  `gorm:"type:uuid;uniqueIndex:idx_account_academy" json:"academy_id,omitempty"`
	Status                  string     `gorm:"type:varchar(50);default:'not attempted'" json:"status,omitempty"`
	Progress                float64    `gorm:"default:0" json:"progress"`
	TotalCompletedMaterials uint       `gorm:"default:0" json:"total_completed_materials"`
	CompletedAt             *time.Time `json:"completed_at"`
}

func (AcademyProgress) TableName() string { return "academy_progress" }

type AcademyMaterialProgress struct {
	Id                     uuid.UUID  `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id,omitempty"`
	AccountId              uuid.UUID  `gorm:"type:uuid;uniqueIndex:idx_account_material" json:"account_id,omitempty"`
	AcademyId              uuid.UUID  `gorm:"type:uuid;index" json:"academy_id,omitempty"`
	MaterialId             uuid.UUID  `gorm:"type:uuid;uniqueIndex:idx_account_material" json:"material_id,omitempty"`
	Progress               float64    `gorm:"default:0" json:"progress,omitempty"`
	TotalCompletedContents uint       `gorm:"default:0" json:"total_completed_contents,omitempty"`
	Status                 string     `gorm:"type:varchar(50);default:'not attempted'" json:"status,omitempty"`
	CompletedAt            *time.Time `json:"completed_at"`
}

func (AcademyMaterialProgress) TableName() string { return "academy_material_progress" }

type AcademyContentProgress struct {
	Id          uuid.UUID  `gorm:"type:uuid;primaryKey;default:gen_random_uuid()" json:"id,omitempty"`
	AccountId   uuid.UUID  `gorm:"type:uuid;uniqueIndex:idx_account_content" json:"account_id,omitempty"`
	AcademyId   uuid.UUID  `gorm:"type:uuid;index" json:"academy_id,omitempty"`
	MaterialId  uuid.UUID  `gorm:"type:uuid;index" json:"material_id,omitempty"`
	ContentId   uuid.UUID  `gorm:"type:uuid;uniqueIndex:idx_account_content" json:"content_id,omitempty"`
	Status      string     `gorm:"type:varchar(50);default:'not attempted'" json:"status,omitempty"`
	CompletedAt *time.Time `json:"completed_at"`
}

func (AcademyContentProgress) TableName() string { return "academy_content_progress" }

type AcademyAssign struct {
	Id        uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AccountId uuid.UUID `gorm:"type:uuid;index" json:"account_id,omitempty"`
	AcademyId uuid.UUID `gorm:"type:uuid;index" json:"academy_id,omitempty"`
	Account   *Account  `gorm:"foreignKey:AccountId" json:"account,omitempty"`
	Academy   *Academy  `gorm:"foreignKey:AcademyId" json:"academy,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
}

func (AcademyAssign) TableName() string { return "academy_assign" }

type File struct {
	Id           uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	OriginalName string    `json:"original_name,omitempty"`
	StoredName   string    `json:"stored_name,omitempty"`
	MimeType     string    `json:"mime_type,omitempty"`
	Size         int64     `json:"size,omitempty"`
	Path         string    `json:"path,omitempty"`
	Context      string    `json:"context,omitempty"`
	AccountId    uuid.UUID `json:"account_id,omitempty"`
	CreatedAt    time.Time `json:"created_at,omitempty"`
	Account      *Account  `gorm:"foreignKey:AccountId" json:"account,omitempty"`
}

func (File) TableName() string { return "files" }

type AcademyExamAssign struct {
	Id        uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_exam_academy_assign"`
	AcademyId uuid.UUID `json:"id_academy,omitempty"`
	ExamId    uuid.UUID `json:"id_exam,omitempty"`
	Exam      *Exam     `gorm:"foreignKey:ExamId" json:"exam,omitempty"`
	Academy   *Academy  `gorm:"foreignKey:AcademyId" json:"academy,omitempty"`
}

func (AcademyExamAssign) TableName() string { return "exam_academy_assign" }

type AcademyExamAnswer struct {
	Id                 uuid.UUID           `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AttemptId          uuid.UUID           `json:"id_attempt,omitempty" gorm:"index"`
	QuestionId         uuid.UUID           `json:"id_question,omitempty" gorm:"index"`
	Answers            pq.StringArray      `gorm:"type:text[]" json:"answer,omitempty"`
	Score              float32             `json:"score"`
	AcademyExamAttempt *AcademyExamAttempt `gorm:"foreignKey:AttemptId" json:"exam_attempt,omitempty"`
	CreatedAt          time.Time           `json:"created_at,omitempty"`
	UpdatedAt          time.Time           `json:"updated_at,omitempty"`
}

func (AcademyExamAnswer) TableName() string { return "exam_academy_answer" }

type AcademyExamAttempt struct {
	Id        uuid.UUID           `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_attempt"`
	AccountId uuid.UUID           `json:"id_account,omitempty"`
	AcademyId uuid.UUID           `json:"id_academy,omitempty"`
	ExamId    uuid.UUID           `json:"id_exam,omitempty"`
	Questions []Questions         `gorm:"-" json:"questions,omitempty"`
	Answers   []AcademyExamAnswer `gorm:"foreignKey:AttemptId;references:Id" json:"answers,omitempty"`
	Account   *Account            `gorm:"foreignKey:AccountId" json:"account,omitempty"`
	Academy   *Academy            `gorm:"foreignKey:AcademyId" json:"academy,omitempty"`
	Exam      *Exam               `gorm:"foreignKey:ExamId" json:"exam,omitempty"`
	RemTime   int                 `json:"remaining_time,omitempty"`
	Mark      float32             `json:"mark,omitempty"`
	CreatedAt time.Time           `json:"created_at,omitempty"`
	DueAt     time.Time           `json:"due_at,omitempty"`
	Submitted bool                `json:"submitted,omitempty"`
}

func (AcademyExamAttempt) TableName() string { return "exam_academy_attempt" }

type AcademyExamResult struct {
	Id                 uuid.UUID           `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id_result"`
	AttemptId          uuid.UUID           `json:"id_attempt,omitempty"`
	FinalScore         float32             `json:"final_score"`
	AcademyExamAttempt *AcademyExamAttempt `gorm:"foreignKey:AttemptId" json:"exam_attempt,omitempty"`
}

func (AcademyExamResult) TableName() string { return "academy_exam_result" }

type AcademyPaymentTransaction struct {
	Id            uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AccountId     uuid.UUID `json:"account_id,omitempty"`
	AcademyId     uuid.UUID `json:"academy_id,omitempty"`
	ExternalId    string    `json:"external_transaction_id,omitempty"`
	InvoiceId     string    `json:"invoice_id,omitempty"`
	InvoiceUrl    string    `json:"invoice_url,omitempty"`
	Amount        float64   `json:"amount,omitempty"`
	TransactionAt time.Time `json:"transaction_at,omitempty"`
	ExpiredAt     time.Time `json:"expired_at,omitempty"`
	Status        string    `json:"status,omitempty"`
}

func (AcademyPaymentTransaction) TableName() string { return "academy_payment_transaction" }

type EventPaymentTransaction struct {
	Id            uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AccountId     uuid.UUID `json:"account_id,omitempty"`
	EventId       uuid.UUID `json:"event_id,omitempty"`
	ExternalId    string    `json:"external_transaction_id,omitempty"`
	InvoiceId     string    `json:"invoice_id,omitempty"`
	InvoiceUrl    string    `json:"invoice_url,omitempty"`
	Amount        float64   `json:"amount,omitempty"`
	TransactionAt time.Time `json:"transaction_at,omitempty"`
	ExpiredAt     time.Time `json:"expired_at,omitempty"`
	Status        string    `json:"status,omitempty"`
}

func (EventPaymentTransaction) TableName() string { return "event_payment_transaction" }

type AcademyCoupon struct {
	Id         uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	AcademyId  uuid.UUID `json:"academy_id,omitempty"`
	Code       string    `gorm:"unique" json:"code,omitempty"`
	Discount   float64   `json:"discount,omitempty"`
	ValidUntil time.Time `json:"valid_until,omitempty"`
}

func (AcademyCoupon) TableName() string { return "academy_coupon" }