Ë
    :gýj�  ã                   óX   — d dl Z d dlmZ d dlmZmZmZ d dlmZ d dl	m
Z
  G d„ d«      Zy)é    N)ÚOptional)ÚfuncÚselectÚupdate)ÚAsyncSession)ÚNotificationc                   ó  — e Zd Zdefd„Z	 	 	 ddej                  dedededee   d	eej                     d
e	fd„Z
	 	 ddej                  deded
ee	   fd„Zdej                  deej                     d
efd„Zdej                  d
efd„Zy)ÚNotificationRepositoryÚdbc                 ó   — || _         y )N)r   )Úselfr   s     ú7/root/telegram-saas/modules/notifications/repository.pyÚ__init__zNotificationRepository.__init__	   s	   € Øˆ�ó    NÚ	tenant_idÚtitleÚmessageÚcategoryÚ
action_urlÚuser_idÚreturnc           
   ƒ   ó   K  — t        t        j                  «       ||||||d¬«      }| j                  j	                  |«       | j                  j                  «       ƒ d {  –—†  | j                  j                  |«      ƒ d {  –—†  |S 7 Œ)7 Œ­w)NF)Úidr   r   r   r   r   r   Úis_read)r   ÚuuidÚuuid4r   ÚaddÚcommitÚrefresh)r   r   r   r   r   r   r   Únotifs           r   ÚcreatezNotificationRepository.create   sz   è ø€ ô Ü�z‰z‹|ØØØØØØ!Øô	
ˆð 	�‰�‰�EÔØ�g‰g�n‰nÓ×ÐØ�g‰g�o‰o˜eÓ$×$Ð$Øˆð 	øØ$ús$   ‚ABÁ B
Á!"BÂBÂBÂBÚunread_onlyÚlimitc              ƒ   óØ  K  — t        t        «      j                  t        j                  |k(  «      }|r.|j                  t        j                  j                  d«      «      }|j                  t        j                  j                  «       «      j                  |«      }| j                  j                  |«      ƒ d {  –—† }t        |j                  «       j                  «       «      S 7 Œ+­w)NF)r   r   Úwherer   r   Úis_Úorder_byÚ
created_atÚdescr#   r   ÚexecuteÚlistÚscalarsÚall)r   r   r"   r#   ÚstmtÚress         r   Úlist_by_tenantz%NotificationRepository.list_by_tenant$   s¦   è ø€ ô ”lÓ#×)Ñ)¬,×*@Ñ*@ÀIÑ*MÓNˆÙØ—:‘:œl×2Ñ2×6Ñ6°uÓ=Ó>ˆDØ�}‰}œ\×4Ñ4×9Ñ9Ó;Ó<×BÑBÀ5ÓIˆØ—G‘G—O‘O DÓ)×)ˆÜ�C—K‘K“M×%Ñ%Ó'Ó(Ð(ð *ús   ‚B:C*Â<C(Â=,C*Únotification_idsc              ƒ   ór  K  — | j                   j                  t        t        «      j	                  t        j
                  |k(  t        j                  j                  |«      «      j                  d¬«      «      ƒ d {  –—† }| j                   j                  «       ƒ d {  –—†  |j                  xs dS 7 Œ67 Œ­w)NT)r   r   )r   r*   r   r   r%   r   r   Úin_Úvaluesr   Úrowcount)r   r   r1   r/   s       r   Ú	mark_readz NotificationRepository.mark_read1   s�   è ø€ ð
 —G‘G—O‘OÜ”<Ó ß‰UÜ×&Ñ&¨)Ñ3Ü—‘×#Ñ#Ð$4Ó5ó÷ ‰V˜DˆVÓ!ó
÷ 
ˆð �g‰g�n‰nÓ×ÐØ�|‰|Ò ˜qÐ ð
øð 	ús$   ‚A:B7Á<B3Á=!B7ÂB5ÂB7Â5B7c              ƒ   óL  K  — | j                   j                  t        t        j                  t
        j                  «      «      j                  t
        j                  |k(  t
        j                  j                  d«      «      «      ƒ d {  –—† }|j                  «       xs dS 7 Œ­w)NFr   )r   r*   r   r   Úcountr   r   r%   r   r   r&   Úscalar)r   r   r/   s      r   Úcount_unreadz#NotificationRepository.count_unreadA   sw   è ø€ Ø—G‘G—O‘OÜ”4—:‘:œlŸo™oÓ.Ó/×5Ñ5Ü×&Ñ&¨)Ñ3Ü×$Ñ$×(Ñ(¨Ó/óó
÷ 
ˆð �z‰z‹|Ò ˜qÐ ð
ús   ‚BB$Â	B"Â
B$)ÚsystemNN)Fé2   )Ú__name__Ú
__module__Ú__qualname__r   r   r   ÚUUIDÚstrr   r   r!   ÚboolÚintr+   r0   r6   r:   © r   r   r
   r
      só   „ ð˜<ó ð !Ø$(Ø'+ñà—9‘9ðð ðð ð	ð
 ðð ˜S‘Mðð ˜$Ÿ)™)Ñ$ðð 
óð6 "Øñ	)à—9‘9ð)ð ð)ð ð	)ð
 
ˆlÑ	ó)ð!à—9‘9ð!ð ˜tŸy™y™/ð!ð 
ó	!ð !¨D¯I©Ið !¸#ô !r   r
   )r   Útypingr   Ú
sqlalchemyr   r   r   Úsqlalchemy.ext.asyncior   Úmodules.notifications.modelsr   r
   rD   r   r   ú<module>rI      s#   ðÛ Ý ß +Ñ +Ý /Ý 5÷@!ò @!r   