20 lines
715 B
Python
20 lines
715 B
Python
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 |