flower-story/Server/Data/Model/RecordItem.cs
2023-07-13 12:10:30 +08:00

106 lines
2.2 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("records")]
public class RecordItem : ILocation
{
/// <summary>
/// 自增 id主键
/// </summary>
[Column("rid")]
[Key]
[Required]
public int Id { get; set; }
/// <summary>
/// 关联人 id
/// </summary>
[Column("uid")]
[ForeignKey(nameof(Owner))]
[Required]
public required int OwnerId { get; set; }
/// <summary>
/// 关联人
/// </summary>
[JsonIgnore]
public UserItem? Owner { get; set; }
/// <summary>
/// 关联花草 id
/// </summary>
[Column("fid")]
[ForeignKey(nameof(Flower))]
[Required]
public required int FlowerId { get; set; }
/// <summary>
/// 关联花草
/// </summary>
[JsonIgnore]
public FlowerItem? Flower { get; set; }
/// <summary>
/// 事件类型
/// </summary>
[Column("eid")]
[Required]
public required int EventId { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[Column("date")]
[Required]
[JsonPropertyName("date")]
public required long DateUnixTime { get; set; }
/// <summary>
/// 操作人 uid
/// </summary>
[Column("byuid")]
public int? ByUserId { get; set; }
/// <summary>
/// 操作人名称
/// </summary>
[Column("byname")]
public string? ByUserName { get; set; }
/// <summary>
/// 备注
/// </summary>
[Column("memo")]
public string? Memo { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[NotMapped]
[JsonIgnore]
public DateTimeOffset Date => DateTimeOffset.FromUnixTimeMilliseconds(DateUnixTime);
/// <summary>
/// 事件关联照片
/// </summary>
public ICollection<PhotoItem>? Photos { get; set; }
/// <summary>
/// 纬度
/// </summary>
[Column("latitude")]
public double? Latitude { get; set; }
/// <summary>
/// 经度
/// </summary>
[Column("longitude")]
public double? Longitude { get; set; }
}