35 lines
1008 B
Go
35 lines
1008 B
Go
package model
|
|
|
|
import (
|
|
"case-admin-api/global"
|
|
"gorm.io/gorm"
|
|
"time"
|
|
)
|
|
|
|
// CaseItemModel 病历表-明细
|
|
type CaseItemModel struct {
|
|
CaseItemModelId int64 `gorm:"column:case_item_model_id;type:bigint(19);primary_key;comment:主键id" json:"case_item_model_id"`
|
|
CaseItemId int64 `gorm:"column:case_item_id;type:bigint(19);comment:明细id;NOT NULL" json:"case_item_id"`
|
|
ModelName string `gorm:"column:model_name;type:varchar(200);comment:模型名称" json:"model_name"`
|
|
Content string `gorm:"column:content;type:text;comment:详情内容" json:"content"`
|
|
Model
|
|
}
|
|
|
|
func (m *CaseItemModel) TableName() string {
|
|
return "case_item_model"
|
|
}
|
|
|
|
func (m *CaseItemModel) BeforeCreate(tx *gorm.DB) error {
|
|
if m.CaseItemModelId == 0 {
|
|
m.CaseItemModelId = 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
|
|
}
|