flower-story/Server/Data/Model/CommentItem.cs
2023-08-09 17:34:18 +08:00

100 lines
2.1 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.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
namespace Blahblah.FlowerStory.Server.Data.Model;
/// <summary>
/// 评论对象
/// </summary>
[Table("comments")]
public class CommentItem
{
/// <summary>
/// 自增 id主键
/// </summary>
[Column("cid")]
[Key]
[Required]
public int Id { get; set; }
/// <summary>
/// 关联人 id
/// </summary>
[Column("uid")]
[ForeignKey(nameof(Owner))]
[Required]
public int OwnerId { get; set; }
/// <summary>
/// 关联人
/// </summary>
[JsonIgnore]
public UserItem? Owner { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[Column("date")]
[Required]
[JsonPropertyName("date")]
public long DateUnixTime { get; set; }
/// <summary>
/// 关联的事件 id
/// </summary>
[Column("rid")]
[Required]
[ForeignKey(nameof(Record))]
public int RecordId { get; set; }
/// <summary>
/// 关联的事件
/// </summary>
[JsonIgnore]
public RecordItem Record { get; set; } = null!;
/// <summary>
/// 评论类别1-点赞2-收藏3-标签default-评论
/// </summary>
[Column("category")]
public int? CommentCategoryId { get; set; }
/// <summary>
/// 操作人 uid
/// </summary>
[Column("byuid")]
public int? ByUserId { get; set; }
/// <summary>
/// 操作人名称
/// </summary>
[Column("byname")]
public string? ByUserName { get; set; }
/// <summary>
/// 备注
/// </summary>
[Column("text")]
public string? Text { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[NotMapped]
[JsonIgnore]
public DateTimeOffset Date => DateTimeOffset.FromUnixTimeMilliseconds(DateUnixTime);
/// <summary>
/// 纬度
/// </summary>
[Column("latitude")]
public double? Latitude { get; set; }
/// <summary>
/// 经度
/// </summary>
[Column("longitude")]
public double? Longitude { get; set; }
}