using MessagePack;
using SqlSugar;

namespace XPrintServer.DataModel.Models
{
    ///<summary>
    ///订单资源表
    ///</summary>
    [SugarIndex("idx_{split_table}_create_time", nameof(CreateTime), OrderByType.Desc)]
    [SugarIndex("idx_{split_table}_submit_time", nameof(SubmitTime), OrderByType.Desc)]
    [SplitTable(SplitType.Year)]//按年分表 （自带分表支持 年、季、月、周、日）
    [SugarTable("order_info_{year}{month}{day}")]//3个变量必须要有，这么设计为了兼容开始按年，后面改成按月、按日
    public partial class OrderInfo
    {
        public OrderInfo()
        {
        }

        /// <summary>
        /// Id
        /// </summary>           
        [Key("Id")]
        [SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键Id")]
        public Guid Id { get; set; }

        /// <summary>
        /// 订单Id
        /// </summary>        
        [Key("OrderId")]
        [SugarColumn(IsNullable = false, ColumnDescription = "订单Id")]
        public Guid OrderId { get; set; }


        /// <summary>
        /// 生产类型名，区分是那个部件
        /// </summary>        
        [Key("ProductType")]
        [SugarColumn(IsNullable = false, ColumnDescription = "生产类型名，区分是那个部件")]
        public string ProductType { get; set; } = null!;


        /// <summary>
        /// 原始生产包打包路径
        /// </summary>        
        [Key("PacketUrl")]
        [SugarColumn(IsNullable = false, ColumnDescription = "原始生产包打包路径")]
        public string PacketUrl { get; set; } = null!;

        /// <summary>
        /// 场景缩略图URL
        /// </summary>        
        [Key("SceneImageUrl")]
        [SugarColumn(IsNullable = false, ColumnDescription = "场景缩略图URL")]
        public string SceneImageUrl { get; set; } = null!;

        /// <summary>
        /// 场景缩略图OSS相对路径
        /// </summary>        
        [Key("SceneImageObjectName")]
        [SugarColumn(IsNullable = false, ColumnDescription = "场景缩略图OSS相对路径")]
        public string SceneImageObjectName { get; set; } = null!;


        /// <summary>
        /// 原始生产包OSS相对路径
        /// </summary>       
        [Key("PacketObjectName")]
        [SugarColumn(IsNullable = false, ColumnDescription = "原始生产包OSS相对路径")]
        public string PacketObjectName { get; set; } = null!;

        /// <summary>
        /// 资源状态；1：未生产；2:生产中；3:已生产；4：已删除
        /// </summary>
        [Key("ResourceStatus")]
        [SugarColumn(IsNullable = true, DefaultValue = "0", ColumnDescription = "资源状态；1：未生产；2:生产中；3:已生产；4：已删除；")]
        public int ResourceStatus { get; set; } = 0;

        /// <summary>
        /// 订单生产包提交时间
        /// </summary>
        [Key("SubmitTime")]
        [SugarColumn(IsNullable = false,  ColumnDescription = "订单生产包提交时间")]
        public DateTime SubmitTime { get; set; }


        [Key("CreateTime")]
        [SplitField] //分表字段 在插入的时候会根据这个字段插入哪个表，在更新删除的时候用这个字段找出相关表
        public DateTime CreateTime { get; set; }

    }
}
