case-api/api/model/CaseItemQuestion.go
2025-03-07 16:57:28 +08:00

40 lines
1.7 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 (
"case-api/global"
"gorm.io/gorm"
"time"
)
// CaseItemQuestion 病历表-明细-题目
type CaseItemQuestion struct {
QuestionId int64 `gorm:"column:question_id;type:bigint(19);primary_key;comment:主键id" json:"question_id"`
CaseItemId int64 `gorm:"column:case_item_id;type:bigint(19);comment:病例明细id;NOT NULL" json:"case_item_id"`
QuestionName string `gorm:"column:question_name;type:varchar(1000);comment:题目名称" json:"question_name"`
QuestionType int `gorm:"column:question_type;type:tinyint(1);comment:题目类型(1:单选 2:多选 3:问答 4:判断)" json:"question_type"`
QuestionAnswer string `gorm:"column:question_answer;type:varchar(255);comment:答案" json:"question_answer"`
IsRightNext int `gorm:"column:is_right_next;type:tinyint(1);default:1;comment:是否答对后允许下一步0:否 1:是)" json:"is_right_next"`
ErrorTips string `gorm:"column:error_tips;type:varchar(200);comment:答错提示" json:"error_tips"`
Model
CaseItemQuestionOption []*CaseItemQuestionOption `gorm:"foreignKey:QuestionId;references:question_id" json:"case_item_question_option"`
StatCaseQuestion []*StatCaseQuestion `gorm:"foreignKey:QuestionId;references:question_id" json:"stat_case_question"`
}
func (m *CaseItemQuestion) TableName() string {
return "case_item_question"
}
func (m *CaseItemQuestion) BeforeCreate(tx *gorm.DB) error {
if m.QuestionId == 0 {
m.QuestionId = 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
}