case-admin-api/api/model/CaseComment.go
2025-03-07 17:23:50 +08:00

46 lines
2.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}