jm_job_info.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. from app.schemas.cron_expression import CronExpression
  4. from app.schemas.jm_job_node import JmJobEdge, JmJobNode
  5. class JmJobInfoBase(BaseModel):
  6. # 任务名称
  7. name: str
  8. # 任务类型
  9. type: str
  10. # 任务分类
  11. tag: str
  12. # 周期类型(1:单次;2:循环)
  13. cron_type: int
  14. # 周期表达式
  15. cron_expression: Optional[CronExpression] = None
  16. # 图形信息
  17. json_str : Optional[str]
  18. class JmJobInfoCreate(JmJobInfoBase):
  19. nodes: List[JmJobNode]
  20. edges: Optional[List[JmJobEdge]] = None
  21. class Config:
  22. schema_extra = {
  23. "example": {
  24. "name": "example",
  25. "type": "单作业离线任务",
  26. "tag": "业务预测",
  27. "cron_type": "2",
  28. "cron_expression": {
  29. "cron_select_type": 3,
  30. "cron_expression": "",
  31. "minute": 0,
  32. "hour": 0,
  33. "day": 1,
  34. "week": 3,
  35. "month": 2,
  36. },
  37. "json_str": "\{图形信息\}",
  38. "nodes": [
  39. {
  40. "id": 1,
  41. "homework_id": 0,
  42. "homework_name": "开始",
  43. "start_point": 0,
  44. },
  45. {
  46. "id": 2,
  47. "homework_id": 1,
  48. "homework_name": "test",
  49. "start_point": 1,
  50. }
  51. ],
  52. "edges": [
  53. {
  54. "source": 1,
  55. "target": 2,
  56. }
  57. ],
  58. }
  59. }
  60. class JmJobInfoUpdate(JmJobInfoBase):
  61. id: int
  62. nodes: List[JmJobNode]
  63. edges: Optional[List[JmJobEdge]] = None
  64. class Config:
  65. schema_extra = {
  66. "example": {
  67. "id": 11,
  68. "name": "example",
  69. "type": "单作业离线任务",
  70. "tag": "业务预测",
  71. "cron_type": "2",
  72. "cron_expression": {
  73. "cron_select_type": 3,
  74. "cron_expression": "* * * * *",
  75. "minute": 0,
  76. "hour": 0,
  77. "day": 1,
  78. "week": 3,
  79. "month": 2,
  80. },
  81. "json_str": "\{图形信息\}",
  82. "nodes": [
  83. {
  84. "id": 1,
  85. "homework_id": 0,
  86. "homework_name": "开始",
  87. "start_point": 0,
  88. },
  89. {
  90. "id": 2,
  91. "homework_id": 1,
  92. "homework_name": "test",
  93. "start_point": 1,
  94. }
  95. ],
  96. "edges": [
  97. {
  98. "source": 1,
  99. "target": 2,
  100. }
  101. ],
  102. }
  103. }
  104. class JmJobInfoStatusUpdate(BaseModel):
  105. id: int
  106. status: int
  107. class Config:
  108. schema_extra = {
  109. "example": {
  110. "id": 1,
  111. "status": 0,
  112. }
  113. }