57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package dto
|
|
|
|
import (
|
|
"ckwk/internal/ckwk"
|
|
)
|
|
|
|
type Resp[T any] struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data T `json:"data,omitempty"`
|
|
}
|
|
|
|
func Success[T any](data T) Resp[T] {
|
|
return Resp[T]{
|
|
Code: 0,
|
|
Message: "success",
|
|
Data: data,
|
|
}
|
|
}
|
|
|
|
func Ok() Resp[any] {
|
|
return Resp[any]{
|
|
Code: 0,
|
|
Message: "success",
|
|
Data: nil,
|
|
}
|
|
}
|
|
|
|
func Error(code int, msg string) Resp[any] {
|
|
return Resp[any]{
|
|
Code: code,
|
|
Message: msg,
|
|
Data: nil,
|
|
}
|
|
}
|
|
|
|
type LoginReq struct {
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
Token string `json:"token"`
|
|
Status ckwk.CourseKind `json:"status"`
|
|
Host string `json:"host" binding:"required"`
|
|
}
|
|
|
|
type StudyReq struct {
|
|
NodeID string `json:"node_id"`
|
|
StudyID string `json:"study_id"`
|
|
StudyTime string `json:"study_time"`
|
|
Status ckwk.StudyStatus `json:"status"`
|
|
}
|
|
|
|
type AllRecordReq struct {
|
|
CourseID string `json:"course_id"`
|
|
Page int `json:"page"`
|
|
RecordType ckwk.RecordType `json:"record_type"`
|
|
}
|