
    i                     b    d dl mZ d dlmZmZ d dlmZ ddlmZ  G d dej                        Zy)	    )
SQLAlchemy)generate_password_hashcheck_password_hash)datetime   )dbc                      e Zd Z ej                  ej
                  d      Z ej                   ej                  d      dd      Z ej                   ej                  d      dd      Z	 ej                   ej                  d      d      Z
 ej                  ej                  d	      Z ej                  ej                  ej                  	      Z ej                  ej                  ej                  ej                  
      Z ej$                  ddd      Z ej$                  dd      Z ej$                  dd      Z ej$                  dd      Z ej$                  dd      Zd Zd Zd Zd Zy)UserT)primary_keyP   F)uniquenullablex      )r   )default)r   onupdateUserProfileuser)back_populatesuselistSubscription)r   PaymentPaymentHistoryUserContentAccessc                 $    t        |      | _        y)u,   비밀번호 설정 - werkzeug 해시 사용N)r   password_hashselfpasswords     D/home/kdj-ubuntu1/mlink_AI_Server/mlink-backend/./src/models/user.pyset_passwordzUser.set_password   s    3H=    c                 .    t        | j                  |      S )u,   비밀번호 검증 - werkzeug 해시 사용)r   r   r   s     r    check_passwordzUser.check_password   s    "4#5#5x@@r"   c                     | j                   | j                  | j                  | j                  | j                  r| j                  j                         nd | j                  r| j                  j                         dS d dS )N)idusernameemail	is_active
created_at
updated_at)r&   r'   r(   r)   r*   	isoformatr+   r   s    r    to_dictzUser.to_dict   sg    ''ZZ9=$//335d9=$//335
 	
 OS
 	
r"   c                 "    d| j                    dS )Nz<User >)r'   r-   s    r    __repr__zUser.__repr__(   s    a((r"   N)__name__
__module____qualname__r   ColumnIntegerr&   Stringr'   r(   r   Booleanr)   DateTimer   utcnowr*   r+   relationshipprofilesubscriptionspaymentspayment_historiescontent_accessr!   r$   r.   r1    r"   r    r
   r
      s6   	2::4	0Bryy2teDHBIIibiinTEBEBIIibiinu=M		"**d3I2;;@J2;;(//ZJ boomFERG#BOON6JMry@H'(8P$R__%8PN>A
)r"   r
   N)	flask_sqlalchemyr   werkzeug.securityr   r   r   r   Modelr
   rA   r"   r    <module>rE      s!    ' I  #)288 #)r"   