This commit is contained in:
2023-11-23 00:30:50 +09:00
parent e8ddadfd0a
commit d354dbb27f
18 changed files with 1907 additions and 817 deletions

70
internal/models/exam.go Normal file
View File

@ -0,0 +1,70 @@
package models
import (
"time"
"gorm.io/datatypes"
)
type Exam struct {
ID string `json:"id" db:"id" example:"ef74c59a-c707-4162-a52b-455906c81ec1" gorm:"column:id;size:255;primary_key;"`
ProgramID string `json:"program_id" db:"program_id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4" gorm:"column:program_id;size:255;uniqueIndex:idx_exam;"`
UserID string `json:"user_id" db:"user_id" example:"f95159dd-c42c-490d-ac6b-ca5d88a266bb" gorm:"column:user_id;size:255;uniqueIndex:idx_exam;"`
Subject string `json:"subject" db:"subject" example:"출력 Print" gorm:"column:subject;size:255;index;"`
Program string `json:"program" db:"program" example:"파이썬 초급 과정" gorm:"column:program;size:255;index;"`
Name string `json:"name" db:"name" example:"홍길순" gorm:"column:name;size:255;index;"`
Score int `json:"score" db:"score" example:"5" gorm:"column:score;"`
Total int `json:"total" db:"total" example:"5" gorm:"column:total;"`
Status string `json:"status" example:"ready" gorm:"column:status;size:10;index;"`
StartAt *time.Time `json:"start_at" gorm:"column:start_at;index;"`
EndAt *time.Time `json:"end_at" gorm:"column:end_at;index;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false;<-:create"`
}
type ExamRequest struct {
ProgramID string `json:"program_id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4"`
Users datatypes.JSON `json:"users"`
}
type ExamResponse struct {
ID string `json:"id" db:"id" example:"ef74c59a-c707-4162-a52b-455906c81ec1"`
ProgramID string `json:"program_id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4"`
UserID string `json:"user_id" example:"f95159dd-c42c-490d-ac6b-ca5d88a266bb"`
Subject string `json:"subject" example:"출력 Print"`
Program string `json:"program" example:"파이썬 초급 과정"`
Name string `json:"name" example:"홍길순"`
Score int `json:"score" example:"5"`
Total int `json:"total" example:"5"`
Status string `json:"status" example:"ready"`
StartAt string `json:"start_at,omitempty" example:"2023-11-10T13:10:00+09:00"`
EndAt string `json:"end_at,omitempty" example:"2023-11-10T13:25:00+09:00"`
}
type ExamUpdateRequest struct {
ProgramID string `json:"program_id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4"`
UserID string `json:"user_id" example:"f95159dd-c42c-490d-ac6b-ca5d88a266bb"`
Subject string `json:"subject" example:"출력 Print"`
Program string `json:"program" example:"파이썬 초급 과정"`
Name string `json:"name" example:"홍길순"`
Score int `json:"score" example:"5"`
Total int `json:"total" example:"5"`
Status string `json:"status" example:"ready"`
StartAt string `json:"start_at,omitempty" example:"2023-11-10T13:10:00+09:00"`
EndAt string `json:"end_at,omitempty" example:"2023-11-10T13:25:00+09:00"`
}
type ExamPatchRequest struct {
Score int `json:"score,omitempty" example:"4"`
Status string `json:"status,omitempty" example:"rating"`
StartAt string `json:"start_at,omitempty" example:"2023-11-10T13:10:00+09:00"`
EndAt string `json:"end_at,omitempty" example:"2023-11-10T13:25:00+09:00"`
}
type ExamListResponse struct {
Data []Exam `json:"data"`
Total int64 `json:"total" example:"999"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"99"`
PageSize int `json:"pageSize" example:"10"`
}

View File

@ -15,8 +15,8 @@ type Program struct {
Tags string `json:"-" db:"tags" gorm:"column:tags;index;"`
Status string `json:"status" example:"on" gorm:"column:status;size:10;index;"`
PublishAt time.Time `json:"publish_at" example:"2023-11-10T00:00:00+09:00" gorm:"column:publish_at;index;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;index;"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;index;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false;<-:create"`
}
type ProgramRequest struct {

View File

@ -16,8 +16,8 @@ type Quiz struct {
Answer datatypes.JSON `json:"answer" db:"answer" gorm:"column:answer;"`
Hint string `json:"hint" db:"hint" example:"퀴즈 힌트" gorm:"column:answer;size:1024;"`
Comment string `json:"comment" db:"comment" example:"퀴즈 해설" gorm:"column:comment;size:1024;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;index;"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;index;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false;<-:create"`
}
type QuizRequest struct {

View File

@ -8,8 +8,8 @@ type User struct {
Name string `json:"name" db:"name" example:"홍길동" gorm:"column:name;size:50;"`
Score int32 `json:"score" db:"score" example:"9999" gorm:"column:score;"`
Password string `json:"-" db:"password" gorm:"column:password;size:255;not null;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;index;"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;index;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false;<-:create"`
}
type UserListResponse struct {