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

namespace YBDevice.NApi.Application.MessageInfo
{
    /// <summary>
    /// 消息订阅
    /// </summary>
    public class SubscribeC2SDto : IValidatableObject
    {
        /// <summary>
        /// 小程序appid
        /// </summary>
        [Required(ErrorMessage ="小程序appid不可为空")]
        public string AppId { get; set; }
        /// <summary>
        /// 订阅的消息类型,1-周提醒,2-月提醒,3-半年提醒,4-一年提醒
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// 订阅的模板状态列表
        /// </summary>
        public List<SubscribeTplS2SDto> List { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            List<int> types = new List<int> { 1, 2, 3, 4 };
            if (!types.Contains(Type))
            {
                yield return new ValidationResult(
                "请选择正确的消息类型"
                , new[] { nameof(Type) }
            );
            }
            if (List == null || List.Count == 0)
            {
                yield return new ValidationResult(
                "未找到可用的模板"
                , new[] { nameof(List) }
            );
            }
        }
    }
    /// <summary>
    /// 取消订阅
    /// </summary>
    public class UnSubscribeC2SDto
    {
        /// <summary>
        /// 小程序appid
        /// </summary>
        [Required(ErrorMessage = "小程序appid不可为空")]
        public string AppId { get; set; }
        /// <summary>
        /// 订阅的消息类型,1-周提醒,2-月提醒,3-半年提醒,4-一年提醒
        /// </summary>
        public int Type { get; set; }
    }

    /// <summary>
    /// 订阅模板
    /// </summary>
    public class SubscribeTplS2SDto
    {
        /// <summary>
        /// 模板ID
        /// </summary>
        [Required(ErrorMessage = "模板ID不可为空")]
        public string TplId { get; set; }
        /// <summary>
        /// 订阅状态,accept-同意,reject-拒绝,ban-已被后台封禁,filter-被过滤
        /// </summary>
        [Required(ErrorMessage = "订阅状态不可为空")]
        public string Status { get; set; }
    }
    /// <summary>
    /// 用户可订阅的消息模板
    /// </summary>
    public class SubscribeTplS2CDto
    {
        /// <summary>
        /// 模板ID
        /// </summary>
        public string Id { get; set; }
    }
    /// <summary>
    /// 用户已订阅的模板
    /// </summary>
    public class UserSubscribeS2CDto
    {
        /// <summary>
        /// 订阅的类型
        /// </summary>
        public int Type { get; set; }
    }
    /// <summary>
    /// 微信客服信息
    /// </summary>
    public class CustomServiceC2SDto
    {
        /// <summary>
        /// 企业微信appid
        /// </summary>
        public string QyAppId { get; set; }
        /// <summary>
        /// 客服链接
        /// </summary>
        public string Url { get; set; }
    }
}
