using CZFW.Core;
using CZFW.Framework.Attributes;
using CZFW.Framework.Model.Entity;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace CZKJ.GBRS2.Entity
{
    [Table("cz_gbrs2_video")]
    public class VideoEntity : EntityBase,ISeo ,IShare
    {
        /// <summary>
        /// 名称
        /// </summary>
        [Display(Name = "名称")]
        [StringLength(64)]
        [Required]
        public string Name { get; set; }
        /// <summary>
        /// 视频链接
        /// </summary>
        [Display(Name = "视频链接")]
        [StringLength(2048)]
        [Required]
        [DataType(DataType.MultilineText)]
        public string Url { get; set; }
        /// <summary>
        /// 图片
        /// </summary>
        [Display(Name = "图片",Description ="图片尺寸:385*280px")]
        [StringLength(1024)]
        [DataType(DataType.ImageUrl)]
        public string Image { get; set; }
        /// <summary>
        /// 介绍
        /// </summary>
        [StringLength(1024)]
        [Display(Name = "介绍")]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }
        #region SEO及分享
        [NotMapped]
        private string seotitle;
        [NotMapped]
        private string seodescription;
        [NotMapped]
        private string seokeywords;
        [NotMapped]
        private string sharetitle;
        [NotMapped]
        private string sharedescription;
        [NotMapped]
        private string shareurl;
        [NotMapped]
        private string shareimage;

        [StringLength(128)]
        [Display(Name = "SEO标题")]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string SeoTitle
        {
            get { return string.IsNullOrEmpty(seotitle) ? Name : seotitle; }
            set { seotitle = value; }
        }

        /// <summary>
        /// SEO描述
        /// </summary>
        [StringLength(512)]
        [Display(Name = @"SEO描述")]
        [DataType(DataType.MultilineText)]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string SeoDescription
        {
            get { return string.IsNullOrEmpty(seodescription) ? Description : seodescription; }
            set { seodescription = value; }
        }

        /// <summary>
        /// SEO关键词
        /// </summary>
        [StringLength(128)]
        [Display(Name = @"SEO关键词")]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string SeoKeywords
        {
            get { return string.IsNullOrEmpty(seokeywords) ? Name : seokeywords; }
            set { seokeywords = value; }
        }

        /// <summary>
        /// 分享图片
        /// </summary>
        [StringLength(512)]
        [Display(Name = @"分享图片")]
        [DataType(DataType.ImageUrl)]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string ShareImage
        {
            get { return string.IsNullOrEmpty(shareimage) ? Image : shareimage; }
            set { shareimage = value; }
        }

        /// <summary>
        /// 分享标题
        /// </summary>
        [StringLength(128)]
        [Display(Name = @"分享标题")]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string ShareTitle
        {
            get { return string.IsNullOrEmpty(sharetitle) ? Name : sharetitle; }
            set { sharetitle = value; }
        }

        /// <summary>
        /// 分享URL
        /// </summary>
        [StringLength(512)]
        [Display(Name = @"分享URL")]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string ShareUrl
        {
            get { return string.IsNullOrEmpty(shareurl) ? ConfigHelper.GetValue<string>("SystemInfo:Website") : shareurl; }
            set { shareurl = value; }
        }

        /// <summary>
        /// 分享描述
        /// </summary>
        [StringLength(512)]
        [Display(Name = @"分享描述")]
        [Invisible(FormVisible = true, AddVisible = true)]
        public string ShareDescription
        {
            get { return string.IsNullOrEmpty(sharedescription) ? Description : sharedescription; }
            set { sharedescription = value; }
        }

        #endregion
    }
}