|
@@ -12,6 +12,7 @@ def create_job_info(db: Session, item: schemas.JobInfoCreate):
|
|
|
'update_time': create_time,
|
|
|
'user_id': 1, # TODO 用户
|
|
|
'trigger_status': 0,
|
|
|
+ 'delete_status': 1,
|
|
|
})
|
|
|
db.add(db_item)
|
|
|
db.commit()
|
|
@@ -21,7 +22,7 @@ def create_job_info(db: Session, item: schemas.JobInfoCreate):
|
|
|
|
|
|
|
|
|
def get_job_infos(db: Session, skip: int = 0, limit: int = 20):
|
|
|
- res: List[models.JobInfo] = db.query(models.JobInfo).all() # TODO: 排序
|
|
|
+ res: List[models.JobInfo] = db.query(models.JobInfo).filter(models.JobInfo.delete_status == 1).all() # TODO: 排序
|
|
|
return res
|
|
|
|
|
|
|
|
@@ -39,4 +40,12 @@ def update_job_info(db: Session, id: int, update_item: schemas.JobInfoUpdate):
|
|
|
db.refresh(db_item)
|
|
|
return db_item
|
|
|
|
|
|
-
|
|
|
+def delete_job_info(db: Session, job_id: int):
|
|
|
+ job_item = db.query(models.JobInfo).filter(models.JobInfo.id == job_id).first()
|
|
|
+ if not job_item:
|
|
|
+ raise Exception('JobInfo not found')
|
|
|
+ job_item.delete_status = 0
|
|
|
+ db.commit()
|
|
|
+ db.flush()
|
|
|
+ db.refresh(job_item)
|
|
|
+ return job_item
|