knowledge-api/api/model/QuestionQa.go

50 lines
3.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"gorm.io/gorm"
"knowledge/global"
"time"
)
// QuestionQa 知识问答
type QuestionQa struct {
QaId int64 `gorm:"column:qa_id;type:bigint(19);primary_key;comment:主键id" json:"qa_id"`
QaName string `gorm:"column:qa_name;type:varchar(255);comment:名称" json:"qa_name"`
QaType int `gorm:"column:qa_type;type:tinyint(1);default:1;comment:题库类型1:常规模式 2:固定套题模式 3:多轮固定题型模式)" json:"qa_type"`
QaQuantity int `gorm:"column:qa_quantity;type:int(5);default:0;comment:题目数量" json:"qa_quantity"`
QaStatus int `gorm:"column:qa_status;type:int(1);default:1;comment:状态1:正常 2:过期)" json:"qa_status"`
TokenNum *int `gorm:"column:token_num;type:int(1);comment:飞花令数量当题库类型为2、3时存在" json:"token_num"`
RoundNum *int `gorm:"column:round_num;type:int(11);comment:轮次数量当题库类型为3时存在" json:"round_num"`
QaRuleContent string `gorm:"column:qa_rule_content;type:text;comment:规则解释" json:"qa_rule_content"`
QaDisplayType int `gorm:"column:qa_display_type;type:tinyint(1);default:1;comment:展示类型1:常规 2:飞花令)" json:"qa_display_type"`
IsTurnTimer int `gorm:"column:is_turn_timer;type:tinyint(1);default:0;comment:是否开启计时0:否 1:是)" json:"is_turn_timer"`
RepeatQaId string `gorm:"column:repeat_qa_id;type:text;comment:禁止重复id合集(逗号分割)" json:"repeat_qa_id"`
QaExpireTime LocalTime `gorm:"column:qa_expire_time;type:datetime;comment:过期时间" json:"qa_expire_time"`
QaShareId string `gorm:"column:qa_share_id;type:varchar(255);comment:分享标识" json:"qa_share_id"`
QaPassword string `gorm:"column:qa_password;type:varchar(255);comment:分享密码" json:"qa_password"`
OpenNumber int `gorm:"column:open_number;type:int(1);default:0;comment:打开的次数" json:"open_number"`
Image string `gorm:"column:image;type:varchar(255);comment:背景图" json:"image"`
ItemContent string `gorm:"column:item_content;type:text;comment:明细选题json" json:"item_content"`
TokenQuestionContent string `gorm:"column:token_question_content;type:text;comment:飞花令题目数量规则当题库类型为2、3时存在。2表示飞花令后固定题目数量3表示飞花令后单个类型题目数量" json:"token_question_content"`
Model
QuestionQaTimer []*QuestionQaTimer `gorm:"foreignKey:QaId;references:qa_id" json:"question_qa_timer"`
}
func (m *QuestionQa) TableName() string {
return "kb_question_qa"
}
func (m *QuestionQa) BeforeCreate(tx *gorm.DB) error {
if m.QaId == 0 {
m.QaId = global.Snowflake.Generate().Int64()
}
m.CreatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
m.UpdatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
return nil
}