+
    a}j                     H    ^ RI HtHt ^ RIHt ^ RIHtHt ^ RIH	t	H
t
 R tR# )    )requestjsonify)get_db)error_responsebuild_search_conditions)get_user_id_from_tokenget_admin_from_tokenc                     V P                  R R.R7      R 4       pV P                  RR.R7      R 4       pV P                  RR.R7      R 4       pV P                  RR.R7      R	 4       pR
# )z
/api/usersGET)methodsc            
      T   \         P                  P                  R 4      p \        \         P                  P                  R^4      4      p\        \         P                  P                  R^
4      4      pV^,
          V,          p\	        4       pVP                  4       pRpRp. p. p	V '       dL   RR.p
\        W4      w  rV'       d3   Wk,          pW{,          pVP                  V4       V	P                  V4       VP                  Wy4       VP                  4       ^ ,          pVR,          pVP                  W#.4       VP                  Wh4       VP                  4       pVP                  4        . pV F$  p\        V4      pRVR	&   VP                  V4       K&  	  \        R
VRVRVRV/4      # )searchpagelimitz,SELECT * FROM users WHERE deleted_at IS NULLz3SELECT COUNT(*) FROM users WHERE deleted_at IS NULLphonenicknamez* ORDER BY created_at DESC LIMIT ? OFFSET ?******passworditemstotal)r   argsgetintr   cursorr   extendexecutefetchonefetchallclosedictappendr   )r   r   r   offsetconnr   querycount_queryparamscount_paramssearch_fieldssearch_condsearch_paramsr   rowsr   rowusers                     B   E:\Work\靠谱人脉\软件相关\BangBang\backend\routes\users.py	get_users'register_user_routes.<locals>.get_users   sj   !!(+7<<##FA./GLL$$Wb12(e#x>K$j1M)@)W&K$*m,##M2{1!!$==uo&u% 

C9D'DLL 
 guUVV    z/api/users/<int:user_id>c                     \        4       pVP                  4       pVP                  R V 34       VP                  4       pVP	                  4        V'       g   \        R4      # \        V4      pRVR&   \        V4      # )7SELECT * FROM users WHERE id = ? AND deleted_at IS NULL   用户不存在r   r   )r   r   r   r   r   r   r    r   )user_idr#   r   r,   r-   s   &    r.   get_user&register_user_routes.<locals>.get_user1   sh    xPSZR\]oo

!"344Cy#Zt}r1   z/api/users/<int:user_id>/tasksc           
      >   \         P                  P                  R 4      p\        \         P                  P                  R^4      4      p\        \         P                  P                  R^
4      4      pV^,
          V,          p\	        4       pVP                  4       pRpRpW .p	W .p
V'       dL   RR.p\        W4      w  rV'       d3   W|,          pW,          pV	P                  V4       V
P                  V4       VP                  W4       VP                  4       ^ ,          pVR,          pV	P                  W4.4       VP                  Wy4       VP                  4       pVP                  4        V Uu. uF  p\        V4      NK  	  pp\        RVR	VRVRV/4      # u upi )
r   r   r   z
            SELECT t.*, u.phone as publisher_phone 
            FROM tasks t LEFT JOIN users u ON t.publisher_id = u.id 
            WHERE (t.publisher_id = ? OR t.acceptor_id = ?) AND t.deleted_at IS NULL
        z]SELECT COUNT(*) FROM tasks WHERE (publisher_id = ? OR acceptor_id = ?) AND deleted_at IS NULLzt.titlezt.descriptionz, ORDER BY t.created_at DESC LIMIT ? OFFSET ?r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r    r   )r5   r   r   r   r"   r#   r   r$   r%   r&   r'   r(   r)   r*   r   r+   r,   r   s   &                 r.   get_user_tasks,register_user_routes.<locals>.get_user_tasks@   sb   !!(+7<<##FA./GLL$$Wb12(e#x
 v#)&8M)@)W&K$*m,##M2{1!!$??uo&u% 

&*+dscd+guUVV ,s   1FPUTc                    \         P                  P                  R 4      pV'       d   VP                  R4      '       g   \	        RR4      # VP                  R4      ^,          p\        V4      pV'       g   \	        RR4      # \        RV4      pV'       g   W08w  d   \	        RR4      # \         P                  p\        4       pVP                  4       p. p. p	V'       d1   R	V9   d*   VP                  R
4       V	P                  VR	,          4       RV9   d*   VP                  R4       V	P                  VR,          4       RV9   d*   VP                  R4       V	P                  VR,          4       RV9   d*   VP                  R4       V	P                  VR,          4       RV9   d*   VP                  R4       V	P                  VR,          4       RV9   d*   VP                  R4       V	P                  VR,          4       V'       g   VP                  4        \	        R4      # V	P                  V 4       VP                  RRP                  V4       R2V	4       VP                  4        VP                   ^ 8X  d   VP                  4        \	        R4      # VP                  RV 34       VP#                  4       p
VP                  4        \%        V
4      pRVR&   \'        V4      # )AuthorizationzBearer u   请先登录i   u!   登录已过期，请重新登录Nu   无权修改此用户信息i  enabledzenabled = ?r   znickname = ?genderz
gender = ?provincezprovince = ?cityzcity = ?districtzdistrict = ?u   没有需要更新的字段zUPDATE users SET z, z$ WHERE id = ? AND deleted_at IS NULLr4   r3   r   r   )r   headersr   
startswithr   splitr   r	   jsonr   r   r!   r   r   joincommitrowcountr   r    r   )r5   auth_headertokencurrent_user_idis_admindatar#   r   update_fieldsupdate_valuesupdated_userr-   s   &           r.   update_user)register_user_routes.<locals>.update_useri   se    oo))/:+"8"8"C"C!.#66!!#&q)07!"EsKK (o> O6!"?EE||x 	T)  /  i1   0  j!12t  .  h0  0  j!12T>  ,  f.  0  j!12JJL!"?@@W%*499]+C*DDhikxy??aJJL!"344PSZR\](

L!#Zt}r1   N)route)appr/   r6   r9   rS   s   &    r.   register_user_routesrW      s    YY|eWY-'W .'WR 	YY)E7Y; < 	YY/%YA&W B&WP 	YY)E7Y;B <Br1   N)flaskr   r   utils.databaser   utils.helpersr   r   
utils.authr   r	   rW    r1   r.   <module>r]      s    " ! A Cfr1   