44 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 (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// MessageIm IM消息表
type MessageIm struct {
MessageId int64 `gorm:"column:message_id;type:bigint(19);primary_key;comment:主键id" json:"message_id"`
FromUserId string `gorm:"column:from_user_id;type:varchar(30);comment:发送方user_id" json:"from_user_id"`
ToUserId int64 `gorm:"column:to_user_id;type:bigint(20);comment:接收方user_id;NOT NULL" json:"to_user_id"`
MessageKey string `gorm:"column:message_key;type:varchar(255);comment:消息唯一标识(系统返回,撤回消息使用)" json:"message_key"`
MessageSendTime string `gorm:"column:message_send_time;type:varchar(11);comment:消息发送时间戳" json:"message_send_time"`
MessageSeq int `gorm:"column:message_seq;type:int(11);comment:消息序列号(单聊消息优先使用 MsgTime 进行排序,同一秒发送的消息则按 MsgSeq 排序MsgSeq 值越大消息越靠后)" json:"message_seq"`
MessageSendResult int `gorm:"column:message_send_result;type:tinyint(4);default:0;comment:消息下发结果0:失败 1:成功)" json:"message_send_result"`
SendErrorInfo string `gorm:"column:send_error_info;type:varchar(255);comment:消息下发失败原因" json:"send_error_info"`
MessageType string `gorm:"column:message_type;type:varchar(50);comment:消息类型具体查看https://cloud.tencent.com/document/product/269/2720" json:"message_type"`
IsSystem int `gorm:"column:is_system;type:tinyint(4);default:0;comment:是否系统操作发送0:否 1:是)" json:"is_system"`
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);comment:问诊id自定义字段" json:"order_inquiry_id"`
MessageContent string `gorm:"column:message_content;type:text;comment:消息内容json形式" json:"message_content"`
MessageCustomContent string `gorm:"column:message_custom_content;type:text;comment:自定义消息内容json形式" json:"message_custom_content"`
Model
}
func (m *MessageIm) TableName() string {
return "gdxz_message_im"
}
func (m *MessageIm) BeforeCreate(tx *gorm.DB) error {
if m.MessageId == 0 {
m.MessageId = 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
}