cslms-api/internal/models/userquizpaper.go
2023-12-27 17:31:49 +09:00

92 lines
4.7 KiB
Go

package models
import (
"time"
"gorm.io/datatypes"
)
// CREATE TABLE `UserQuizPapers` (
// `id` bigint(20) NOT NULL AUTO_INCREMENT,
// `guid_id` char(36) NOT NULL DEFAULT '0',
// `center_id` bigint(20) NOT NULL DEFAULT 0,
// `quiz_paper_id` bigint(20) NOT NULL DEFAULT 0,
// `status` varchar(10) NOT NULL DEFAULT '0' COMMENT '매칭된 학생퀴즈시험지 상태: \r\nwaiting(대기)/processing(시험진행중)/abort(취소)/marking(채점중)/done(완료) ',
// `user_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '매칭된 학생',
// `user_score` float NOT NULL DEFAULT 5 COMMENT '10',
// `total_score` float NOT NULL DEFAULT 100 COMMENT '100.0, 5.0',
// `start_at` timestamp NULL DEFAULT NULL COMMENT '학생시험시작시각',
// `done_at` timestamp NULL DEFAULT NULL COMMENT '학생시험종료시각',
// `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
// `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
// PRIMARY KEY (`id`) USING BTREE,
// KEY `guid_id` (`guid_id`) USING BTREE,
// KEY `center_id` (`center_id`) USING BTREE,
// KEY `user_id` (`user_id`),
// KEY `manager_id` (`quiz_paper_id`) USING BTREE
// ) ENGINE=InnoDB AUTO_INCREMENT=10000001 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='학생퀴즈시험지 매칭\r\n';
type UserQuizPaper struct {
ID int64 `json:"id" db:"id" example:"1000015" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4" gorm:"column:guid_id;size:255;uniqueIndex"`
CenterID int64 `json:"center_id" db:"center_id" example:"1000015" gorm:"column:center_id;index;"`
QuizPaperID int64 `json:"quiz_paper_id" db:"quiz_paper_id" example:"1000001" gorm:"column:quiz_paper_id;index;"`
UserID int64 `json:"user_id" db:"user_id" example:"1000002" gorm:"column:user_id;index;"`
UserScore float32 `json:"user_score" db:"user_score" example:"5" gorm:"column:user_score;"`
TotalScore float32 `json:"total_score" db:"total_score" example:"100" gorm:"column:total_score;"`
Status string `json:"status" example:"wating" gorm:"column:status;size:10;index;"`
StartAt *time.Time `json:"start_at" gorm:"column:start_at;index;"`
DoneAt *time.Time `json:"done_at" gorm:"column:done_at;index;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false;<-:create"`
}
// 테이블이름 정의
func (UserQuizPaper) TableName() string {
return "UserQuizPapers"
}
type UserQuizPaperRequest struct {
QuizPaperID int64 `json:"quiz_paper_id" example:"1000002"`
Users datatypes.JSON `json:"users"`
}
type UserQuizPaperResponse struct {
ID int64 `json:"id" db:"id" example:"1000015"`
GUID string `json:"guid_id" db:"guid_id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4"`
CenterID int64 `json:"center_id" db:"center_id" example:"1000015"`
QuizPaperID int64 `json:"quiz_paper_id" db:"quiz_paper_id" example:"1000001"`
UserID int64 `json:"user_id" db:"user_id" example:"1000002"`
UserScore float32 `json:"user_score" db:"user_score" example:"5"`
TotalScore float32 `json:"total_score" db:"total_score" example:"100"`
Status string `json:"status" example:"wating"`
StartAt *time.Time `json:"start_at"`
DoneAt *time.Time `json:"done_at"`
}
type UserQuizPaperUpdateRequest struct {
QuizPaperID int64 `json:"quiz_paper_id" example:"1000002"`
UserID int64 `json:"user_id" example:"1000003"`
UserScore float32 `json:"user_score" example:"5"`
TotalScore float32 `json:"total_score" example:"100"`
Status string `json:"status" example:"ready"`
StartAt string `json:"start_at,omitempty" example:"2023-11-10T13:10:00+09:00"`
DoneAt string `json:"done_at,omitempty" example:"2023-11-10T13:25:00+09:00"`
}
type UserQuizPaperPatchRequest struct {
UserScore float32 `json:"user_score" example:"4"`
TotalScore float32 `json:"total_score" example:"80"`
Status string `json:"status" example:"ready"`
StartAt string `json:"start_at,omitempty" example:"2023-11-10T13:10:00+09:00"`
DoneAt string `json:"done_at,omitempty" example:"2023-11-10T13:25:00+09:00"`
}
type UserQuizPaperListResponse struct {
Data []UserQuizPaper `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"`
}