49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
from typing import cast
|
|
|
|
from channels.layers import BaseChannelLayer, get_channel_layer
|
|
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_数据库.用户数据库.小程序登陆用户 import weiuser
|
|
|
|
default_channel_layer = cast(BaseChannelLayer, get_channel_layer(alias="default"))
|
|
|
|
from functools import wraps
|
|
import threading
|
|
|
|
|
|
def sync_lock(lock):
|
|
def decorator(fn):
|
|
@wraps(fn)
|
|
def wrapper(*args, **kwargs):
|
|
with lock:
|
|
return fn(*args, **kwargs)
|
|
|
|
return wrapper
|
|
|
|
return decorator
|
|
|
|
|
|
class 项目初始化功能接口ViewSets(ViewSet):
|
|
lock = threading.Lock() # 所有请求 共享这一个 lock对象
|
|
|
|
@sync_lock(lock=lock) # 锁住这个接口所有并发请求,
|
|
@action(detail=False, methods=["get", "post", "put", "delete"], url_path="初始化")
|
|
def 只用于初始化项目测试接口(self, request: Request):
|
|
""""""
|
|
six六果对象xiao, six是否新创建值 = weiuser.objects.update_or_create(unionid="六果",
|
|
defaults={
|
|
"user_IP地址": None, "user_昵称": "六果", "user_用户当前的等级": 0, "user_省份": "六果", "user_城市": "六果", "user_区县": "六果",
|
|
"user_街道信息": "六果", "user_头像": "https://hudie.xiao.band/%E6%9C%AA%E5%91%BD%E5%90%8D.png", "user_绑定企微usrID账号": "六果", "user_角色权限": "六果", "external_userid": "六果",
|
|
"parent_id": "六果", "mini_openid": "wxf612e825377328f0", "wechat_openid": "六果", "wecom_openid": "wwbe6369dc26a9d83a", "codeConfigId": "六果", "codeRemark": "六果",
|
|
"codeQrCode": "https://hudie.xiao.band/mini.jpg",
|
|
"user_企微角色权限": "六果", "user_绑定企微UNIONID": "六果"
|
|
})
|
|
|
|
httpResData = BaseResponse(resData=ResData(listData=[""], dictData={}), ).model_dump()
|
|
return Response(data=httpResData, status=status.HTTP_200_OK)
|