first commit

This commit is contained in:
2023-12-27 17:31:49 +09:00
commit ab6a57b907
69 changed files with 11271 additions and 0 deletions

29
internal/models/auth.go Normal file
View File

@ -0,0 +1,29 @@
package models
type LoginRequest struct {
Username string `json:"user_name" example:"admin0"`
Password string `json:"password" example:"testme"`
}
type LoginResponse struct {
User User `json:"user"`
Token string `json:"token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDI3MTMwMjcsInN1"`
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDc4OTcwMjcs"`
}
type RegisterRequest struct {
FirstName string `json:"first_name" example:"길순"`
LastName string `json:"last_name" example:"홍"`
Username string `json:"user_name" example:"gilsoon"`
Password string `json:"password" example:"StrongPass!@#$"`
Gender string `json:"gender" example:"F"`
UserRole string `json:"user_role" example:"member"`
Phone string `json:"phone_cs" example:"01012345678"`
Image string `json:"upload_image" example:""`
}
type RegisterResponse struct {
User User `json:"user"`
Token string `json:"token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDI3MTMwMjcsInN1"`
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDc4OTcwMjcs"`
}

57
internal/models/center.go Normal file
View File

@ -0,0 +1,57 @@
package models
import (
"time"
)
// CREATE TABLE `Centers` (
// `id` bigint(20) NOT NULL AUTO_INCREMENT,
// `guid_id` varchar(36) DEFAULT '',
// `center_title` varchar(50) DEFAULT '' COMMENT '강동런스팀로봇코딩학원',
// `center_name` varchar(50) DEFAULT '' COMMENT 'learnsteam_kd',
// `owner_id` bigint(20) DEFAULT 0,
// `content_page` text DEFAULT '' COMMENT '학원상세페이지, html/마크다운/text',
// `company_info` text DEFAULT '' COMMENT '사업자정보-json\r\n기타 정보 추가 가능\r\n\r\n{\r\n "company_ceo": "대표자이름",\r\n "company_code": "사업자번호",\r\n "company_phone": "대표전화번호",\r\n "company_email": "대표전자메일",\r\n "company_homepage": "대표홈페이지 url",\r\n "company_logo": "로고이미지 url",\r\n "company_cover_image": "대표 이미지", \r\n}',
// `memo` varchar(256) DEFAULT '',
// `created_at` timestamp NULL DEFAULT current_timestamp(),
// `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
// `status` varchar(10) DEFAULT NULL,
// PRIMARY KEY (`id`)
// ) ENGINE=InnoDB AUTO_INCREMENT=1000005 DEFAULT CHARSET=utf8mb4 COMMENT='Centers의 이미지/영상은 Links에서 관리됨. ';
type Center struct {
ID int64 `json:"id" db:"id" example:"100001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6" gorm:"column:guid_id;size:255;index;"`
Title string `json:"center_title" db:"center_title" example:"강동런스팀로봇코딩학원" gorm:"column:center_title;size:50;index;"`
Name string `json:"center_name" db:"center_name" example:"learnsteam_kd" gorm:"column:center_name;size:50;index;"`
OwnerID int64 `json:"owner_id" db:"owner_id" example:"100001" gorm:"column:owner_id;index;"`
Content string `json:"content_page" db:"content_page" example:"학원상세페이지, html/마크다운/text" gorm:"column:content_page;size:2048;"`
Info string `json:"company_info" db:"company_info" example:"사업자정보-json 기타 정보 추가 가능" gorm:"column:company_info;size:2048;"`
Memo string `json:"memo" db:"memo" example:"메모" gorm:"column:memo;size:1024;"`
Status string `json:"status" db:"status" example:"on" gorm:"column:status;size:10;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 (Center) TableName() string {
return "Centers"
}
type CenterRequest struct {
Title string `json:"center_title" example:"강동런스팀로봇코딩학원"`
Name string `json:"center_name" example:"learnsteam_kd"`
OwnerID int64 `json:"owner_id" example:"100001"`
Content string `json:"content_page" example:"학원상세페이지, html/마크다운/text"`
Info string `json:"company_info" example:"사업자정보-json 기타 정보 추가 가능"`
Memo string `json:"memo" example:"메모"`
Status string `json:"status" example:"on"`
}
type CenterListResponse struct {
Data []Center `json:"data"`
Total int64 `json:"total" example:"5"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"1"`
PageSize int `json:"pageSize" example:"10"`
}

78
internal/models/quiz.go Normal file
View File

@ -0,0 +1,78 @@
package models
import (
"time"
"gorm.io/datatypes"
)
// 문항 json,
// option1~4는 구분이름일 뿐, 실제로는 셔플되어서 반환됨.
/*
{
"option1": {"content": "markdown 문서로 작성됨", "is_answer": false},
"option2": {"content": "markdown 문서로 작성됨", "is_answer": false},
"option3": {"content": "markdown 문서로 작성됨", "is_answer": false},
"option4": {"content": "markdown 문서로 작성됨", "is_answer": true},
"hint": "markdown문서로 작성됨",
"score": 10
}
*/
type Quiz struct {
ID int64 `json:"id" db:"id" example:"1000001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6" gorm:"column:guid_id;size:255;index;"`
CenterID int64 `json:"center_id" db:"center_id" example:"100001" gorm:"column:center_id;index;"`
QuizPaperID int64 `json:"quiz_paper_id" db:"quiz_paper_id" example:"100001" gorm:"column:quiz_paper_id;index;"`
No int `json:"vol_no" db:"vol_no" example:"5" gorm:"column:vol_no;index;"`
QuestionType string `json:"question_type" db:"question_type" example:"choice" gorm:"column:question_type;size:10;index;"`
Question string `json:"question" db:"question" example:"퀴즈 질문입니다." gorm:"column:question;size:512;"`
Content datatypes.JSON `json:"content" db:"content" gorm:"column:content;"`
Answer datatypes.JSON `json:"answer" db:"answer" gorm:"column:answer;"`
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 (Quiz) TableName() string {
return "Quizs"
}
type QuizRequest struct {
QuizPaperID int64 `json:"quiz_paper_id" example:"1000001"`
CenterID int64 `json:"center_id" example:"1000001"`
No int `json:"vol_no" example:"1"`
QuestionType string `json:"question_type" example:"choice"`
Question string `json:"question" example:"질문입니다."`
Content QuizContent `json:"content"`
Answer []string `json:"answer" example:"option1,option2"`
}
type QuizResponse struct {
ID int64 `json:"id" example:"1000001"`
QuizPaperID int64 `json:"quiz_paper_id" example:"1000001"`
No int `json:"vol_no" example:"5"`
QuestionType string `json:"question_type" example:"check"`
Question string `json:"question" example:"퀴즈 질문입니다."`
Content QuizContent `json:"content"`
Answer []string `json:"answer" example:"option1,option2"`
}
type QuizListResponse struct {
Data []Quiz `json:"data"`
Total int64 `json:"total" example:"5"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"1"`
PageSize int `json:"pageSize" example:"10"`
}
type QuizContent struct {
Option1 string `json:"option1" example:"markdown 문서로 작성됨"`
Option2 string `json:"option2" example:"markdown 문서로 작성됨"`
Option3 string `json:"option3" example:"markdown 문서로 작성됨"`
Option4 string `json:"option4" example:"markdown 문서로 작성됨"`
Hint string `json:"hint" example:"markdown문서로 작성됨"`
}
type QuizAnswer struct {
}

View File

@ -0,0 +1,82 @@
package models
import (
"time"
"gorm.io/datatypes"
)
// CREATE TABLE `QuizPapers` (
// `id` bigint(20) NOT NULL AUTO_INCREMENT,
// `guid_id` char(36) NOT NULL DEFAULT '0',
// `center_id` bigint(20) NOT NULL DEFAULT 0,
// `manager_id` bigint(20) NOT NULL DEFAULT 0,
// `title` varchar(256) NOT NULL DEFAULT '' COMMENT '퀴즈시트 제목',
// `status` varchar(10) NOT NULL DEFAULT '0' COMMENT 'on/off',
// `content` text NOT NULL DEFAULT '' COMMENT 'markdown 문서',
// `tags` varchar(256) NOT NULL DEFAULT '' COMMENT '출력,hello world,for반복문...',
// `category` varchar(256) NOT NULL DEFAULT '파이썬기본',
// `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 `manager_id` (`manager_id`) USING BTREE
// ) ENGINE=InnoDB AUTO_INCREMENT=10000001 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='퀴즈시험지 관리 테이블\r\n\r\n';
type QuizPaper struct {
ID int64 `json:"id" db:"id" example:"100001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"ef74c59a-c707-4162-a52b-455906c81ec1" gorm:"column:guid_id;size:255;index;"`
CenterID int64 `json:"center_id" db:"center_id" example:"100001" gorm:"column:center_id;index;"`
ManagerID int64 `json:"manager_id" db:"manager_id" example:"100001" gorm:"column:manager_id;index;"`
Title string `json:"title" db:"title" example:"퀴즈 시트 제목" gorm:"column:title;size:255;index;"`
Content string `json:"content" db:"content" example:"퀴즈 시트 설명" gorm:"column:content;size:512;"`
Category string `json:"category" db:"category" example:"파이썬기본" gorm:"column:title;size:255;"`
Tag datatypes.JSON `json:"tag" db:"tag" gorm:"column:tag;"`
Status string `json:"status" example:"on" gorm:"column:status;size:10;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 (QuizPaper) TableName() string {
return "QuizPapers"
}
type QuizPaperRequest struct {
CenterID int64 `json:"center_id" example:"100001"`
Title string `json:"title" example:"퀴즈 시트 제목"`
Content string `json:"content" example:"퀴즈 시트 설명"`
Category string `json:"category" example:"파이썬기본"`
Tag datatypes.JSON `json:"tag"`
Status string `json:"status" example:"on"`
}
type QuizPaperResponse struct {
ID int64 `json:"id" example:"100001"`
CenterID int64 `json:"center_id" example:"100001"`
ManagerID int64 `json:"manager_id" example:"100001"`
Title string `json:"title" example:"퀴즈 시트 제목"`
Content string `json:"content" example:"퀴즈 시트 설명"`
Category string `json:"category" example:"파이썬기본"`
Tag datatypes.JSON `json:"tag"`
Status string `json:"status" example:"on"`
}
type QuizPaperListResponse struct {
Data []QuizPaper `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"`
}
type QuizPaperCopyRequest struct {
Title string `json:"title" example:"퀴즈 시트 제목"`
CenterID int64 `json:"center_id" example:"100002"`
}
type QuizPaperCopyResponse struct {
QuizPaper QuizPaper `json:"quiz_paper"`
Quiz []Quiz `json:"quiz"`
}

46
internal/models/token.go Normal file
View File

@ -0,0 +1,46 @@
package models
import "time"
// CREATE TABLE `UserTokens` (
// `id` bigint(20) NOT NULL AUTO_INCREMENT,
// `user_id` bigint(20) DEFAULT 0,
// `token` varchar(256) DEFAULT '',
// `refresh_token` varchar(256) DEFAULT '',
// `status` varchar(3) DEFAULT 'on' COMMENT 'on/off',
// `register_at` timestamp NULL DEFAULT current_timestamp(),
// `ending_at` timestamp NULL DEFAULT NULL COMMENT '종료날짜',
// PRIMARY KEY (`id`) USING BTREE
// ) ENGINE=InnoDB AUTO_INCREMENT=1000017 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
type Token struct {
ID int64 `json:"-" db:"id" gorm:"primary_key"`
UserID int64 `json:"user_id" db:"user_id" gorm:"index;"`
Token string `json:"token" db:"token" gorm:"size:255;index;"`
RefreshToken string `json:"refresh_token" db:"refresh_token" gorm:"size:255;index;"`
Status string `json:"status" gorm:"size:3;index"`
RegisterAt time.Time `json:"register_at" db:"register_at"`
EndingAt time.Time `json:"ending_at" db:"ending_at"`
}
// 테이블이름 정의
func (Token) TableName() string {
return "UserTokens"
}
type RefreshTokenRequest struct {
RefreshToken string `json:"refresh_token" binding:"required"`
}
type TokenResponse struct {
Token string `json:"token"`
TokenBody TokenBody `json:"tokenBody"`
}
type TokenBody struct {
ExpireAt time.Time `json:"tokenExpiredDate"`
TokenIdx int `json:"tokenIdx"`
TokenType int `json:"tokenType"`
}

52
internal/models/user.go Normal file
View File

@ -0,0 +1,52 @@
package models
import "time"
// CREATE TABLE `Users` (
// `id` bigint(20) NOT NULL AUTO_INCREMENT,
// `guid_id` longtext DEFAULT NULL,
// `first_name` longtext DEFAULT NULL,
// `last_name` longtext DEFAULT NULL,
// `user_name` longtext DEFAULT NULL,
// `password` longtext DEFAULT NULL,
// `gender` char(1) DEFAULT 'M' COMMENT 'M(남)/F(여)',
// `user_role` longtext DEFAULT NULL,
// `memo_cs` longtext DEFAULT NULL,
// `register_at` datetime(3) DEFAULT NULL,
// `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '업데이트될때마다 자동저장',
// `phone_cs` longtext DEFAULT NULL,
// `upload_image` longtext DEFAULT NULL,
// PRIMARY KEY (`id`) USING BTREE,
// KEY `guid_id` (`guid_id`(768)),
// KEY `first_name` (`first_name`(768)),
// KEY `last_name` (`last_name`(768)),
// KEY `user_name` (`user_name`(768))
// ) ENGINE=InnoDB AUTO_INCREMENT=1000023 DEFAULT CHARSET=utf8mb4;
type User struct {
ID int64 `json:"id" db:"id" example:"100001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"137c1683-2ad6-4201-b256-253828b61c49" gorm:"column:guid_id;size:255;"`
FirstName string `json:"first_name" db:"first_name" example:"길순" gorm:"column:first_name;size:255;"`
LastName string `json:"last_name" db:"last_name" example:"홍" gorm:"column:last_name;size:255;"`
Username string `json:"user_name" db:"user_name" example:"user0" gorm:"column:user_name;size:50;uniqueIndex;"`
Password string `json:"-" db:"password" gorm:"column:password;size:255;not null;"`
Gender string `json:"gender" db:"gender" example:"F" gorm:"column:gender;size:1;"`
UserRole string `json:"user_role" db:"user_role" example:"member" gorm:"column:user_role;size:255;"`
Memo string `json:"memo_cs" db:"memo_cs" example:"사용자 메모" gorm:"column:memo_cs;size:255;"`
Phone string `json:"phone_cs" db:"phone_cs" example:"010-1234-5678" gorm:"column:phone_cs;size:255;"`
Image string `json:"upload_image" db:"upload_image" example:"image_url" gorm:"column:upload_image;size:255;"`
RegisterAt time.Time `json:"register_at" db:"regiser_at" gorm:"column:register_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
}
// 테이블이름 정의
func (User) TableName() string {
return "Users"
}
type UserListResponse struct {
Data []User `json:"data"`
Total int64 `json:"total" example:"90"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"9"`
PageSize int `json:"pageSize" example:"10"`
}

View File

@ -0,0 +1,68 @@
package models
import (
"time"
"gorm.io/datatypes"
)
type UserQuiz struct {
ID int64 `json:"id" db:"id" example:"1000001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6" gorm:"column:guid_id;size:255;index;"`
CenterID int64 `json:"center_id" db:"center_id" example:"100001" gorm:"column:center_id;index;"`
UserQuizPaperID int64 `json:"user_quiz_paper_id" db:"user_quiz_paper_id" example:"1000001" gorm:"column:user_quiz_paper_id;index;"`
UserID int64 `json:"user_id" db:"user_id" example:"1000001" gorm:"column:user_id;index;"`
No int `json:"vol_no" db:"vol_no" example:"5" gorm:"column:vol_no;index;"`
QuestionType string `json:"question_type" db:"question_type" example:"choice" gorm:"column:question_type;size:10;index;"`
Question string `json:"question" db:"question" example:"퀴즈 질문입니다." gorm:"column:question;size:512;"`
Content datatypes.JSON `json:"content" db:"content" gorm:"column:content;"`
Answer datatypes.JSON `json:"answer,omitempty" db:"answer" gorm:"column:answer;default:'[]';"`
Status string `json:"status" db:"status" example:"waiting" gorm:"column:status;size:10;index;"`
Result string `json:"result" db:"result" example:"success" gorm:"column:result;size:10;index;"`
Score float32 `json:"score" db:"score" example:"10" gorm:"column:score;"`
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 (UserQuiz) TableName() string {
return "UserQuizs"
}
type UserQuizRequest struct {
CenterID int64 `json:"center_id" example:"1000001"`
UserQuizPaperID int64 `json:"quiz_paper_id" example:"1000001"`
UserID int64 `json:"user_id" example:"1000001"`
No int `json:"vol_no" example:"1"`
QuestionType string `json:"question_type" example:"choice"`
Question string `json:"question" example:"질문입니다."`
Content QuizContent `json:"content"`
Answer []string `json:"answer" example:"option1,option2"`
Status string `json:"status" example:"waiting"`
Result string `json:"result" example:"success"`
Score float32 `json:"score" example:"10"`
}
type UserQuizResponse struct {
ID int64 `json:"id" example:"1000001"`
GUID string `json:"guid_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6"`
CenterD string `json:"center_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6"`
UserQuizPaperID int64 `json:"user_quiz_paper_id" example:"1000001"`
UserID int64 `json:"user_id" example:"1000001"`
No int `json:"vol_no" example:"5"`
QuestionType string `json:"question_type" example:"check"`
Question string `json:"question" example:"퀴즈 질문입니다."`
Content QuizContent `json:"content"`
Answer []string `json:"answer" example:"option1,option2"`
Status string `json:"status" example:"waiting"`
Result string `json:"result" example:"success"`
Score float32 `json:"score" example:"10"`
}
type UserQuizListResponse struct {
Data []UserQuizResponse `json:"data"`
Total int64 `json:"total" example:"5"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"1"`
PageSize int `json:"pageSize" example:"10"`
}

View File

@ -0,0 +1,91 @@
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"`
}