using Furion.DataValidation;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YBDevice.Application.OfficeialInfo
{
    /// <summary>
    /// 订阅消息模板列表
    /// </summary>
    public class MiniSubscribeTplS2CDto
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 添加至帐号下的模板 id，发送小程序订阅消息时所需
        /// </summary>
        public string PriTmplId { get; set; }

        /// <summary>
        /// 模板标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 模板关键字列表,多个以|分隔
        /// </summary>
        public string KeyWords { get; set; }
        /// <summary>
        /// 模板关键字对应的值,多个以|分隔
        /// </summary>
        public string Example { get; set; }
        /// <summary>
        /// 模板类型,2-一次性订阅,3-长期订阅
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// 是否选取,true-是,false-否
        /// </summary>
        public bool IsSelected { get; set; }
    }
    /// <summary>
    /// 设置订阅消息模板内容
    /// </summary>
    public class SubscribeTplContentC2SDto
    {
        /// <summary>
        /// 模板主键ID
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 模板内容
        /// </summary>
        public string Content { get; set; }
    }
    /// <summary>
    /// 设置订阅消息模板状态
    /// </summary>
    public class SubscribeTplStatusC2SDto
    {
        /// <summary>
        /// 模板主键ID
        /// </summary>
        [Required(ErrorMessage = "请先选择模板")]
        public Guid Id { get; set; }
        /// <summary>
        /// 是否选择,true-是,false-否
        /// </summary>
        public bool IsSelected { get; set; }
    }
    /// <summary>
    /// 微信客服设置
    /// </summary>
    public class CustomServiceC2SDto
    {
        /// <summary>
        /// 小程序主键ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 企业微信appid
        /// </summary>
        [Required(ErrorMessage = "请输入企业ID"), MaxLength(50, ErrorMessage = "企业ID最多50个字")]
        public string QyAppId { get; set; }
        /// <summary>
        /// 客服链接
        /// </summary>
        [Required(ErrorMessage = "请输入客服链接"), MaxLength(100, ErrorMessage = "客服链接最多100个字")]
        [DataValidation(ValidationTypes.Url, ErrorMessage = "客服链接格式不正确")]
        public string Url { get; set; }
    }
    /// <summary>
    /// 小程序域名配置
    /// </summary>
    public class MiniDomainC2SDto : IValidatableObject
    {

        /// <summary>
        /// 小程序记录ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 域名列表
        /// </summary>
        public List<string> List { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Id <= 0)
            {
                yield return new ValidationResult(
                "请先选择小程序"
                , new[] { nameof(Id) }
            );
            }
            if (List == null || List.Count == 0)
            {
                yield return new ValidationResult(
                "域名不可为空"
                , new[] { nameof(List) }
            );
            }
        }
    }
}
