jm_job_info.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. # 用户名称
  19. user_name: str
  20. class JmJobInfoCreate(JmJobInfoBase):
  21. nodes: List[JmJobNode]
  22. edges: Optional[List[JmJobEdge]] = None
  23. class Config:
  24. schema_extra = {
  25. "example": {
  26. "name": "example",
  27. "type": "单作业离线任务",
  28. "tag": "业务预测",
  29. "cron_type": "2",
  30. "cron_expression": {
  31. "cron_select_type": 3,
  32. "cron_expression": "",
  33. "minute": 0,
  34. "hour": 0,
  35. "day": 1,
  36. "week": 3,
  37. "month": 2,
  38. },
  39. "json_str": "\{图形信息\}",
  40. "user_name": "test",
  41. "nodes": [
  42. {
  43. "id": 1,
  44. "homework_id": 0,
  45. "homework_name": "开始",
  46. "start_point": 0,
  47. },
  48. {
  49. "id": 2,
  50. "homework_id": 1,
  51. "homework_name": "test",
  52. "start_point": 1,
  53. }
  54. ],
  55. "edges": [
  56. {
  57. "source": 1,
  58. "target": 2,
  59. }
  60. ],
  61. }
  62. }
  63. class JmJobInfoUpdate(JmJobInfoBase):
  64. id: int
  65. nodes: List[JmJobNode]
  66. edges: Optional[List[JmJobEdge]] = None
  67. class Config:
  68. schema_extra = {
  69. "example": {
  70. "id": 11,
  71. "name": "example",
  72. "type": "单作业离线任务",
  73. "tag": "业务预测",
  74. "cron_type": "2",
  75. "cron_expression": {
  76. "cron_select_type": 3,
  77. "cron_expression": "* * * * *",
  78. "minute": 0,
  79. "hour": 0,
  80. "day": 1,
  81. "week": 3,
  82. "month": 2,
  83. },
  84. "json_str": "\{图形信息\}",
  85. "user_name": "test",
  86. "nodes": [
  87. {
  88. "id": 1,
  89. "homework_id": 0,
  90. "homework_name": "开始",
  91. "start_point": 0,
  92. },
  93. {
  94. "id": 2,
  95. "homework_id": 1,
  96. "homework_name": "test",
  97. "start_point": 1,
  98. }
  99. ],
  100. "edges": [
  101. {
  102. "source": 1,
  103. "target": 2,
  104. }
  105. ],
  106. }
  107. }
  108. class JmJobInfoStatusUpdate(BaseModel):
  109. id: int
  110. status: int
  111. class Config:
  112. schema_extra = {
  113. "example": {
  114. "id": 1,
  115. "status": 0,
  116. }
  117. }