Spaces:
Runtime error
Runtime error
File size: 20,461 Bytes
b025147 db7ff15 b55a115 b025147 b55a115 b025147 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 4542d62 b55a115 b025147 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 db7ff15 9c9198b b55a115 db7ff15 b025147 9c9198b db7ff15 9c9198b db7ff15 9c9198b db7ff15 9c9198b db7ff15 9c9198b b025147 db7ff15 b025147 9c9198b b55a115 db7ff15 9c9198b db7ff15 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 9c9198b b55a115 db7ff15 b025147 9c9198b b55a115 db7ff15 b025147 9c9198b db7ff15 9c9198b db7ff15 9c9198b b55a115 db7ff15 d877823 db7ff15 9c9198b b55a115 db7ff15 9c9198b b025147 b55a115 db7ff15 b025147 9c9198b b025147 b55a115 4542d62 b55a115 b025147 9c9198b b025147 b55a115 4542d62 b55a115 b025147 9c9198b b025147 b55a115 4542d62 b55a115 b025147 32ac45b 9c9198b b55a115 b025147 b55a115 b025147 b55a115 9c9198b b025147 b55a115 b025147 b55a115 | 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 | 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"`
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"`
DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"`
}
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"`
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"`
}
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"`
}
func (Exam) TableName() string { return "exam" }
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"`
ProblemSetId uuid.UUID `json:"id_problem_set,omitempty"`
ProblemSet *ProblemSet `gorm:"foreignKey:ProblemSetId" json:"problem_set,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 ExamEventAssign 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 (ExamEventAssign) 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 ExamEventAnswer 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"`
ExamEventAttempt *ExamEventAttempt `gorm:"foreignKey:AttemptId" json:"exam_attempt,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
func (ExamEventAnswer) TableName() string { return "exam_event_answer" }
type ExamEventAttempt 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 []ExamEventAnswer `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 (ExamEventAttempt) 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"`
ExamEventAttempt *ExamEventAttempt `gorm:"foreignKey:AttemptId" 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"`
RegisterStatus int `gorm:"-" json:"register_status"`
CreatedAt time.Time `json:"created_at,omitempty"`
DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"`
}
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"`
}
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"`
}
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 ExamAcademyAssign 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 (ExamAcademyAssign) TableName() string { return "exam_academy_assign" }
type ExamAcademyAnswer 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"`
ExamAcademyAttempt *ExamAcademyAttempt `gorm:"foreignKey:AttemptId" json:"exam_attempt,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
func (ExamAcademyAnswer) TableName() string { return "exam_academy_answer" }
type ExamAcademyAttempt 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 []ExamAcademyAnswer `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 (ExamAcademyAttempt) TableName() string { return "exam_academy_attempt" }
type ExamAcademyResult 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"`
ExamAcademyAttempt *ExamAcademyAttempt `gorm:"foreignKey:AttemptId" json:"exam_attempt,omitempty"`
}
func (ExamAcademyResult) TableName() string { return "academy_exam_result" }
|