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

34 lines
926 B
Go

package model
import (
"case-api/global"
"gorm.io/gorm"
"time"
)
// CaseItemQuestionOption 病历表-明细-题目-选项
type CaseItemQuestionOption struct {
OptionId int64 `gorm:"column:option_id;type:bigint(19);primary_key;comment:主键id" json:"option_id"`
QuestionId int64 `gorm:"column:question_id;type:bigint(19);comment:题目id;NOT NULL" json:"question_id"`
OptionValue string `gorm:"column:option_value;type:varchar(255);comment:选项内容" json:"option_value"`
Model
}
func (m *CaseItemQuestionOption) TableName() string {
return "case_item_question_option"
}
func (m *CaseItemQuestionOption) BeforeCreate(tx *gorm.DB) error {
if m.OptionId == 0 {
m.OptionId = 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
}