
    Eh                     |    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)LocationSpillageFactorBaseTblLocationSpillageFactor)CustomResponse)Messages)HTTPException)JWTPayloadSchema)Sessionc                   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)%LocationSpillageFactorAnalysisServicedbtokenc                      || _         || _        y )N)r   r   )selfr   r   s      X/var/www/html/retail-simulation-api/app/api/location_spillage_factor_analysis/service.py__init__z.LocationSpillageFactorAnalysisService.__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_locationr   commitr   r   LOCATION_FACTORS)r   r   created_locations      r   r   z5LocationSpillageFactorAnalysisService.create_location   sV     5DDWEWEWEYZ!112BDGGL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_locationr   r	   r   LocationSpillageFactorResponser   )r   r!   new_get_location	get_groups       r   r%   z2LocationSpillageFactorAnalysisService.get_location   sZ     4AA(DGGTC8PQQaqraqT]55DDYOaqrrrs   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   location_idr   r   LOCATION_FACTORS_NOTr   update_locationr   r   LOCATION_FACTORS_UPDATE)r   r   requpdated_locations       r   update_location1z6LocationSpillageFactorAnalysisService.update_location1   s     C9HHIYZ++3%T8;X;XYY%556F6R6RTdfjfmfmn	 
 	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_locationr   r   r   r,   LOCATION_FACTORS_DELETE)r   r+   deleted_locations      r   r3   z5LocationSpillageFactorAnalysisService.delete_location$   sI     4DD[RVRYRYZ!x7T7TUUS(2R2RSSs   AAN)__name__
__module____qualname__r   r
   r   r   LocationSpillageFactorCreater   intr%   r   LocationSpillageFactorUpdater1   r3    r   r   r   r   
   s_    ' )9 MF,O,O Ms# sTT&2U2U-V TT Tr   r   N)typingr   )app.api.location_spillage_factor_analysisr   1app.models.main.location_spillage_factor_analysisr   r   app.utils.schemas_utilsr   app.locale.messagesr   fastapir	   app.dependency.authanticationr
   sqlalchemy.ormr   r   r<   r   r   <module>rE      s)     < s 2 ( ! : "T Tr   