using SqlSugar;
using XF.Domain.Repository;

namespace DataSharing.RawData
{
    /// <summary>
    /// 公告
    /// </summary>
    public class DsBulletin : CreationEntity
    {
        /// <summary>
        /// 通知公告Id
        /// </summary>
        public string BulletinId { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        [SugarColumn(ColumnDataType = "text")]
        public string Content { get; set; }

        /// <summary>
        /// 公告类型ID
        /// </summary>
        public string BulletinTypeId { get; set; }

        /// <summary>
        /// 公告类型名称
        /// </summary>
        public string BulletinTypeName { get; set; }

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

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

        /// <summary>
        /// 失效时间
        /// </summary>
        public DateTime LoseEfficacyTime { 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>
        /// 阅读量+1
        /// </summary>
        public void Read()
        {
            ReadedNum++;
        }
    }

    public class Kv
    {
        public Kv()
        {
        }

        public Kv(string key, string value)
        {
            Key = key;
            Value = value;
        }

        public string Key { get; set; }
        public string Value { get; set; }
    }
}
