73 lines
1.9 KiB
C#
73 lines
1.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.ComponentModel.DataAnnotations.Schema;
|
||
using Microsoft.EntityFrameworkCore;
|
||
|
||
namespace IM_API.Models;
|
||
|
||
[Table("messages")]
|
||
[Index("Sender", Name = "Sender")]
|
||
[MySqlCharSet("utf8mb4")]
|
||
[MySqlCollation("utf8mb4_general_ci")]
|
||
public partial class Message
|
||
{
|
||
[Key]
|
||
[Column("ID", TypeName = "int(11)")]
|
||
public int Id { get; set; }
|
||
|
||
/// <summary>
|
||
/// 聊天类型
|
||
/// (0:私聊,1:群聊)
|
||
/// </summary>
|
||
[Column(TypeName = "tinyint(4)")]
|
||
public sbyte ChatType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息类型
|
||
/// (0:文本,1:图片,2:语音,3:视频,4:文件,5:语音聊天,6:视频聊天)
|
||
/// </summary>
|
||
[Column(TypeName = "tinyint(4)")]
|
||
public sbyte MsgType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息内容
|
||
/// </summary>
|
||
[Column(TypeName = "text")]
|
||
public string Content { get; set; } = null!;
|
||
|
||
/// <summary>
|
||
/// 发送者
|
||
/// </summary>
|
||
[Column(TypeName = "int(11)")]
|
||
public int Sender { get; set; }
|
||
|
||
/// <summary>
|
||
/// 接收者(私聊为用户ID,群聊为群聊ID)
|
||
/// </summary>
|
||
[Column(TypeName = "int(11)")]
|
||
public int Recipient { get; set; }
|
||
|
||
/// <summary>
|
||
/// 消息状态(0:已发送,1:已撤回)
|
||
/// </summary>
|
||
[Column(TypeName = "tinyint(4)")]
|
||
public sbyte State { get; set; }
|
||
|
||
/// <summary>
|
||
/// 发送时间
|
||
/// </summary>
|
||
[Column(TypeName = "datetime")]
|
||
public DateTime Created { get; set; }
|
||
|
||
[InverseProperty("LastMessage")]
|
||
public virtual ICollection<Conversation> Conversations { get; set; } = new List<Conversation>();
|
||
|
||
[InverseProperty("MessageldNavigation")]
|
||
public virtual ICollection<File> Files { get; set; } = new List<File>();
|
||
|
||
[ForeignKey("Sender")]
|
||
[InverseProperty("Messages")]
|
||
public virtual User SenderNavigation { get; set; } = null!;
|
||
}
|