
    EhG                     |    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
 d dlmZ d dlmZ d dlmZ  G d	 d
      Zy)    )List)schema)ShortNegotiationFinalBaseTblShortNegotiationFinal)CustomResponse)Session)JWTPayloadSchema)Messages)HTTPExceptionc                   z    e Zd ZdedefdZdej                  fdZde	fdZ
deej                     fdZd	e	fd
Zy)ShortNegotiationFinalServicedbtokenc                      || _         || _        y )N)r   r   )selfr   r   s      N/var/www/html/retail-simulation-api/app/api/short_negotiation_final/service.py__init__z%ShortNegotiationFinalService.__init__   s    
    requestc                    K   t        j                  |j                               }t        j                  || j
                         | j
                  j                          t        dt        j                        S w)N1statusmessage)
r   model_validate
model_dumpr   creater   commitr   r
   SHORT_NEGOTIATION_FINAL)r   r   createds      r   r   z#ShortNegotiationFinalService.create   sT     +::7;M;M;OP ''9S(2R2RSSs   A9A;group_idc                    K   t        j                  || j                        }|st        dd      |D cg c]!  }t        j
                  j                  |      # c}S c c}w w)Ni  zGet group ID not found)status_codedetail)r   getr   r   r   ShortNegotiationFinalResponser   )r   r!   geted	get_groups       r   r%   z ShortNegotiationFinalService.get   sY     (,,Xtww?C8PQQ`ef`eS\44CCIN`efffs   4A$&AA$c                 p  K   |D ]y  }t        j                  |j                               }|j                  t	        dt
        j                        c S t        j                  |j                  || j                         { | j                  j                          t	        dt
        j                        S wNz-1r   r   )r   r   r   short_negotiation_final_idr   r
   SHORT_NEGOTIATION_FINAL_NOTr   updater   r   SHORT_NEGOTIATION_FINAL_UPDATE)r   r   requpdateds       r   r-   z#ShortNegotiationFinalService.update   s     C/>>s~~?OPG119%T8;_;_``$++G,N,NPWY]Y`Y`a	 
 	S(2Y2YZZs   B4B6r+   c                    K   t        j                  || j                        }|st        dt        j
                        S t        dt        j                        S wr*   )r   deleter   r   r
   r,   SHORT_NEGOTIATION_FINAL_DELETE)r   r+   deleteds      r   r2   z#ShortNegotiationFinalService.delete%   sF     *112LdggV!x7[7[\\S(2Y2YZZs   AAN)__name__
__module____qualname__r   r	   r   r   ShortNegotiationFinalCreater   intr%   r   ShortNegotiationFinalUpdater-   r2    r   r   r   r      s_    ' )9 T6#E#E Tg g[4(J(J#K [[c [r   r   N)typingr   app.api.short_negotiation_finalr   'app.models.main.short_negotiation_finalr   r   app.utils.schemas_utilsr   sqlalchemy.ormr   app.dependency.authanticationr	   app.locale.messagesr
   fastapir   r   r;   r   r   <module>rD      s)     2 g 2 " : ( ![ [r   