2025-06-19 10:33:58 +08:00

63 lines
1.6 KiB
Go

package schema
import (
"github.guxuan/haibei/pkg/util"
)
// Defining the `Grade` struct.
type Grade struct {
util.BaseModel
Name string `json:"name" gorm:"size:255;not null;index;comment:等级名称"`
Introduce string `json:"introduce" gorm:"size:2048;comment:等级介绍"`
Icon string `json:"icon" gorm:"size:2048;comment:等级icon"`
Score int `json:"score" gorm:"not null;unique;comment:等级积分"`
Lv string `json:"lv" gorm:"index;not null;unique;comment:等级级别"`
Status string `json:"status" gorm:"size:20;index;comment:等级状态"`
}
// Defining the query parameters for the `Grade` struct.
type GradeQueryParam struct {
util.PaginationParam
Status string `form:"status" `
}
// Defining the query options for the `Grade` struct.
type GradeQueryOptions struct {
util.QueryOptions
}
// Defining the query result for the `Grade` struct.
type GradeQueryResult struct {
Data Grades
PageResult *util.PaginationResult
}
// Defining the slice of `Grade` struct.
type Grades []*Grade
// Defining the data structure for creating a `Grade` struct.
type GradeForm struct {
Name string `json:"name"`
Introduce string `json:"introduce" `
Icon string `json:"icon" `
Score int `json:"score"`
Lv string `json:"lv"`
Status string `json:"status" `
}
// A validation function for the `GradeForm` struct.
func (a *GradeForm) Validate() error {
return nil
}
// Convert `GradeForm` to `Grade` object.
func (a *GradeForm) FillTo(grade *Grade) error {
grade.Name = a.Name
grade.Introduce = a.Introduce
grade.Icon = a.Icon
grade.Score = a.Score
grade.Lv = a.Lv
grade.Status = a.Status
return nil
}