CfcApiModels.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System.Text.Json.Serialization;
  2. namespace XafPet.Desktop.PetEngine;
  3. /// <summary>CFC 统一响应包装 Result<T></summary>
  4. public sealed class ApiResult<T>
  5. {
  6. [JsonPropertyName("code")]
  7. public int Code { get; set; }
  8. [JsonPropertyName("message")]
  9. public string? Message { get; set; }
  10. [JsonPropertyName("data")]
  11. public T? Data { get; set; }
  12. public bool IsSuccess => Code == 200;
  13. }
  14. public sealed class CfcTask
  15. {
  16. [JsonPropertyName("id")]
  17. public long Id { get; set; }
  18. [JsonPropertyName("title")]
  19. public string? Title { get; set; }
  20. [JsonPropertyName("status")]
  21. public string? Status { get; set; } // PENDING / IN_PROGRESS / COMPLETED / REJECTED
  22. [JsonPropertyName("dueDate")]
  23. public string? DueDate { get; set; }
  24. }
  25. public sealed class DimensionValue
  26. {
  27. [JsonPropertyName("dimension")]
  28. public string? Dimension { get; set; }
  29. [JsonPropertyName("value")]
  30. public int Value { get; set; }
  31. [JsonPropertyName("color")]
  32. public string? Color { get; set; }
  33. }
  34. public sealed class EnergyOverview
  35. {
  36. [JsonPropertyName("dimensions")]
  37. public List<DimensionValue> Dimensions { get; set; } = new();
  38. }
  39. public sealed class DailyCheckin
  40. {
  41. [JsonPropertyName("checked")]
  42. public bool Checked { get; set; }
  43. [JsonPropertyName("items")]
  44. public List<string> Items { get; set; } = new();
  45. }
  46. /// <summary>API 返回非 200 code 时抛出</summary>
  47. public sealed class ApiException : Exception
  48. {
  49. public int ApiCode { get; }
  50. public ApiException(int apiCode, string message) : base(message)
  51. {
  52. ApiCode = apiCode;
  53. }
  54. }
  55. public sealed class MascotInfo
  56. {
  57. [JsonPropertyName("mascotId")]
  58. public string? MascotId { get; set; }
  59. [JsonPropertyName("name")]
  60. public string? Name { get; set; }
  61. public sealed class MascotInfo
  62. {
  63. [JsonPropertyName("mascotId")]
  64. public string? MascotId { get; set; }
  65. [JsonPropertyName("name")]
  66. public string? Name { get; set; }
  67. }
  68. }