Documentation
¶
Index ¶
- Variables
- func GetUserProblemType(userId uint) ([]string, error)
- func Init(ctx context.Context) error
- func PickRandonFinished(userId uint, ttype string) (bool, error)
- func PickRandonUnPicked(userId uint, ttype string) (bool, error)
- type Conf
- type CustomClaims
- type JWT
- type LoginParam
- type OverviewRes
- type Problem
- type RegisterParam
- type TodoItem
- type UpdateProblemParam
- type User
- type UserConfig
- type UserProblem
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GetUserProblemType ¶
func PickRandonFinished ¶
PickRandonFinished 随机选一道做过的题
Types ¶
type CustomClaims ¶
type CustomClaims struct {
UserID uint `json:"userId"`
Name string `json:"name"`
Email string `json:"email"`
Phone string `json:"phone"`
Role string `json:"role"`
jwt.StandardClaims
}
载荷,可以加一些自己需要的信息
type JWT ¶
type JWT struct {
SigningKey []byte
}
JWT 签名结构
func (*JWT) CreateToken ¶
func (j *JWT) CreateToken(claims CustomClaims) (string, error)
CreateToken 生成一个token
func (*JWT) ParseToken ¶
func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)
ParseToken 解析Token
type LoginParam ¶
type OverviewRes ¶ added in v1.0.0
type Problem ¶
type Problem struct {
gorm.Model
Name string `gorm:"column:name" json:"name" validate:"required"` //题目标题
Content string `gorm:"column:content;type:text" json:"content"` //题解内容
Result string `gorm:"column:result;type:text" json:"result"` //题目答案
Link string `gorm:"column:link" json:"link"` //题目链接
Type string `gorm:"column:type" json:"type"` //题目类别 algorithm、sql...
SubType string `gorm:"column:sub_type" json:"sub_type"` //题目子类别 图、树、数组...
IsPublic bool `gorm:"column:is_public" json:"is_public"` //题目是否公开
CreatorID uint `gorm:"column:creator_id" json:"creator_id"` //题目创建者ID
Creator User `gorm:"foreignKey:CreatorID" json:"-"` //题目创建者
}
func (Problem) AddToUserStudyPlan ¶
将题目加入某用户的学习计划
type RegisterParam ¶
type UpdateProblemParam ¶
type UpdateProblemParam struct {
ID uint `json:"id" validate:"required"` //题目ID
Name string `json:"name" validate:"required"` //题目标题
Content string `json:"content"` //题解内容
Result string `json:"result"` //题目答案
Link string `json:"link"` //题目链接
Type string `json:"type"` //题目类别 algorithm、sql...
SubType string `json:"sub_type"` //题目子类别 图、树、数组...
IsPublic bool `json:"is_public"` //题目是否公开
}
func (*UpdateProblemParam) ToMap ¶
func (param *UpdateProblemParam) ToMap() map[string]interface{}
type User ¶
type User struct {
gorm.Model
Name string `gorm:"column:name" json:"name"`
Email string `gorm:"column:email" json:"email"`
Phone string `gorm:"column:phone" json:"phone"`
Password string `gorm:"column:password" json:"-"`
Role string `gorm:"column:role" json:"role"`
PersistDay int `gorm:"column:persist_day" json:"persist_day"`
InterruptDay int `gorm:"column:interrupt_day" json:"interrupt_day"`
Config UserConfig `gorm:"column:config;type:string" json:"config"`
}
func GetAllUsers ¶
func LoginCheck ¶
func LoginCheck(param LoginParam) (User, error)
func Register ¶
func Register(param RegisterParam) (User, error)
func (*User) UpdateComplete ¶ added in v1.0.0
type UserConfig ¶
type UserProblem ¶
type UserProblem struct {
gorm.Model
UserId uint `gorm:"column:user_id;primaryKey"` //用户ID
ProblemId uint `gorm:"column:problem_id;primaryKey"` //题目ID
ProblemType string `gorm:"column:problem_type"` //题目类型
Picked bool `gorm:"column:picked"` //是否被选
PickTime time.Time `gorm:"column:pick_time"` //选题时间
Finished bool `gorm:"column:finished"` //是否完成
Times int `gorm:"column:times"` //已做次数
}
func (UserProblem) RemoveFromUserPlan ¶
func (up UserProblem) RemoveFromUserPlan() error
Click to show internal directories.
Click to hide internal directories.