fix(project):add list project
This commit is contained in:
@@ -15,23 +15,23 @@ class DesignProgressModel(BaseModel):
|
|||||||
complete_at: Optional[datetime.datetime] = Field(description='تاریخ تکمیل مدارک')
|
complete_at: Optional[datetime.datetime] = Field(description='تاریخ تکمیل مدارک')
|
||||||
user_complete: Optional[int] = Field(description='کاربری که اطلاعات را تکمیل می کند در این فیلد قرار می گیرد')
|
user_complete: Optional[int] = Field(description='کاربری که اطلاعات را تکمیل می کند در این فیلد قرار می گیرد')
|
||||||
type: Literal[1, 2, 3, 4, 5, 6, 7] = Field(description="""
|
type: Literal[1, 2, 3, 4, 5, 6, 7] = Field(description="""
|
||||||
1 تکمیل مدارک و مستندات
|
1. تکمیل مدارک و مستندات
|
||||||
.2 فاز صفر
|
.2 فاز صفر
|
||||||
.3 فاز یک
|
.3 فاز یک
|
||||||
.4 طراحی شبکه و دوربین و برق اضطراری
|
.4 طراحی شبکه و دوربین و برق اضطراری
|
||||||
.5 فاز دو
|
.5 فاز دو
|
||||||
.6 متر برآورد
|
.6 متر برآورد
|
||||||
.7 اسناد مناقصه
|
.7 اسناد مناقصه
|
||||||
""")
|
""")
|
||||||
parent_id: Optional[uuid.UUID] = Field(description='زیر مجموعه کدام نوع اصلی است')
|
parent_id: Optional[uuid.UUID] = Field(description='زیر مجموعه کدام نوع اصلی است')
|
||||||
sub_type: Optional[Literal[1, 2, 3, 4, 5, 6, 7]] = Field(description="""
|
sub_type: Optional[Literal[1, 2, 3, 4, 5, 6, 7]] = Field(description="""
|
||||||
1. برنامه فیزیکی
|
1. برنامه فیزیکی
|
||||||
2. گزارش فاز صفر کلیه رشته ها
|
2. گزارش فاز صفر کلیه رشته ها
|
||||||
3. آلترناتیک لکه گذاری جا نمایی در سایت
|
3. آلترناتیک لکه گذاری جا نمایی در سایت
|
||||||
4. آلترناتیک لکه گذاری معماری طبقات
|
4. آلترناتیک لکه گذاری معماری طبقات
|
||||||
5. فاز یک معماری
|
5. فاز یک معماری
|
||||||
6.تائید دانشگاه علوم پزشکی
|
6.تائید دانشگاه علوم پزشکی
|
||||||
7.گزارش های کلیه رشته ها
|
7.گزارش های کلیه رشته ها
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
@@ -54,4 +54,5 @@ class CreateDesignProgress(DesignProgressModel):
|
|||||||
|
|
||||||
class GetRecord(pydantic.BaseModel):
|
class GetRecord(pydantic.BaseModel):
|
||||||
project_id:uuid.UUID = Field(description='کد شناسایی پروژ')
|
project_id:uuid.UUID = Field(description='کد شناسایی پروژ')
|
||||||
type:Literal[1, 2, 3, 4, 5, 6, 7] = Field(description='نوع')
|
type:Literal[1, 2, 3, 4, 5, 6, 7] = Field(description='نوع')
|
||||||
|
sub_type:Optional[Literal[1, 2, 3, 4, 5, 6, 7]]
|
||||||
@@ -3,6 +3,8 @@ import uuid
|
|||||||
from typing import List
|
from typing import List
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
|
from fastapi import HTTPException
|
||||||
|
|
||||||
from app.models.design_progress import DesignProgressModel, CreateDesignProgress, RecordModel, GetRecord
|
from app.models.design_progress import DesignProgressModel, CreateDesignProgress, RecordModel, GetRecord
|
||||||
from core.repositories.base import BaseRepository
|
from core.repositories.base import BaseRepository
|
||||||
from core.service.mongo_db import use_collection
|
from core.service.mongo_db import use_collection
|
||||||
@@ -13,8 +15,7 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
|||||||
def __int__(self):
|
def __int__(self):
|
||||||
super().__init__(collection=COLLECTION, model=CreateDesignProgress)
|
super().__init__(collection=COLLECTION, model=CreateDesignProgress)
|
||||||
def create_progress_model(self,_inp:CreateDesignProgress, type_create='create')->DesignProgressModel:
|
def create_progress_model(self,_inp:CreateDesignProgress, type_create='create')->DesignProgressModel:
|
||||||
print(type_create)
|
if _inp.complete_at and _inp.records:
|
||||||
if _inp.complete_at:
|
|
||||||
_inp.start_at = _inp.records[0].send.date_at
|
_inp.start_at = _inp.records[0].send.date_at
|
||||||
progress = DesignProgressModel(
|
progress = DesignProgressModel(
|
||||||
project_id=_inp.project_id,
|
project_id=_inp.project_id,
|
||||||
@@ -25,7 +26,6 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
|||||||
complete_at= _inp.complete_at
|
complete_at= _inp.complete_at
|
||||||
)
|
)
|
||||||
if type_create == 'create':
|
if type_create == 'create':
|
||||||
print('9999999999999')
|
|
||||||
progress.init_id().cu_at()
|
progress.init_id().cu_at()
|
||||||
else:
|
else:
|
||||||
progress.u_at()
|
progress.u_at()
|
||||||
@@ -57,8 +57,12 @@ class DesignProgressRepository(BaseRepository[CreateDesignProgress]):
|
|||||||
return await self.get(get_record)
|
return await self.get(get_record)
|
||||||
|
|
||||||
async def get(self,get_record:GetRecord):
|
async def get(self,get_record:GetRecord):
|
||||||
progress = await use_collection(COLLECTION).find_one({"project_id":get_record.project_id,"type":get_record.type})
|
print("2222222")
|
||||||
progress['records'] = await use_collection('design_progress_record').find({"design_progress_id":progress["_id"]}).to_list(None)
|
if get_record.type in [2,3]:
|
||||||
|
raise HTTPException(status_code=422,detail='لطفا نوع زیرمجموعه را ارد کنید')
|
||||||
|
progress = await use_collection(COLLECTION).find_one({"project_id":get_record.project_id,"type":get_record.type,"sub_type":get_record.sub_type})
|
||||||
|
if progress:
|
||||||
|
progress['records'] = await use_collection('design_progress_record').find({"design_progress_id":progress["_id"]}).to_list(None)
|
||||||
return progress
|
return progress
|
||||||
|
|
||||||
async def update(self, _id: UUID, update: CreateDesignProgress):
|
async def update(self, _id: UUID, update: CreateDesignProgress):
|
||||||
|
|||||||
Reference in New Issue
Block a user