
    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)BrandAttributeAssessmentBaseTblBrandAttributeAssessment)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e	   fd	Zde	fd
Zy)BrandAttributeAssessmentServicedbtokenc                      || _         || _        y )N)r   r   )selfr   r   s      Q/var/www/html/retail-simulation-api/app/api/brand_attribute_assessment/service.py__init__z(BrandAttributeAssessmentService.__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_brand_attribute_assessmentr   commitr   r
   BRAND_ATTRIBUTE_ASSESSMENT)r   r   created_brands      r   create_brandz,BrandAttributeAssessmentService.create_brand   sW     4CCGDVDVDXY#EEmUYU\U\]S(2U2UVVs   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_brand_attribute_assessmentr   r   r    BrandAttributeAssessmentResponser   )r   r"   new_get_brand	get_groups       r   	get_brandz)BrandAttributeAssessmentService.get_brand   s]     3RRS[]a]d]deC8PQQcpqcpV_77FFyQcpqqqs   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
   BRAND_ATTRIBUTE_ASSESSMENT_NOTr   !update_brand_attribute_assessmentr   r   !BRAND_ATTRIBUTE_ASSESSMENT_UPDATE)r   r   requpdated_brands       r   update_brandz,BrandAttributeAssessmentService.update_brand   s     C8GGHXYM%%-%T8;b;bcc'II-J`J`boquqxqxy	 
 	S(2\2\]]s   B4B6c                    K   t        j                  || j                        }|st        dt        j
                        S t        dt        j                        S wr-   )r   !delete_brand_attribute_assessmentr   r   r
   r/   !BRAND_ATTRIBUTE_ASSESSMENT_DELETE)r   r"   deleted_brands      r   delete_brandz,BrandAttributeAssessmentService.delete_brand$   sI     3UUV^`d`g`gh!x7^7^__S(2\2\]]s   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   GetAttributesr   __dict__)r   r"   get_attributesr*   s       r   r@   z.BrandAttributeAssessmentService.get_attributes*   s     'BCJJKfKoKos{K{|  A  A  CC8PQQYghYgI$$33I4F4FGYghhhs   A!B#0BBN)__name__
__module____qualname__r   r	   r   r   BrandAttributeAssessmentCreater!   intr+   r   BrandAttributeAssessmentUpdater4   r9   r@    r   r   r   r   
   sq    7 *: W)N)N Wrs r^f.S.S)T ^^$s) ^iC ir   r   N)typingr   "app.api.brand_attribute_assessmentr   *app.models.main.brand_attribute_assessmentr   r   app.utils.schemas_utilsr   sqlalchemy.ormr   app.dependency.authanticationr	   app.locale.messagesr
   fastapir   r   rG   r   r   <module>rP      s)     5 p 2 " : ( !$i $ir   