新增了 问答题库管理
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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"`
|
||||
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"`
|
||||
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"`
|
||||
QaExpireTime LocalTime `gorm:"column:qa_expire_time;type:datetime;comment:过期时间" json:"qa_expire_time"`
|
||||
QaLink string `gorm:"column:qa_link;type:varchar(255);comment:分享链接" json:"qa_link"`
|
||||
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"`
|
||||
Model
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"knowledge/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// QuestionQaItem 知识问答-明细
|
||||
type QuestionQaItem struct {
|
||||
ItemId int64 `gorm:"column:item_id;type:bigint(19);primary_key;comment:主键id" json:"item_id"`
|
||||
QaId int64 `gorm:"column:qa_id;type:bigint(19);comment:知识问答id;NOT NULL" json:"qa_id"`
|
||||
QuestionId int64 `gorm:"column:question_id;type:bigint(19);comment:题目id;NOT NULL" json:"question_id"`
|
||||
IsMustSelect int `gorm:"column:is_must_select;type:tinyint(1);default:0;comment:是否必被选中(0:否 1:是)" json:"is_must_select"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *QuestionQaItem) TableName() string {
|
||||
return "kb_question_qa_item"
|
||||
}
|
||||
|
||||
func (m *QuestionQaItem) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ItemId == 0 {
|
||||
m.ItemId = 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
|
||||
}
|
||||
Reference in New Issue
Block a user