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

namespace YBDevice.Entity
{
    /// <summary>
    /// 用户列表
    /// </summary>
    public class AccountExtend : YB_Account
    {
        /// <summary>
        /// 客户名称
        /// </summary>
        public string BusinessName { get; set; }
        /// <summary>
        /// 角色名称
        /// </summary>
        public string RoleName { get; set; }
    }
    /// <summary>
    /// 用户登录
    /// </summary>
    public class LoginModel
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string username { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string pwd { get; set; }
        /// <summary>
        /// 验证码
        /// </summary>
        public string code { get; set; } = "";
        /// <summary>
        /// 用户openid
        /// </summary>
        public string openid { get; set; }
    }
    /// <summary>
    /// 角色信息提交
    /// </summary>
    public class RoleSubmitModel : YB_nRole
    {
        /// <summary>
        /// 菜单列表
        /// </summary>
        public List<Guid> menuids { get; set; }
        /// <summary>
        /// 按钮列表
        /// </summary>
        public List<YB_nRoleAction> actionids { get; set; }
    }
    ///<summary>
    /// 修改密码
    /// </summary>
    public class BusienssPwd : IValidatableObject
    {
        /// <summary>
        /// 旧密码
        /// </summary>
        [Required(ErrorMessage ="请输入旧密码")]
        [MinLength(6,ErrorMessage ="密码长度最少为6位")]
        public string OldPwd { get; set; }
        /// <summary>
        /// 新密码
        /// </summary>
        [Required(ErrorMessage = "请输入新密码")]
        [MinLength(6, ErrorMessage = "密码长度最少为6位")]
        public string NewPwd { get; set; }
        /// <summary>
        /// 确认新密码
        /// </summary>
        [Required(ErrorMessage = "请再次输入新密码")]
        [MinLength(6, ErrorMessage = "密码长度最少为6位")]
        public string ReNewPwd { get; set; }
       /// <summary>
       /// 验证
       /// </summary>
       /// <param name="validationContext"></param>
       /// <returns></returns>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (NewPwd != ReNewPwd)
            {
                yield return new ValidationResult(
                    "两次密码不一致"
                    , new[] { nameof(NewPwd) }
                );
            }
        }
    }

    /// <summary>
    /// 客户信息提交
    /// </summary>
    public class BusinessSubmitModel : YB_Business
    {
        /// <summary>
        /// 账户类型
        /// </summary>
        public AccountType AccountType { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        public string password { get; set; }
        /// <summary>
        /// 重复输入密码
        /// </summary>
        public string repassword { get; set; }
        /// <summary>
        /// 角色ID
        /// </summary>
        public Guid RoleId { get; set; }
    }
    /// <summary>
    /// 用户资料
    /// </summary>
    public class UserInfoModel
    {
        /// <summary>
        /// 头像
        /// </summary>
        public string headimg { get; set; }
        /// <summary>
        /// 性别,0-未知,1-男,2-女
        /// </summary>
        public GenderType sex { get; set; }
        /// <summary>
        /// 昵称
        /// </summary>
        public string nickname { get; set; }
        /// <summary>
        /// 手机号是否已绑定,true-是,false-否
        /// </summary>
        public bool isbindphone { get; set; }
        /// <summary>
        /// 家庭成员ID
        /// </summary>
        public int familyid { get; set; }
        /// <summary>
        /// 身高
        /// </summary>
        public decimal height { get; set; }
        /// <summary>
        /// 目标体重
        /// </summary>
        public decimal targetweight { get; set; }
        /// <summary>
        /// 目标体重日期
        /// </summary>
        public string targettime { get; set; }
        /// <summary>
        /// 年龄
        /// </summary>
        public int age { get; set; }
        /// <summary>
        /// 带几岁几个月的
        /// </summary>
        public string MAge { get; set; }
        /// <summary>
        /// 最新的体重
        /// </summary>
        public decimal weight { get; set; }
        /// <summary>
        /// 最新的测量时间
        /// </summary>
        public string lasthearttime { get; set; }
        /// <summary>
        /// 生日
        /// </summary>
        public string Birthday { get; set; }
        /// <summary>
        /// 第一次测量体重
        /// </summary>
        public decimal FirstWeight { get; set; } = 0;
        /// <summary>
        /// 重量变化
        /// </summary>
        public decimal TotalWeight { get; set; } = 0;
        /// <summary>
        /// 测量次数
        /// </summary>
        public int Cnt { get; set; } = 0;
        /// <summary>
        /// 较上次的体重变化
        /// </summary>
        public decimal LastWeight { get; set; } = 0;
        /// <summary>
        /// 标准体重
        /// </summary>
        public decimal StandWeight { get; set; } = 0;
        /// <summary>
        /// 测量天数
        /// </summary>
        public int Day { get; set; } = 0;
        /// <summary>
        /// 初始测量时间
        /// </summary>
        public DateTime? FirstResultTime { get; set; }
        /// <summary>
        /// 成员类型
        /// </summary>
        public FamilyType Type { get; set; }
        /// <summary>
        /// BMI值
        /// </summary>
        public decimal BMI { get; set; }
    }

    /// <summary>
    /// 家庭成员提交信息
    /// </summary>
    public class FamilySubmitModel:IValidatableObject
    {
        /// <summary>
        /// 如果是修改,则传入此值
        /// </summary>
        public int id { get; set; } = 0;

        /// <summary>
        /// 家庭成员名称
        /// </summary>
        [Required(ErrorMessage ="家庭成员名称不可为空")]
        public string name { get; set; }
        /// <summary>
        /// 身高,单位为CM
        /// </summary>
        [Range(30, 300, ErrorMessage = "身高值只能在30-300厘米之间")]
        public decimal height { get; set; }
        /// <summary>
        /// 性别,0-未知,1-男,2-女
        /// </summary>
        public GenderType sex { get; set; }
        /// <summary>
        /// 出生年月
        /// </summary>
        public DateTime birthday { get; set; }
        /// <summary>
        /// 类型,1-成人,2-儿童,3-婴儿
        /// </summary>
        public FamilyType type { get; set; }
        /// <summary>
        /// 头像地址
        /// </summary>
        public string headimg { get; set; }
        /// <summary>
        /// 验证
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (birthday >= DateTime.Now.Date)
            {
                yield return new ValidationResult("出生年月不可大于当前日期", new[] { nameof(birthday)});
            }
            if (birthday.ToAge() >= 100)
            {
                yield return new ValidationResult("年龄范围需在0-100之间", new[] { nameof(birthday) });
            }
        }
    }
    /// <summary>
    /// 家庭成员列表
    /// </summary>
    public class FamilyListModel
    {
        /// <summary>
        /// 成员ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 头像
        /// </summary>
        public string HeadImg { get; set; }
        /// <summary>
        ///  类型,1-成人,2-儿童
        /// </summary>
        public FamilyType Type { get; set; }
        /// <summary>
        /// 名字
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 身高,单位为厘米
        /// </summary>
        public decimal Height { get; set; }
        /// <summary>
        /// 性别,0-未知,1-男,2-女
        /// </summary>
        public GenderType Sex { get; set; }
        /// <summary>
        /// 最新的体重
        /// </summary>
        public decimal Weight { get; set; }

        /// <summary>
        /// 最近的测量时间
        /// </summary>
        public string LastHeartTime { get; set; }
        /// <summary>
        /// 生日,出生年月日
        /// </summary>
        public DateTime Birthday { get; set; }
        /// <summary>
        /// 年龄,整数岁,主要用于结果计算
        /// </summary>
        public int Age { get; set; }
        /// <summary>
        /// 年龄,精确到月份
        /// </summary>
        public string mAge { get; set; } = "";
        /// <summary>
        ///  是否为自己,0-否,1-是,不能够删除
        /// </summary>
        public int IsSelf { get; set; }
    }
    /// <summary>
    /// 八电极用户测量信息查询
    /// </summary>
    public class UserBodyMeasureInfoModel: UserMeasureInfoModel
    {
        /// <summary>
        /// 用户id
        /// </summary>
        public string fansid { get; set; } = "";
    }

    /// <summary>
    /// 用户测量信息查询
    /// </summary>
    public class UserMeasureInfoModel : IValidatableObject
    {
        /// <summary>
        /// 是否重新计算,0-否,1-是
        /// </summary>
        public int IsCalc { get; set; } = 0;

        /// <summary>
        /// 家庭成员ID
        /// </summary>
        public int familyid { get; set; }
        /// <summary>
        /// 性别,1-男,2-女,0-未知
        /// </summary>
        public GenderType sex { get; set; }
        /// <summary>
        /// 身高,单位为CM
        /// </summary>
        [Range(50, 250, ErrorMessage = "身高值只能在50-250厘米之间")]
        public decimal height { get; set; }
        /// <summary>
        /// 出生年月
        /// </summary>
        public DateTime birthday { get; set; }
        /// <summary>
        /// 页码,历史记录使用
        /// </summary>
        public int pagesize { get; set; } = 1;
        /// <summary>
        /// 每页显示的数量,历史记录使用
        /// </summary>
        public int pagenum { get; set; } = 10;
        /// <summary>
        /// 设备类型,参考类型表
        /// </summary>
        public int devtype { get; set; } = 0;
        /// <summary>
        /// 验证
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (familyid <= 0)
            {
                yield return new ValidationResult("请先选择家庭成员", new[] { nameof(familyid) });
            }
        }
    }

    ///<summary>
    /// 短信接口
    /// </summary>
    public class SMSMODEL
    {
        /// <summary>
        /// code=0成功
        /// </summary>
        public int code { get; set; }
        /// <summary>
        /// 信息描述
        /// </summary>
        public string message { get; set; }
        /// <summary>
        /// 数据
        /// </summary>
        public object data { get; set; }
    }
    /// <summary>
    /// 注册成功返回的数据
    /// </summary>
    public class RegSuccessS2CDto
    {
        /// <summary>
        /// 用户token
        /// </summary>
        public string token { get; set; }
        /// <summary>
        /// 用户sessionid
        /// </summary>
        public string sessionid { get; set; }
        /// <summary>
        /// 注册用户资料
        /// </summary>
        public RegUserInfoS2CDto info { get; set; }
    }
    /// <summary>
    /// 注册用户信息
    /// </summary>
    public class RegUserInfoS2CDto
    {
        /// <summary>
        /// 头像
        /// </summary>
        public string headimg { get; set; }
        /// <summary>
        /// 昵称
        /// </summary>
        public string nickname { get; set; }
    }

    /// <summary>
    /// 用户注册
    /// </summary>
    public class RegModel
    {
        /// <summary>
        /// 唯一id,作为换取登录信息的凭据
        /// </summary>
        public string sessionId { get; set; } = "";
        /// <summary>
        /// 手机号
        /// </summary>
        public string phone { get; set; }
        /// <summary>
        /// 验证码
        /// </summary>
        public string code { get; set; } = "";
        /// <summary>
        /// 是否校检验证码
        /// </summary>
        public bool isvrcode { get; set; } = true;

        /// <summary>
        /// 用户wxfansid
        /// </summary>
        public Guid? fansid { get; set; } = null;

    }
    /// <summary>
    /// 小程序升级信息
    /// </summary>
    public class WxOpenUpgradeC2SDto
    {
        /// <summary>
        /// 小程序appid
        /// </summary>
        public string AppId { get; set; }
        /// <summary>
        /// 线上小程序版本号
        /// </summary>
        public string Version { get; set; }
        /// <summary>
        /// 小程序版本,develop-开发版,trial-体验版,release-正式版
        /// </summary>
        public string EnvVersion { get; set; }
    }
    /// <summary>
    /// 小程序升级信息
    /// </summary>
    public class WxOpenUpgradeS2CDto
    {
        /// <summary>
        /// 升级版本号
        /// </summary>
        public string Version { get; set; }
        /// <summary>
        /// 版本描述
        /// </summary>
        public string Desc { get; set; }
    }
    /// <summary>
    /// 用户基础信息
    /// </summary>
    public class UserBaseInfoS2SDto
    {
        /// <summary>
        /// 用户openid
        /// </summary>
        public string openid { get; set; }

        /// <summary>
        /// 昵称
        /// </summary>
        public string nickname { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string headimgurl { get; set; }

        /// <summary>
        /// 用户unionid
        /// </summary>
        public string unionid { get; set; }
    }
}
