AliyunEcsDTO.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. 
  2. using dodohold.core;
  3. using System.Text.Json;
  4. namespace molilian.core
  5. {
  6. [Table("aliyun_ecs")]
  7. public class AliyunEcsDTO
  8. {
  9. [Key]
  10. public int id { get; set; }
  11. public int account_id { get; set; }
  12. public string name { get; set; } = string.Empty;
  13. public string description { get; set; } = string.Empty;
  14. public DateTime create_time { get; set; } = DateTime.Now;
  15. public DateTime last_time { get; set; } = DateTime.Now;
  16. public string instance_id { get; set; } = string.Empty;
  17. public string instance_name { get; set; } = string.Empty;
  18. public string host_name { get; set; } = string.Empty;
  19. public string os_name { get; set; } = string.Empty;
  20. public string region_id { get; set; } = string.Empty;
  21. public string instance_type { get; set; } = string.Empty;
  22. public int cpu { get; set; } = 0;
  23. public decimal memory { get; set; } = 0;
  24. public DateTime expired_time { get; set; } = DateTime.MinValue;
  25. public DateTime creation_time { get; set; } = DateTime.MinValue;
  26. [Column("address_ips")]
  27. public string AddressIpsJson
  28. {
  29. get => JsonSerializer.Serialize(AddressIps);
  30. set => AddressIps = string.IsNullOrEmpty(value)
  31. ? new List<AddressIpDTO>()
  32. : JsonSerializer.Deserialize<List<AddressIpDTO>>(value);
  33. }
  34. [NotMapped] // 这个属性不会映射到数据库
  35. public List<AddressIpDTO> AddressIps { get; set; } = [];
  36. }
  37. public class AddressIpDTO
  38. {
  39. public string networkInterfaceId { get; set; } = string.Empty;
  40. public string privateIp { get; set; } = string.Empty;
  41. public string publicIp { get; set; } = string.Empty;
  42. }
  43. }