1 回复
2875557447 medium avatar
#1 - 28 天前
2875557447

看了源码,如下:

用户签到接口

def user_sign(request):
eid = request.POST.get('eid','') # 发布会id
phone = request.POST.get('phone','') # 嘉宾手机号

if eid =='' or phone == '':
return JsonResponse({'status':10021,'message':'parameter error'})

try:
result = Event.objects.get(id=eid)
except Event.DoesNotExist:
return JsonResponse({'status': 10022, 'message': 'event id null'})

if result.status is False:
return JsonResponse({'status': 10023, 'message': 'event status is not available'})

event_time = result.start_time # 发布会时间
timeArray = time.strptime(str(event_time), "%Y-%m-%d %H:%M:%S")
e_time = int(time.mktime(timeArray))

n_time = int(time.time()) # 当前时间

if n_time >= e_time:
return JsonResponse({'status':10024,'message':'event has started'})

result = Guest.objects.filter(phone=phone)
if not result:
return JsonResponse({'status':10025,'message':'user phone null'})
else:
for res in result:
if res.event_id == int(eid):
break
else:
return JsonResponse({'status': 10026, 'message': 'user did not participate in the conference'})

result = Guest.objects.get(event_id=eid, phone=phone)
print(result.sign)
if result.sign is True:
return JsonResponse({'status':10027,'message':'user has sign in'})
else:
result.sign = True
result.save()
return JsonResponse({'status':200,'message':'sign success'})

测试学习小组 — 软件测试学习讨论区
现在注册
已注册用户请 登入
内容分享

欢迎关注我们的公众号: 测试圈TC


小贴士

你的问题在测试教程网中能找到答案