feat:add factor audit
This commit is contained in:
@@ -2,3 +2,4 @@ class TaskEnv:
|
|||||||
CLN_AUDIT_STATUS = 'audit_status'
|
CLN_AUDIT_STATUS = 'audit_status'
|
||||||
CLN_AUDIT_PARLIAMENT = 'audit_parliament'
|
CLN_AUDIT_PARLIAMENT = 'audit_parliament'
|
||||||
CLN_AUDIT_PRICE = 'audit_price'
|
CLN_AUDIT_PRICE = 'audit_price'
|
||||||
|
CLN_AUDIT_FACTOR = 'audit_factor'
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import uuid
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
import pydantic
|
||||||
|
from pydantic import Field
|
||||||
|
|
||||||
|
from core.models.base import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class FactorModel(BaseModel):
|
||||||
|
id: Optional[uuid.UUID] = Field(alias='_id')
|
||||||
|
project_id: uuid.UUID = Field(description='کد شناسایی پروژ')
|
||||||
|
number: Optional[str] = Field(description=" شماره آیتم")
|
||||||
|
description: Optional[str] = Field(description='موضوع فاکتور')
|
||||||
|
unit: Optional[str] = Field(description='واحد')
|
||||||
|
count: Optional[int] = Field(description='تعداد')
|
||||||
|
fee_day: Optional[int] = Field(description='بهای روز')
|
||||||
|
total_day: Optional[int] = Field(description=' بهای کل روز = تعداد * بهای واحد روز')
|
||||||
|
field: Optional[str] = Field(description="""
|
||||||
|
'electrical',
|
||||||
|
'mechanic',
|
||||||
|
'building',
|
||||||
|
'other'
|
||||||
|
""")
|
||||||
|
location: Optional[str] = Field(description='موقعیت')
|
||||||
|
|
||||||
|
class CheckModel(pydantic.BaseModel):
|
||||||
|
project_id: uuid.UUID = Field(description='کد شناسایی پروژ')
|
||||||
|
number: Optional[str] = Field(description=" شماره آیتم")
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
from fastapi import HTTPException
|
||||||
|
|
||||||
|
from app.config import TaskEnv
|
||||||
|
from app.models.factor_audit import FactorModel, CheckModel
|
||||||
|
from core.repositories.base import BaseRepository
|
||||||
|
from core.service.mongo_db import use_collection
|
||||||
|
|
||||||
|
|
||||||
|
class FactorRepository(BaseRepository):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(collection=TaskEnv.CLN_AUDIT_FACTOR, model=FactorModel)
|
||||||
|
|
||||||
|
async def check(self,_inp:CheckModel):
|
||||||
|
check_price = await use_collection(TaskEnv.CLN_AUDIT_FACTOR).find_one({
|
||||||
|
"project_id":_inp.project_id,"number":_inp.number
|
||||||
|
})
|
||||||
|
if check_price:
|
||||||
|
raise HTTPException(status_code=422,detail="this item number is exist")
|
||||||
|
else:
|
||||||
|
return False
|
||||||
@@ -4,3 +4,4 @@ from .design_progress import *
|
|||||||
from .register_status import *
|
from .register_status import *
|
||||||
from .parliament_audit import *
|
from .parliament_audit import *
|
||||||
from .price_audit import *
|
from .price_audit import *
|
||||||
|
from .factor_audit import *
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from fastapi import Body
|
||||||
|
|
||||||
|
from app.models.factor_audit import FactorModel, CheckModel
|
||||||
|
from app.repositories.factor_audit import FactorRepository
|
||||||
|
from core.app import app
|
||||||
|
from core.utils.router import generate_router, shrink
|
||||||
|
from core.utils.table_engine import TableEngineExport, TableEngineRequestType
|
||||||
|
|
||||||
|
ThisModel = FactorModel
|
||||||
|
router_base_url = 'audit_factor'
|
||||||
|
_tag_base = [router_base_url]
|
||||||
|
router = generate_router(router_base_url, auth_dependencies=False, version='v2')
|
||||||
|
repo = FactorRepository()
|
||||||
|
|
||||||
|
@router.post('/create', response_model=ThisModel, tags=_tag_base)
|
||||||
|
@shrink(repo.create)
|
||||||
|
def create(coding: ThisModel = Body(...)):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@router.post('/check', response_model=bool, tags=_tag_base)
|
||||||
|
@shrink(repo.check)
|
||||||
|
def check(coding: CheckModel = Body(...)):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@router.put('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||||
|
@shrink(repo.update)
|
||||||
|
def update(_id: UUID, coding: ThisModel = Body(...)):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@router.get('/{_id}', response_model=ThisModel, tags=_tag_base)
|
||||||
|
@shrink(repo.get)
|
||||||
|
def get(_id: UUID):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@router.post('', response_model=TableEngineExport[ThisModel], tags=_tag_base)
|
||||||
|
@shrink(repo.fetch)
|
||||||
|
def fetch(body: TableEngineRequestType = Body(...)):
|
||||||
|
pass
|
||||||
|
|
||||||
|
app.include_router(router)
|
||||||
Reference in New Issue
Block a user