
    Eh                     |    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	 d dl
mZ d dlmZmZ d dlmZ  G d	 d
      Zy)    )List)Session)HTTPException)schema)Messages)JWTPayloadSchema)LocationDetailsBaseTblLocationDetails)CustomResponsec                   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)LocationDetailsServicedbtokenc                      || _         || _        y )N)r   r   )selfr   r   s      G/var/www/html/retail-simulation-api/app/api/location_details/service.py__init__zLocationDetailsService.__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
   create_location_detailsr   commitr   r   LOCATION_DETAILS)r   r   created_location_detailss      r   r   z.LocationDetailsService.create_location_details   sV     #6#E#EgFXFXFZ#[ 223KTWWUS(2K2KLLs   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
   get_location_detailsr   r   r   LocationDetailsResponser   )r   r!   new_get_location_details	get_groups       r   r%   z+LocationDetailsService.get_location_details   s\     #5#J#J8UYU\U\#] 'C8PQQZrsZrY..==iHZrssss   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   
details_idr   r   LOCATION_DETAILS_NOTr
   update_location_detailsr   r   LOCATION_DETAILS_UPDATE)r   r   requpdated_location_detailss       r   r-   z.LocationDetailsService.update_location_details   s     C':'I'I#..JZ'[$'22:%T8;X;XYY667O7Z7Z\tvzv}v}~	 
 	S(2R2RSSs   B4B6r+   c                    K   t        j                  || j                        }|st        dt        j
                        S t        dt        j                        S wr*   )r
   delete_location_detailsr   r   r   r,   LOCATION_DETAILS_DELETE)r   r+   deleted_location_detailss      r   r2   z.LocationDetailsService.delete_location_details$   sI     #5#M#MjZ^ZaZa#b '!x7T7TUUS(2R2RSSs   AAN)__name__
__module____qualname__r   r   r   r   LocationDetailsCreater   intr%   r   LocationDetailsUpdater-   r2    r   r   r   r   
   s_    ' )9 MF4P4P Mt# tTD9U9U4V TTs Tr   r   N)typingr   sqlalchemy.ormr   fastapir   app.api.location_detailsr   app.locale.messagesr   app.dependency.authanticationr    app.models.main.location_detailsr	   r
   app.utils.schemas_utilsr   r   r;   r   r   <module>rD      s)     " ! + ( : T 2T Tr   