jm_homework.py 2.6 KB

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