fix(project):get list with ids
This commit is contained in:
@@ -151,5 +151,8 @@ class ProjectStatusAgreement(BaseModel):
|
||||
project_id: Optional[uuid.UUID] = Field(description="کد شناسایی پروژه در این فیلد قرار می گیرد")
|
||||
status:str
|
||||
|
||||
class ListWithIds(pydantic.BaseModel):
|
||||
ids: list[uuid.UUID]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import requests
|
||||
from fastapi import HTTPException
|
||||
|
||||
from app.config import TaskEnv
|
||||
from app.models.project import ProjectModel, UpdateSts, ProjectSts, Design, ProjectStatusAgreement
|
||||
from app.models.project import ProjectModel, UpdateSts, ProjectSts, Design, ProjectStatusAgreement, ListWithIds
|
||||
from core.repositories.base import BaseRepository
|
||||
from core.service.mongo_db import use_collection
|
||||
from core.utils.table_engine import TableEngineRequestType, TableEngineExport
|
||||
@@ -200,6 +200,13 @@ class ProjectRepository(BaseRepository[ProjectModel]):
|
||||
project = await use_collection(TaskEnv.CLN_PROJECT).find({}).to_list(None)
|
||||
return project
|
||||
|
||||
async def list_project_with_select(self):
|
||||
project = await use_collection(TaskEnv.CLN_PROJECT).find({},{"_id":1,"design.title":1,"design.code":1}).to_list(None)
|
||||
return project
|
||||
async def list_project_with_ids(self,inp:ListWithIds):
|
||||
projects = await use_collection(TaskEnv.CLN_PROJECT).find({"_id":{"$in":inp.ids}}).to_list(None)
|
||||
return projects
|
||||
|
||||
async def set_sts_two_for_monitor(self, project_id: uuid.UUID):
|
||||
project = await use_collection(TaskEnv.CLN_PROJECT).find_one({"_id": project_id})
|
||||
if not ('sts' in project['monitor'] and project['monitor']['sts'] > 1):
|
||||
|
||||
+10
-1
@@ -3,7 +3,7 @@ from uuid import UUID
|
||||
|
||||
from fastapi import Body
|
||||
|
||||
from app.models.project import ProjectModel, UpdateSts
|
||||
from app.models.project import ProjectModel, UpdateSts, ListWithIds
|
||||
from app.repositories.project import ProjectRepository
|
||||
from core.app import app
|
||||
from core.utils.router import generate_router, shrink
|
||||
@@ -32,6 +32,15 @@ def list_project_design():
|
||||
def list_project_monitor():
|
||||
pass
|
||||
|
||||
@router.post('/list/ids', response_model=ThisModel, tags=_tag_base)
|
||||
@shrink(repo.list_project_with_ids)
|
||||
def list_project_with_ids(inp:ListWithIds):
|
||||
pass
|
||||
|
||||
@router.get('/list/all', response_model=List[ThisModel], tags=_tag_base)
|
||||
@shrink(repo.list_project_with_select)
|
||||
def list_project_with_select():
|
||||
pass
|
||||
@router.get('/list/project', response_model=List[ThisModel], tags=_tag_base)
|
||||
@shrink(repo.list_project)
|
||||
def list_project():
|
||||
|
||||
Reference in New Issue
Block a user