using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.Entity
{
    /// <summary>
    /// 传输资产信息的对象
    /// </summary>
    public class TdAssetItem
    {
        /// <summary>
        /// Id信息
        /// </summary>
        [JsonProperty("id")]
        public string Id { get; set; }
        /// <summary>
        /// 种族编码
        /// </summary>
        [JsonProperty("family")]
        public string FamilyCode { get; set; }
        /// <summary>
        /// 设备分类
        /// </summary>
        [JsonProperty("category")]
        public string Category { get; set; }
        /// <summary>
        /// 关联信息relation
        /// </summary>
        [JsonProperty("relation")]
        public JObject Relations { get; set; }
        /// <summary>
        /// 关联信息点
        /// </summary>
        [JsonProperty("infos")]
        public JObject Infos { get; set; }
        /// <summary>
        /// 转换成json对象
        /// </summary>
        /// <returns></returns>
        public virtual JObject ToJObject()
        {
            JObject j =new JObject() ;
            if(!string.IsNullOrEmpty(Id))
            {
                j.Add("id",this.Id);
            }
            if (!string.IsNullOrEmpty(FamilyCode))
            {
                j.Add("family", this.FamilyCode);
            }
            if (!string.IsNullOrEmpty(Category))
            {
                j.Add("category", this.Category);
            }
            if (Relations != null)
            {
                j.Add("relation", Relations);
            }
            var attach = Infos;
            if (attach == null)
            {
                attach = new JObject();
            }
            j.Add("infos", attach);
            
            return j;
        }


    }
}
