using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using YBDevice.Body.BodyFatHelper;

namespace YBDevice.NApi.Application.UserInfo
{
    /// <summary>
    /// 八电极算法接口返回数据
    /// </summary>
    public class BodyReponseInfo
    {
        /// <summary>
        /// 状态,1000测量成功,其他均是失败
        /// </summary>
        public int code { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public string status { get; set; }
        /// <summary>
        /// 信息
        /// </summary>
        public string message { get; set; }
    }
    /// <summary>
    /// 八电极算法接口返回数据
    /// </summary>
    public class BodyReponseInfo<T> : BodyReponseInfo
    {
        /// <summary>
        /// 数据
        /// </summary>
        public List<T> data { get; set; }
    }

    public class BodyResponseData
    {
        /// <summary>
        /// 参数名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 值
        /// </summary>
        public object value { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public BodyResponseDataDesc description { get; set; }
        /// <summary>
        /// 单位
        /// </summary>
        public string unit { get; set; }
        /// <summary>
        /// 标准
        /// </summary>
        public BodyResponseDataLevel level { get; set; }
    }

    /// <summary>
    /// 参数描述
    /// </summary>
    public class BodyResponseDataDesc
    {
        /// <summary>
        /// 描述定义
        /// </summary>
        public string definition { get; set; }
        /// <summary>
        /// 提示
        /// </summary>
        public string tips { get; set; }
    }
    /// <summary>
    /// 测量项标准
    /// </summary>
    public class BodyResponseDataLevel
    {
        /// <summary>
        /// 标准值
        /// </summary>
        public string value { get; set; }
        /// <summary>
        /// 范围
        /// </summary>
        public List<string> stand { get; set; }
    }

    /// <summary>
    /// 八电极测量历史记录
    /// </summary>
    public class BodyMeasureHisList : UserMeasureDto
    {
        /// <summary>
        /// 年龄
        /// </summary>
        public int age { get; set; }

        /// <summary>
        /// 测量时间
        /// </summary>
        public DateTime time { get; set; }
        /// <summary>
        /// 等级标准
        /// </summary>
        public string leveljson { get; set; }
    }

    /// <summary>
    /// 八电极测量历史记录
    /// </summary>
    public class BodyMeasureHisListDto : UserMeasureDto
    {
        /// <summary>
        /// 年龄
        /// </summary>
        public string age { get; set; }

        /// <summary>
        /// 测量时间
        /// </summary>
        public string time { get; set; }
    }


    /// <summary>
    /// 八电极趋势信息
    /// </summary>
    public class BodyQueryTrandDto
    {
        /// <summary>
        /// 家庭成员id
        /// </summary>
        public long familyid { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? starttime { get; set; }
        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? endtime { get; set; }
        /// <summary>
        /// 设备类型
        /// </summary>
        public int DevType { get; set; } = 2;
    }
    /// <summary>
    /// 查询趋势
    /// </summary>
    public class TrandS2CDto
    {
        /// <summary>
        /// 记录ID
        /// </summary>
        public string id { get; set; } = "";

        /// <summary>
        /// BMI
        /// </summary>
        public decimal bmi { get; set; }
        /// <summary>
        /// 脂肪率
        /// </summary>
        public decimal fat_r { get; set; }
        /// <summary>
        /// 体重
        /// </summary>
        public decimal weight { get; set; }

        /// <summary>
        ///  身高
        /// </summary> 
        public decimal height { get; set; }
        /// <summary>
        /// 肌肉率
        /// </summary>
        public decimal muscle { get; set; }
        /// <summary>
        /// 测量时间
        /// </summary>
        public string createtime { get; set; }
        /// <summary>
        ///测量时间
        /// </summary>
        public DateTime time { get; set; }
    }

    /// <summary>
    /// 查询趋势
    /// </summary>
    public class BodyTrandDto : TrandS2CDto
    {
        
    }
    /// <summary>
    /// 设备类型列表
    /// </summary>
    public class UserDevTypeS2CDto
    {
        /// <summary>
        /// 类型名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 类型图片
        /// </summary>
        public string HeadImg { get; set; }
        /// <summary>
        /// 类型值
        /// </summary>
        public int Id { get; set; }
    }
    /// <summary>
    /// 修改初始体重
    /// </summary>
    public class UserFirstWeightC2SDto : IValidatableObject
    {
        /// <summary>
        /// 体重值
        /// </summary>
        public decimal Weight { get; set; }
        /// <summary>
        /// 初始时间
        /// </summary>
        public DateTime Time { get; set; }
        /// <summary>
        /// 家庭成员ID
        /// </summary>
        public int FamilyId { get; set; }
        /// <summary>
        /// 设备类型
        /// </summary>
        public int DevType { get; set; }
        /// <summary>
        /// 验证
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Weight <= 0)
            {
                yield return new ValidationResult("体重值不可小于0", new[] { nameof(Weight) });
            }
            if (FamilyId <= 0)
            {
                yield return new ValidationResult("请先选择家庭成员", new[] { nameof(FamilyId) });
            }
            if (DevType <= 0)
            {
                yield return new ValidationResult("请先选择设备类型", new[] { nameof(DevType) });
            }
        }
    }
}
