jm_homework.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. from app.schemas.jm_homework_datasource_relation import JmHomeworkDatasourceRelationCreate
  4. class JmHomeworkBase(BaseModel):
  5. # 作业名称
  6. name: str
  7. # 作业类型
  8. type: str
  9. # 作业分类
  10. tag: str
  11. # 执行镜像
  12. image_url: str
  13. # DAG_ID
  14. dag_uuid: str
  15. # DAG文件地址
  16. dag_url: str
  17. # 脚本文件
  18. script_file: str
  19. # 执行命令
  20. execute_command: Optional[str]
  21. class JmHomeworkCreate(JmHomeworkBase):
  22. relation_list: Optional[List[JmHomeworkDatasourceRelationCreate]] = None
  23. class Config:
  24. schema_extra = {
  25. "example": {
  26. "name": "监察流水线",
  27. "type": "java",
  28. "tag": "作业监测",
  29. "image_url": "/test/images/example",
  30. "dag_uuid": "",
  31. "dag_url": "",
  32. "script_file": "/test/scripts/example",
  33. "execute_command": "ls",
  34. "relation_list": [
  35. {
  36. "type": "input",
  37. "datasource_id": 1,
  38. "node_uuid": "77a6e831-bb62-42e1-be8d-97699db00e73",
  39. "table": "jm_homework_datasource_relation",
  40. }
  41. ]
  42. }
  43. }
  44. class JmHomeworkUpdate(JmHomeworkBase):
  45. relation_list: Optional[List[JmHomeworkDatasourceRelationCreate]] = None
  46. class Config:
  47. schema_extra = {
  48. "example": {
  49. "name": "监察流水线",
  50. "type": "DAG",
  51. "tag": "作业监测",
  52. "image_url": "/test/images/example",
  53. "dag_uuid": "",
  54. "dag_url": "",
  55. "script_file": "/test/scripts/example",
  56. "execute_command": "ls",
  57. "relation_list": [
  58. {
  59. "type": "input",
  60. "datasource_id": 1,
  61. "node_uuid": "77a6e831-bb62-42e1-be8d-97699db00e73",
  62. "table": "jm_homework_datasource_relation",
  63. }
  64. ]
  65. }
  66. }
  67. class JmHomework(JmHomeworkBase):
  68. id: int
  69. # 用户ID
  70. user_id: str
  71. # 项目ID
  72. project_id: str
  73. # 创建时间
  74. create_time: int
  75. # 更新时间
  76. update_time: int
  77. # 状态
  78. status: int
  79. class Config:
  80. orm_mode = True