42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import threading
|
|||
|
|
|
||
|
|
import pydash
|
||
|
|
import requests
|
||
|
|
from rest_framework import status
|
||
|
|
from rest_framework.decorators import action
|
||
|
|
from rest_framework.request import Request
|
||
|
|
from rest_framework.response import Response
|
||
|
|
from rest_framework.viewsets import ViewSet
|
||
|
|
|
||
|
|
from sixGuoDjango import BaseResponse, ResData
|
||
|
|
from wechat_token.token工具包 import sixToken
|
||
|
|
from wechat_wecom_企业微信管理.企微通讯录管理.企微通讯录管理数据库.企微员工数据 import wecom企微员工
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class 企微员工通讯录管理接口ViewSets( ViewSet ):
|
||
|
|
lock = threading.Lock( )
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
@action( detail=False, methods=[ "get", "post", "put", "delete" ], url_path="获取成员ID列表" )
|
||
|
|
def 获取成员ID列表( self, request: Request ):
|
||
|
|
pass
|
||
|
|
wecom_phone_token = sixToken.get_weom_phone_token( )
|
||
|
|
uri = f"https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token={wecom_phone_token}"
|
||
|
|
postData = requests.post( url=uri, json={
|
||
|
|
"limit": 10000
|
||
|
|
} )
|
||
|
|
|
||
|
|
企微员工列表数据 = pydash.get( obj=postData.json( ), path="dept_user" )
|
||
|
|
print( 企微员工列表数据 )
|
||
|
|
for 员工 in 企微员工列表数据:
|
||
|
|
print( 员工 )
|
||
|
|
userid = pydash.get( obj=员工, path="userid" )
|
||
|
|
department = pydash.get( obj=员工, path="department" )
|
||
|
|
wecom企微员工.objects.get_or_create( wecom_userid=userid, wecom_department=department )
|
||
|
|
httpResData = BaseResponse( resData=ResData( listData=[ ], dictData={ } ), ).model_dump( )
|
||
|
|
return Response( data=httpResData, status=status.HTTP_200_OK )
|