Swag Docs
This commit is contained in:
@ -5,7 +5,27 @@ type LoginRequest struct {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
User User `json:"user"`
|
||||
Token string `json:"token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDI3MTMwMjcsInN1"`
|
||||
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDc4OTcwMjcs"`
|
||||
}
|
||||
|
||||
// ID string `json:"id" example:"7f9329f5-2e36-4638-92d2-73064b7291a4"`
|
||||
// Username string `json:"username" example:"user0"`
|
||||
// Name string `json:"name" example:"홍길동"`
|
||||
// Token string `json:"token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDI3MTMwMjcsInN1"`
|
||||
// RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDc4OTcwMjcs"`
|
||||
// }
|
||||
|
||||
type RegisterRequest struct {
|
||||
Name string `json:"name"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type RegisterResponse struct {
|
||||
User User `json:"user"`
|
||||
Token string `json:"token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDI3MTMwMjcsInN1"`
|
||||
RefreshToken string `json:"refresh_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE3MDc4OTcwMjcs"`
|
||||
}
|
||||
|
47
internal/models/program.go
Normal file
47
internal/models/program.go
Normal file
@ -0,0 +1,47 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type Program struct {
|
||||
ID string `json:"id" db:"id" example:"ef74c59a-c707-4162-a52b-455906c81ec1" gorm:"column:id;size:255;primary_key;"`
|
||||
Course string `json:"course" db:"course" example:"코스 이름" gorm:"column:course;size:40;index;"`
|
||||
Subject string `json:"subject" db:"subject" example:"프로그램 제목" gorm:"column:subject;size:255;index;"`
|
||||
Content string `json:"content" db:"content" example:"코스 설명" gorm:"column:content;size:512;"`
|
||||
Tag datatypes.JSON `json:"tag" db:"tag" gorm:"column:tag;"`
|
||||
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;"`
|
||||
}
|
||||
|
||||
type ProgramRequest struct {
|
||||
Course string `json:"course" example:"코스 이름"`
|
||||
Subject string `json:"subject" example:"프로그램 제목"`
|
||||
Content string `json:"content" example:"코스 설명"`
|
||||
Tag datatypes.JSON `json:"tag"`
|
||||
Status string `json:"status" example:"on"`
|
||||
PublishAt string `json:"publish_at" example:"2023-11-10T00:00:00+09:00"`
|
||||
}
|
||||
|
||||
type ProgramResponse struct {
|
||||
ID string `json:"id" example:"ef74c59a-c707-4162-a52b-455906c81ec1"`
|
||||
Course string `json:"course" example:"코스 이름"`
|
||||
Subject string `json:"subject" example:"프로그램 제목"`
|
||||
Content string `json:"content" example:"코스 설명"`
|
||||
Tag []string `json:"tag" example:"tag1,tag2"`
|
||||
Status string `json:"status" example:"on"`
|
||||
PublishAt string `json:"publish_at" example:"2023-11-10T00:00:00+09:00"`
|
||||
}
|
||||
|
||||
type ProgramListResponse struct {
|
||||
Data []Program `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"`
|
||||
}
|
52
internal/models/quiz.go
Normal file
52
internal/models/quiz.go
Normal file
@ -0,0 +1,52 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type Quiz struct {
|
||||
ID string `json:"id" db:"id" example:"1b066168-68c4-4b50-bc9a-b6c4fceaf378" gorm:"column:id;size:255;primary_key;"`
|
||||
ProgramID string `json:"program_id" db:"program_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6" gorm:"column:program_id;size:255;index;"`
|
||||
Sequence int `json:"sequence" db:"sequence" example:"5" gorm:"column:sequence;index;"`
|
||||
QuizType string `json:"quiz_type" db:"quiz_type" example:"choice" gorm:"column:quiz_type;size:10;index;"`
|
||||
Question string `json:"question" db:"question" example:"퀴즈 질문입니다." gorm:"column:question;size:512;"`
|
||||
Choice datatypes.JSON `json:"choice" db:"choice" gorm:"column:choice;"`
|
||||
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;"`
|
||||
}
|
||||
|
||||
type QuizRequest struct {
|
||||
ProgramID string `json:"program_id"`
|
||||
Sequence int `json:"sequence"`
|
||||
QuizType string `json:"quiz_type"`
|
||||
Question string `json:"question"`
|
||||
Choice datatypes.JSON `json:"choice"`
|
||||
Answer datatypes.JSON `json:"answer"`
|
||||
Hint string `json:"hint"`
|
||||
Comment string `json:"comment"`
|
||||
}
|
||||
|
||||
type QuizResponse struct {
|
||||
ID string `json:"id" example:"1b066168-68c4-4b50-bc9a-b6c4fceaf378"`
|
||||
ProgramID string `json:"program_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6"`
|
||||
Sequence int `json:"sequence" example:"5" gorm:"column:sequence;index;"`
|
||||
QuizType string `json:"quiz_type" example:"check"`
|
||||
Question string `json:"question" example:"퀴즈 질문입니다."`
|
||||
Choice datatypes.JSON `json:"choice"`
|
||||
Answer datatypes.JSON `json:"answer"`
|
||||
Hint string `json:"hint" example:"퀴즈 힌트"`
|
||||
Comment string `json:"comment" example:"퀴즈 해설"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
@ -2,15 +2,32 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
// type Token struct {
|
||||
// ID string `json:"id" db:"id" gorm:"column:id;size:255;primary_key;"`
|
||||
// UserID string `json:"user_id" db:"user_id" gorm:"column:user_id;size:255;index;"`
|
||||
// Token string `json:"token" gorm:"column:token;size:255;index;"`
|
||||
// RefreshToken string `json:"refresh_token" gorm:"column:token;size:255;index;"`
|
||||
// Status string `json:"status" gorm:"column:status;size:10;index;"`
|
||||
// ExpireAt time.Time `json:"expire_at" gorm:"column:expire_at;index;"`
|
||||
// UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;index;"`
|
||||
// CreatedAt time.Time `json:"created_at" gorm:"column:created_at;index;"`
|
||||
// }
|
||||
|
||||
type Token struct {
|
||||
ID string `json:"id" db:"id" gorm:"column:id;size:255;primary_key;"`
|
||||
UserID string `json:"user_id" db:"user_id" gorm:"column:user_id;size:255;index;"`
|
||||
Token string `json:"token" gorm:"column:token;size:255;index;"`
|
||||
RefreshToken string `json:"refresh_token" gorm:"column:token;size:255;index;"`
|
||||
Status string `json:"status" gorm:"column:status;size:10;index;"`
|
||||
ExpireAt time.Time `json:"expire_at" gorm:"column:expire_at;index;"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at;index;"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at;index;"`
|
||||
ID string `json:"-" db:"id" gorm:"primary_key"`
|
||||
UserID string `json:"-" gorm:"index;"`
|
||||
Token string `json:"token" gorm:"size:255;index;"`
|
||||
RefreshToken string `json:"refreshToken" gorm:"size:255"`
|
||||
|
||||
Expires int64 `json:"expires"`
|
||||
RefreshExpires int64 `json:"refreshExpires"`
|
||||
|
||||
UpdatedAt time.Time `json:"-" gorm:"type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false"`
|
||||
CreatedAt time.Time `json:"-" gorm:"type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false;<-:create"`
|
||||
}
|
||||
|
||||
type RefreshTokenRequest struct {
|
||||
RefreshToken string `json:"refresh_token" binding:"required"`
|
||||
}
|
||||
|
||||
type TokenResponse struct {
|
||||
|
@ -1,9 +1,21 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id" db:"id" gorm:"column:id;size:255;primary_key;"`
|
||||
Username string `json:"username" db:"username" gorm:"column:username;size:50;uniqueIndex;"`
|
||||
Score int32 `json:"score" db:"score" gorm:"column:score;"`
|
||||
Money int32 `json:"money" db:"money" gorm:"column:money;"`
|
||||
Password string `json:"-" db:"password" gorm:"column:password;size:255;not null;"`
|
||||
ID string `json:"id" db:"id" example:"137c1683-2ad6-4201-b256-253828b61c49" gorm:"column:id;size:255;primary_key;"`
|
||||
Username string `json:"username" db:"username" example:"user0" gorm:"column:username;size:50;uniqueIndex;"`
|
||||
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;"`
|
||||
}
|
||||
|
||||
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"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user