|
@@ -1,9 +1,11 @@
|
|
|
# @Author : Rocky
|
|
|
# @File : InitController.py
|
|
|
# @Time : 2023/4/11 17:26
|
|
|
+from django.contrib.auth.hashers import check_password
|
|
|
from django.http import HttpResponse
|
|
|
from django.views import View
|
|
|
|
|
|
+from Model.models import Device_User, Device_Info, Order_Model, UID_Bucket, Unused_Uid_Meal
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
|
|
|
|
|
@@ -20,10 +22,41 @@ class InitView(View):
|
|
|
return self.validation(request.POST, operation)
|
|
|
|
|
|
def validation(self, request_dict, operation):
|
|
|
- if operation == 'health-check': # 负载均衡器健康检测接口
|
|
|
+ if operation == 'health-check': # 负载均衡器健康检测接口
|
|
|
return self.health_check(request_dict)
|
|
|
+ elif operation == 'delete-account': # 网页删除账号
|
|
|
+ return self.delete_account(request_dict)
|
|
|
|
|
|
@staticmethod
|
|
|
def health_check(request_dict):
|
|
|
response = ResponseObject()
|
|
|
return response.json(0)
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def delete_account(request_dict):
|
|
|
+ username = request_dict.get('username', None)
|
|
|
+ password = request_dict.get('password', None)
|
|
|
+ response = ResponseObject()
|
|
|
+
|
|
|
+ device_user_qs = Device_User.objects.filter(username=username).values('password', 'userID')
|
|
|
+ if not device_user_qs.exists():
|
|
|
+ return response.json(104)
|
|
|
+
|
|
|
+ cipher_password, user_id = device_user_qs[0]['password'], device_user_qs[0]['userID']
|
|
|
+ if not check_password(password, cipher_password):
|
|
|
+ return response.json(111)
|
|
|
+
|
|
|
+ device_info_qs = Device_Info.objects.filter(userID=user_id)
|
|
|
+ if device_info_qs.exists():
|
|
|
+ return response.json(10047)
|
|
|
+
|
|
|
+ uid_list = Order_Model.objects.filter(userID=user_id, status=1).values_list('UID').distinct().order_by('UID')
|
|
|
+ uid_bucket_qs = UID_Bucket.objects.filter(uid__in=uid_list, use_status=1)
|
|
|
+ if uid_bucket_qs.exists():
|
|
|
+ return response.json(10046)
|
|
|
+
|
|
|
+ unused_uid_meal_qs = Unused_Uid_Meal.objects.filter(uid__in=uid_list)
|
|
|
+ if unused_uid_meal_qs.exists():
|
|
|
+ return response.json(10046)
|
|
|
+ device_user_qs.delete()
|
|
|
+ return response.json(0)
|