新增了飞花令数量1

This commit is contained in:
2024-11-12 10:41:12 +08:00
parent 472f25fb61
commit 51af306add
6 changed files with 207 additions and 2 deletions
+2
View File
@@ -17,6 +17,7 @@ type QuestionQa struct {
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"`
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"`
@@ -25,6 +26,7 @@ type QuestionQa struct {
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 {
+35
View File
@@ -0,0 +1,35 @@
package model
import (
"gorm.io/gorm"
"knowledge/global"
"time"
)
// QuestionQaTimer 知识问答-计时设置
type QuestionQaTimer struct {
TimerId int64 `gorm:"column:timer_id;type:bigint(19);primary_key;comment:主键id" json:"timer_id"`
QaId int64 `gorm:"column:qa_id;type:bigint(19);comment:知识问答id;NOT NULL" json:"qa_id"`
QuestionType int `gorm:"column:question_type;type:tinyint(1);default:1;comment:题目类型(1:单选 2:多选 3:问答 4:判断)" json:"question_type"`
TimerRule int `gorm:"column:timer_rule;type:tinyint(1);default:1;comment:计时规则(1:正计时 2:倒计时)" json:"timer_rule"`
Duration int `gorm:"column:duration;type:int(1);default:1;comment:时长(秒)" json:"duration"`
Model
}
func (m *QuestionQaTimer) TableName() string {
return "kb_question_qa_timer"
}
func (m *QuestionQaTimer) BeforeCreate(tx *gorm.DB) error {
if m.TimerId == 0 {
m.TimerId = 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
}