IM/backend/IM_API/Models/Message.cs

73 lines
1.9 KiB
C#
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.

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!;
}