43 lines
1.7 KiB
Go
43 lines
1.7 KiB
Go
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.hlsq.asia/mmorpg/service-common/utils"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
const TableNameQuestion = "questions"
|
|
|
|
// Question mapped from table <questions>
|
|
type Question struct {
|
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
|
Sn string `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
|
|
Question string `gorm:"column:question;not null;comment:题干" json:"question"` // 题干
|
|
Options string `gorm:"column:options;not null;comment:选项" json:"options"` // 选项
|
|
Answer string `gorm:"column:answer;not null;comment:答案" json:"answer"` // 答案
|
|
Explanation string `gorm:"column:explanation;not null;comment:解析" json:"explanation"` // 解析
|
|
Difficulty int32 `gorm:"column:difficulty;not null;comment:难度分 0 - 100" json:"difficulty"` // 难度分 0 - 100
|
|
CategorySn string `gorm:"column:category_sn;not null;comment:分类-唯一编号" json:"category_sn"` // 分类-唯一编号
|
|
CreatedAt time.Time `gorm:"column:created_at;not null" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at;not null" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at" json:"deleted_at"`
|
|
}
|
|
|
|
// TableName Question's table name
|
|
func (*Question) TableName() string {
|
|
return TableNameQuestion
|
|
}
|
|
|
|
// Auto sn
|
|
func (m *Question) BeforeCreate(_ *gorm.DB) error {
|
|
if m.Sn == "" {
|
|
m.Sn = utils.SnowflakeInstance().Generate().String()
|
|
}
|
|
return nil
|
|
}
|