case-open-api/api/model/CaseItem.go
2024-12-30 16:34:26 +08:00

37 lines
1.2 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-open-api/global"
"gorm.io/gorm"
"time"
)
// CaseItem 病历表-明细
type CaseItem struct {
CaseItemId int64 `gorm:"column:case_item_id;type:bigint(19);primary_key;comment:主键id" json:"case_item_id"`
CaseId int64 `gorm:"column:case_id;type:bigint(19);comment:所属病例id;NOT NULL" json:"case_id"`
Page int `gorm:"column:page;type:int(1);default:1;comment:页码" json:"page"`
Content string `gorm:"column:content;type:text;comment:详情内容" json:"content"`
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
}
func (m *CaseItem) TableName() string {
return "case_item"
}
func (m *CaseItem) BeforeCreate(tx *gorm.DB) error {
if m.CaseItemId == 0 {
m.CaseItemId = 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
}