package model import ( "case-admin-api/global" "gorm.io/gorm" "time" ) // CaseCommentLike 病历-评论-点赞 type CaseCommentLike struct { LikeId int64 `gorm:"column:like_id;type:bigint(19);primary_key;comment:主键id" json:"like_id"` CommentId int64 `gorm:"column:comment_id;type:bigint(19);comment:评论id" json:"comment_id"` UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"` Model } func (m *CaseCommentLike) TableName() string { return "case_comment_like" } func (m *CaseCommentLike) BeforeCreate(tx *gorm.DB) error { if m.LikeId == 0 { m.LikeId = 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 }