o
    Uh                     @   sb   d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
mZ d dlmZ G dd dZd	S )
    )HTTPException)Session)PlumbingResponceplumbingCreate)JWTPayloadSchema)PlumbingBaseTblPlumbing)CustomResponsec                   @   s:   e Zd ZdedefddZdefddZdefd	d
Z	dS )PlumlingServicedbtokenc                 C   s   || _ || _d S )N)r   r   )selfr   r    r   3/var/www/html/RetailAPI/app/api/plumbing/service.py__init__	   s   
zPlumlingService.__init__requestc                    sd   |j |j }t|}||_tt| | j	}| j	
| | j	  | j	| tdddS )N1zPlumbing created successfully.)statusmessage)unitscost_per_unitr   model_validatetotalr   creater   
model_dumpr   addcommitrefreshr	   )r   r   r   created_plumbingnew_equipmentr   r   r   create_plumbing   s   

zPlumlingService.create_plumbinggroup_idc                    s8   | j ttj|k }|stdddt|S )Ni  zPlumbing Not Found)status_codedetail)	r   queryr   filterr!   firstr   r   r   )r   r!   plumbing_recordr   r   r   get_plumbing   s
   
zPlumlingService.get_plumbingN)
__name__
__module____qualname__r   r   r   r   r    intr(   r   r   r   r   r
      s    r
   N)fastapir   sqlalchemy.ormr   app.api.plumbing.schemasr   r   app.dependency.authanticationr   app.models.main.Plumbingr   r   app.utils.schemas_utilsr	   r
   r   r   r   r   <module>   s    