1
This commit is contained in:
@@ -8,12 +8,9 @@ import (
|
||||
|
||||
// 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"`
|
||||
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"`
|
||||
Model
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"case-open-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
|
||||
}
|
||||
Reference in New Issue
Block a user