six_001
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from django.db import models
|
||||
from uuid6 import uuid8
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class wecom企微员工( models.Model ):
|
||||
"""城市信息表"""
|
||||
objects = models.Manager( ) #
|
||||
wecom企微员工_id = models.UUIDField( primary_key=True, default=uuid8 )
|
||||
# id_str = models.CharField(max_length=128, default=generator.generate_str)
|
||||
wecom_userid = models.CharField( max_length=128, )
|
||||
wecom_department = models.CharField( max_length=128, null=True, blank=True )
|
||||
dateAndTime = models.DateTimeField( auto_now_add=True, db_comment="创建时间" ) # 数据创建时间
|
||||
updateTime = models.DateTimeField( auto_now=True, db_comment="更新时间" ) # 更新时间(需要用 save() )
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
db_table = "wecom企微员工" # 给数据表自定义一个名称;默认的会是在 应用名+类名
|
||||
app_label = "django_app"
|
||||
@@ -0,0 +1,41 @@
|
||||
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 )
|
||||
Reference in New Issue
Block a user