41 lines
1.5 KiB
Go
41 lines
1.5 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 TableNameRecord = "records"
|
|
|
|
// Record mapped from table <records>
|
|
type Record struct {
|
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
|
Sn int64 `gorm:"column:sn;not null;comment:业务唯一编号" json:"sn"` // 业务唯一编号
|
|
UserSn int64 `gorm:"column:user_sn;not null;comment:用户-唯一编号" json:"user_sn"` // 用户-唯一编号
|
|
QuestionSn int64 `gorm:"column:question_sn;not null;comment:题目-唯一编号" json:"question_sn"` // 题目-唯一编号
|
|
Answer string `gorm:"column:answer;not null;comment:答案" json:"answer"` // 答案
|
|
IsCorrect int32 `gorm:"column:is_correct;not null;comment:是否正确 0 否 1 是" json:"is_correct"` // 是否正确 0 否 1 是
|
|
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 Record's table name
|
|
func (*Record) TableName() string {
|
|
return TableNameRecord
|
|
}
|
|
|
|
// Auto sn
|
|
func (m *Record) BeforeCreate(_ *gorm.DB) error {
|
|
if m.Sn == 0 {
|
|
m.Sn = utils.SnowflakeInstance().Generate().Int64()
|
|
}
|
|
return nil
|
|
}
|