case-open-api/api/model/UserBehaviorRecord.go

38 lines
1.3 KiB
Go

package model
import (
"case-open-api/global"
"gorm.io/gorm"
"time"
)
// UserBehaviorRecord 用户操作记录
type UserBehaviorRecord struct {
RecordId int64 `gorm:"column:record_id;type:bigint(19);primary_key;comment:主键id" json:"record_id"`
CaseId int64 `gorm:"column:case_id;type:bigint(19);comment:病例id;NOT NULL" json:"case_id"`
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);comment:平台id;NOT NULL" json:"platform_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
Step string `gorm:"column:step;type:varchar(100);comment:步骤名称" json:"step"`
StartTime LocalTime `gorm:"column:start_time;type:datetime;comment:开始时间" json:"start_time"`
EndTime LocalTime `gorm:"column:end_time;type:datetime;comment:结束时间" json:"end_time"`
Model
}
func (m *UserBehaviorRecord) TableName() string {
return "user_behavior_record"
}
func (m *UserBehaviorRecord) BeforeCreate(tx *gorm.DB) error {
if m.RecordId == 0 {
m.RecordId = 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
}