package model import ( "case-admin-api/global" "gorm.io/gorm" "time" ) // CaseComment 病历表-评论 type CaseComment struct { CommentId int64 `gorm:"column:comment_id;type:bigint(19);primary_key;comment:主键id" json:"comment_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"` ParentId int64 `gorm:"column:parent_id;type:bigint(19);comment:父级id,一级评论为null" json:"parent_id"` RootId int64 `gorm:"column:root_id;type:bigint(19);comment:根评论id,一级评论时为null。其余为一级评论id" json:"root_id"` Level int `gorm:"column:level;type:tinyint(1);default:1;comment:级别(1:留言 2:回复 3:评论)" json:"level"` UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"` Status int `gorm:"column:status;type:tinyint(1);default:1;comment:评论状态(0:禁用 1:正常)" json:"status"` IsSensitive int `gorm:"column:is_sensitive;type:tinyint(1);default:0;comment:是否存在敏感词(0:否 1:是)" json:"is_sensitive"` IsHighQuality int `gorm:"column:is_high_quality;type:tinyint(1);default:0;comment:是否优质留言(0:否 1:是)" json:"is_high_quality"` IsGrantHighQuality int `gorm:"column:is_grant_high_quality;type:tinyint(1);default:0;comment:优质留言积分是否已发放(0:否 1:是)" json:"is_grant_high_quality"` LikeNum int `gorm:"column:like_num;type:int(5);default:0;comment:点赞数量" json:"like_num"` Content string `gorm:"column:content;type:varchar(500);comment:评论内容" json:"content"` ContentWord string `gorm:"column:content_word;type:varchar(500);comment:评论内容(原版)" json:"content_word"` Model User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` } func (m *CaseComment) TableName() string { return "case_comment" } func (m *CaseComment) BeforeCreate(tx *gorm.DB) error { if m.CommentId == 0 { m.CommentId = 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 }