
    J)i
                     |    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)BrandingAttributesBaseTblBrandingAttributes)CustomResponse)Session)JWTPayloadSchema)Messages)HTTPExceptionc                       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de	fdZy)BrandingAttributesServicedbtokenc                      || _         || _        y )N)r   r   )selfr   r   s      J/var/www/html/retail-simulation-api/app/api/branding_attributes/service.py__init__z"BrandingAttributesService.__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_branding_attributesr   commitr   r
   BRANDING_ATTRIBUTES)r   r   created_branding_attributess      r   r   z4BrandingAttributesService.create_branding_attributes   sY     &<&K&KGL^L^L`&a#889TVZV]V]^S(2N2NOOs   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_branding_attributesr   r   r   BrandingAttributesResponser   )r   r!   new_get_branding_attributes	get_groups       r   r&   z1BrandingAttributesService.get_branding_attributes   s^     &;&S&ST\^b^e^e&f#*C8PQQ]xy]xPY11@@K]xyyys   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   brand_idr   r
   BRANDING_ATTRIBUTES_NOTr   update_branding_attributesr   r   BRANDING_ATTRIBUTES_UPDATE)r   r   requpdated_branding_attributess       r   r.   z4BrandingAttributesService.update_branding_attributes   s     C*@*O*OPSP^P^P`*a'*33;%T8;[;[\\!<<=X=a=ac~  AE  AH  AH  I	 
 	S(2U2UVVs   B4B6r,   c                    K   t        j                  || j                        }|st        dt        j
                        S t        dt        j                        S wr+   )r   delete_branding_attributesr   r   r
   r-   BRANDING_ATTRIBUTES_DELETE)r   r,   deleted_branding_attributess      r   r3   z4BrandingAttributesService.delete_branding_attributes$   sJ     &;&V&VW_aeahah&i#*!x7W7WXXS(2U2UVVs   AAc                 :  K   | j                   j                  t              j                  t        j                  |k(        j                         }|st        dd      |D cg c]+  }t        j                  j                  |j                        - c}S c c}w wr#   )r   queryr   filterr!   allr   r   Get_BrandAndOwnr   __dict__)r   r!   get_data	get_datass       r   get_brand_attributez-BrandingAttributesService.get_brand_attribute*   s|     77==!67>>?T?]?]ai?ijnnpC8PQQ[cd[ci&&55i6H6HI[cddds   A!B#0BBN)__name__
__module____qualname__r   r	   r   r   BrandingAttributesCreater   intr&   r   BrandingAttributesUpdater.   r3   r>    r   r   r   r   
   sm    ' )9 Pv7V7V PzS zWtF<[<[7\ WW We er   r   N)typingr   app.api.branding_attributesr   #app.models.main.branding_attributesr   r   app.utils.schemas_utilsr   sqlalchemy.ormr   app.dependency.authanticationr	   app.locale.messagesr
   fastapir   r   rE   r   r   <module>rN      s)     . ] 2 " : ( !$e $er   