default
This commit is contained in:
20
type/adminTypes.go
Normal file
20
type/adminTypes.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package types
|
||||
|
||||
// ChallengeRequest 定义新增/修改题目的一个请求
|
||||
type ChallengeRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Score int `json:"score" binding:"required"`
|
||||
Flag string `json:"flag"` // 暂时一个题只能一个flag
|
||||
Description string `json:"description"`
|
||||
Attachment []string `json:"attachment"`
|
||||
Category string `json:"category" binding:"required"`
|
||||
Tags string `json:"tags"`
|
||||
Hints []string `json:"hints"`
|
||||
Visible int `json:"visible"`
|
||||
}
|
||||
|
||||
// NoticeRequest 定义新增公告的一个请求
|
||||
type NoticeRequest struct {
|
||||
Title string `form:"title" json:"title" binding:"required"`
|
||||
Content string `form:"content" json:"content" binding:"required"`
|
||||
}
|
58
type/commentypes.go
Normal file
58
type/commentypes.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package types
|
||||
|
||||
//user定义用户结构体。
|
||||
type User struct {
|
||||
ID int `json:"id"` //用户id,唯一,自增
|
||||
Token string `json:"token"` //用户token,唯一
|
||||
Username string `json:"username"` //用户名,唯一
|
||||
Password string `json:"password"` //用户密码md5值,md5(原密码)
|
||||
Email string `json:"email"` //邮箱,唯一
|
||||
Affiliation string `json:"affiliation"` //组织、战队或机构等,非必需,默认为0
|
||||
Country string `json:"country"` //国家,非必需,默认为0
|
||||
Website string `json:"website"` //个人链接,默认为0
|
||||
Hidden int `json:"hidden"` //1:隐藏,0:显示,默认为0
|
||||
Banned int `json:"banned"` //1:禁止,0:正常,默认为1,邮箱激活后为0
|
||||
TeamID int `json:"team_id"` //队伍id,在团队模式下必须,个人模式非必需,默认为0
|
||||
Created int `json:"created"` //用户注册时间,10位数时间戳
|
||||
Role int `json:"role"` //0:普通用户,默认为0,1:普通管理员,2:所有者(最高权限)
|
||||
}
|
||||
|
||||
// Notice 定义一个公告
|
||||
type Notice struct {
|
||||
ID int `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
CreatedAt int `json:"created_at"`
|
||||
}
|
||||
|
||||
// Challenge 定义一个题目
|
||||
type Challenge struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Score int `json:"score"`
|
||||
Flag string `json:"flag"`
|
||||
Description string `json:"description"`
|
||||
Attachment []string `json:"attachment"`
|
||||
Category string `json:"category"`
|
||||
Tags string `json:"tags"`
|
||||
Hints []string `json:"hints"`
|
||||
Visible int `json:"visible"` // 0表示隐藏,1表示可见
|
||||
}
|
||||
|
||||
// Submission 表示一次flag提交记录
|
||||
type Submission struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"uid" gorm:"column:uid"`
|
||||
ChallengeID int `json:"cid" gorm:"column:cid"`
|
||||
Flag string `json:"flag"`
|
||||
IP string `json:"ip"`
|
||||
Time int `json:"submitted_at" gorm:"column:submitted_at"`
|
||||
}
|
||||
|
||||
// Solve 表示一次正确的flag提交记录
|
||||
type Solve struct {
|
||||
ID int `json:"id" `
|
||||
UserID int `json:"uid" gorm:"column:uid"`
|
||||
ChallengeID int `json:"cid" gorm:"column:cid"`
|
||||
Time int `json:"solved_at" gorm:"column:submitted_at"`
|
||||
}
|
124
type/userTypes.go
Normal file
124
type/userTypes.go
Normal file
@@ -0,0 +1,124 @@
|
||||
package types
|
||||
|
||||
// LoginRequest 定义接收登录数据的结构体。
|
||||
type LoginRequest struct {
|
||||
// binding:"required"修饰的字段,若接收为空值,则报错,是必须字段
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Remember bool `json:"remember"`
|
||||
}
|
||||
|
||||
// RegisterRequest 定义接收注册数据的结构体。
|
||||
type RegisterRequest struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Email string `json:"email" binding:"required"`
|
||||
CaptchaID string `json:"captchaid" binding:"required"`
|
||||
Solution string `json:"solution" binding:"required"`
|
||||
}
|
||||
|
||||
// InfoRequest 定义接收用户修改信息的结构体。
|
||||
type InfoRequest struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Email string `json:"email"`
|
||||
Affiliation string `json:"affiliation"`
|
||||
Country string `json:"country"`
|
||||
Website string `json:"website"`
|
||||
}
|
||||
|
||||
// InstallRequest 定义接收installRequest数据的结构体。
|
||||
type InstallRequest struct {
|
||||
Username string `json:"username" binding:"required"`
|
||||
Password string `json:"password" binding:"required"`
|
||||
Email string `json:"email" binding:"required"`
|
||||
}
|
||||
|
||||
// SubmissionRequest 定义接收提交flag数据的结构体。
|
||||
type SubmissionRequest struct {
|
||||
Cid int `json:"cid" binding:"required"`
|
||||
Flag string `json:"flag" binding:"required"`
|
||||
}
|
||||
|
||||
// StudentInfo 定义校内学生信息结构体。
|
||||
type StudentInfo struct {
|
||||
Username string `json:"username"`
|
||||
StudentID string `json:"student_id"`
|
||||
QQ string `json:"qq"`
|
||||
}
|
||||
|
||||
// SubmitStudentInfoRequest 定义接收提交校内学生用户信息的结构体。
|
||||
type SubmitStudentInfoRequest struct {
|
||||
Student1 StudentInfo `json:"student1" binding:"required"`
|
||||
Student2 StudentInfo `json:"student2"`
|
||||
Student3 StudentInfo `json:"student3"`
|
||||
Student4 StudentInfo `json:"student4"`
|
||||
}
|
||||
|
||||
// OthersInfo 定义校外用户信息结构体。
|
||||
type OthersInfo struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
QQ string `json:"qq"`
|
||||
}
|
||||
|
||||
// SubmitOthersInfoRequest 定义接收提交校外学生用户信息的结构体。
|
||||
type SubmitOthersInfoRequest struct {
|
||||
Others1 OthersInfo `json:"others1" binding:"required"`
|
||||
Others2 OthersInfo `json:"others2"`
|
||||
Others3 OthersInfo `json:"others3"`
|
||||
Others4 OthersInfo `json:"others4"`
|
||||
}
|
||||
|
||||
// ScoreResponse 定义返回得分情况结构体。
|
||||
type ScoreResponse struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Score int `json:"score"`
|
||||
}
|
||||
|
||||
// SolveResponse 定义返回解题情况结构体。
|
||||
type SolveResponse struct {
|
||||
ID int `json:"id"`
|
||||
Uid int `json:"uid"`
|
||||
Cid int `json:"cid"`
|
||||
Username string `json:"username"`
|
||||
ChallengeName string `json:"challenge_name"`
|
||||
SubmittedAt int `json:"submitted_at"`
|
||||
Score int `json:"score"`
|
||||
}
|
||||
|
||||
// PublicInfoResponse 定义返回用户公开信息结构体。
|
||||
type PublicInfoResponse struct {
|
||||
Username string `json:"username"`
|
||||
Affiliation string `json:"affiliation"`
|
||||
Country string `json:"country"`
|
||||
TeamID int `json:"team_id"`
|
||||
}
|
||||
|
||||
// ChallengeResponse 定义获取题目的一个响应。
|
||||
type ChallengeResponse struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Score int `json:"score"`
|
||||
Description string `json:"description"` //题目描述
|
||||
Attachment []string `json:"attachment"` //题目附件
|
||||
Category string `json:"category"` //分类
|
||||
Tags string `json:"tags"` //标签
|
||||
Hints []string `json:"hints"` //提示
|
||||
SolverCount int `json:"solver_count"` //解决人数
|
||||
IsSolved bool `json:"is_solved"` // true:已解决,false:未解决
|
||||
}
|
||||
|
||||
// ScoreRankResponse 定义获取当前用户分数和排名的一个响应。
|
||||
type ScoreRankResponse struct {
|
||||
Score int `json:"score"`
|
||||
Rank int `json:"rank"`
|
||||
}
|
||||
|
||||
// StudentsOrOthersInfoResponse 定义获取校内用户或校外用户信息的响应。
|
||||
type StudentsOrOthersInfoResponse struct {
|
||||
Username string `json:"username"`
|
||||
IDOrEmail string `json:"id_email"`
|
||||
QQ string `json:"qq"`
|
||||
}
|
Reference in New Issue
Block a user