using Hotline.Share.Dtos;
using Hotline.Share.Dtos.File;
using Hotline.Share.Enums.Article;
using Hotline.Users;
using SqlSugar;
using XF.Domain.Repository;

namespace Hotline.Article
{
    /// <summary>
    /// 公告
    /// </summary>
    public class Bulletin : CreationEntity
    {
        public string Title { get; set; }

        [SugarColumn(ColumnDataType = "text")]
        public string Content { get; set; }

        public string BulletinTypeId { get; set; }

        public string BulletinTypeName { get; set; }

        /// <summary>
        /// 阅读量
        /// </summary>
        public int ReadedNum { get; set; }

        /// <summary>
        /// 通知时间
        /// </summary>
        public DateTime? BulletinTime { get; set; }

        /// <summary>
        /// 失效时间
        /// </summary>
        public DateTime? LoseEfficacyTime { get; set; }

        /// <summary>
        /// 公告状态
        /// </summary>
        public EBulletinState BulletinState { get; set; }

		/// <summary>
		/// 发布范围（多选） 位枚举  EPushRange
		/// </summary>
		[SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
		public List<Kv>? PushRanges { get; set; }

        /// <summary>
        /// 来源单位ID
        /// </summary>
        public string SourceOrgId { get; set; }

       /// <summary>
       /// 来源单位名称
       /// </summary>
        public string SourceOrgName { get; set; }

        /// <summary>
        /// 提交时间
        /// </summary>
        public DateTime? CommitTime { get; set; }

        /// <summary>
        /// 审核意见
        /// </summary>
        public string? ExaminOpinion { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string? ExaminManId { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(ExaminManId))]
        public User? ExaminMan { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? ExaminTime { get; set; }

        /// <summary>
        /// 是否上架
        /// </summary>
        public bool? IsArrive { get; set; }

        /// <summary>
        /// 显示位置（多选） 位枚举  BulletinDisplayLocation
        /// </summary>
        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
        public List<Kv>? DisplayLocation { get; set; }

        /// <summary>
        /// 旧数据id
        /// </summary>
        public string? OldNoticeId { get; set; }

        /// <summary>
        /// 阅读量+1
        /// </summary>
        public void Read()
        {
            ReadedNum++;
        }

        /// <summary>
        /// 附件
        /// </summary>
        [SugarColumn(ColumnDataType = "json", IsJson = true, IsNullable = true)]
        public List<FileJson>? FileJson { get; set; }
    }
}
