feat(project):add sts
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from uuid import UUID
|
||||
|
||||
from app.models.project import ProjectModel
|
||||
from fastapi import HTTPException
|
||||
|
||||
from app.models.project import ProjectModel, UpdateSts
|
||||
from core.repositories.base import BaseRepository
|
||||
from core.service.mongo_db import use_collection
|
||||
|
||||
@@ -47,6 +49,25 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":update.mongo_dict()})
|
||||
return await self.get(_id)
|
||||
|
||||
async def update_design_sts(self, _id: UUID, update: UpdateSts):
|
||||
old_project = await use_collection(COLLECTION).find_one({"_id":_id})
|
||||
if not old_project:
|
||||
raise HTTPException(status_code=400,detail='این پروژه وجود ندارد')
|
||||
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":{
|
||||
'design.sts':update.sts,'design.reason_stop':update.reason_stop
|
||||
}})
|
||||
return True
|
||||
|
||||
async def delete(self, _id: UUID):
|
||||
old_project = await use_collection(COLLECTION).find_one({"_id":_id})
|
||||
if not old_project:
|
||||
raise HTTPException(status_code=400,detail='این پروژه وجود ندارد')
|
||||
await use_collection(COLLECTION).update_one({"_id":_id},{"$set":{
|
||||
'sts':2,
|
||||
}})
|
||||
return True
|
||||
|
||||
|
||||
async def list_project_design(self):
|
||||
project = await use_collection(COLLECTION).find({'monitor':{"$exists":0}}).to_list(None)
|
||||
return project
|
||||
|
||||
Reference in New Issue
Block a user