using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Mapster;

namespace YGNT.Infrastructure.AbpEntity
{
    public class AutoIdEntity : Entity<string>
    {
        [Column("id")]
        public override string Id { get; set; }

        public AutoIdEntity()
        {
            Id = DbHelper.GetPk();
        }
    }

    public class BaseEntity : AutoIdEntity, IHasCreationTime, IHasModificationTime
    {
        [AdaptIgnore]
        [Column("create_time", TypeName = "timestamp")]
        public DateTime CreationTime { get; set; }
        [AdaptIgnore]
        [Column("last_update", TypeName = "timestamp")]
        public DateTime? LastModificationTime { get; set; } = DateTime.Now;
    }


    public class FullBaseEntity : BaseEntity, IDelete
    {
        [Column("del_status", TypeName = "int(11)")]
        public int? DelStatus { get; set; } = 1;
    }

    public class EntityBase : Entity, IDelete, IHasCreationTime, IHasModificationTime
    {
        [Column("id")]
        public override int Id { get; set; }

        [Column("del_status", TypeName = "int(11)")]
        public int? DelStatus { get; set; } = 1;

        [Column("create_time", TypeName = "timestamp")]
        public DateTime CreationTime { get; set; }

        [Column("last_update", TypeName = "timestamp")]
        public DateTime? LastModificationTime { get; set; } = DateTime.Now;
    }

    public class EntityBase<TKey> : Entity<TKey>, IHasCreationTime, IHasModificationTime
    {
        [Column("id")]
        public override TKey Id { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        [Column("create_time", TypeName = "timestamp")]
        public DateTime CreationTime { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        [Column("last_update", TypeName = "timestamp")]
        public DateTime? LastModificationTime { get; set; } = DateTime.Now;
    }

    public class EntityBaseSoftDelete<TKey> : EntityBase<TKey>, IDelete
    {
        /// <summary>
        /// 删除状态
        /// </summary>
        [Column("del_status", TypeName = "int(11)")]
        public int? DelStatus { get; set; } = 1;
    }

    public interface IDelete
    {
        int? DelStatus { get; set; }
    }
}