|
@@ -15,7 +15,7 @@ from django.views.generic.base import View
|
|
|
|
|
|
from Controller.SensorGateway.EquipmentFamilyController import EquipmentFamilyView
|
|
|
from Model.models import UserFamily, FamilyMemberJoin, FamilyMember, SysMsgModel, FamilyMemberPermission, \
|
|
|
- Device_User
|
|
|
+ Device_User, FamilyRoomDevice
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -62,6 +62,34 @@ class GatewayFamilyMemberView(View):
|
|
|
return self.family_created(app_user_id, request_dict, response)
|
|
|
elif operation == 'del/home':
|
|
|
return self.del_home(app_user_id, request_dict, response)
|
|
|
+ elif operation == 'join/del':
|
|
|
+ return self.member_join_del(app_user_id, request_dict, response)
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def member_join_del(cls, app_user_id, request_dict, response):
|
|
|
+ """
|
|
|
+ 删除最近联系人
|
|
|
+ @param app_user_id:
|
|
|
+ @param request_dict:
|
|
|
+ @param response:
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ join_id = request_dict.get('joinId', None)
|
|
|
+ if not join_id:
|
|
|
+ return response.json()
|
|
|
+ family_member_join_qs = FamilyMemberJoin.objects.filter(id=join_id)
|
|
|
+ if not family_member_join_qs.exists():
|
|
|
+ return response.json(173)
|
|
|
+ is_owner = EquipmentFamilyView.get_family_owner(app_user_id, family_member_join_qs.first().family_id)
|
|
|
+ if not is_owner:
|
|
|
+ return response.json(404)
|
|
|
+ try:
|
|
|
+ with transaction.atomic():
|
|
|
+ family_member_join_qs.delete()
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(177, repr(e))
|
|
|
|
|
|
@classmethod
|
|
|
def del_home(cls, app_user_id, request_dict, response):
|
|
@@ -72,16 +100,19 @@ class GatewayFamilyMemberView(View):
|
|
|
@param response:
|
|
|
@return:
|
|
|
"""
|
|
|
- familyId = request_dict.get('familyId', None)
|
|
|
- if not familyId:
|
|
|
+ family_id = request_dict.get('familyId', None)
|
|
|
+ if not family_id:
|
|
|
return response.json(444)
|
|
|
- is_owner = EquipmentFamilyView.get_family_owner(app_user_id, familyId)
|
|
|
+ is_owner = EquipmentFamilyView.get_family_owner(app_user_id, family_id)
|
|
|
if not is_owner:
|
|
|
return response.json(404)
|
|
|
- familyId = int(familyId)
|
|
|
+ family_id = int(family_id)
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
- user_family_qs = UserFamily.objects.filter(id=familyId)
|
|
|
+ family_room_device_qs = FamilyRoomDevice.objects.filter(family_id=family_id)
|
|
|
+ if family_room_device_qs.exists():
|
|
|
+ family_room_device_qs.delete()
|
|
|
+ user_family_qs = UserFamily.objects.filter(id=family_id)
|
|
|
if user_family_qs.exists():
|
|
|
user_family_qs.delete()
|
|
|
return response.json(0)
|
|
@@ -376,7 +407,7 @@ class GatewayFamilyMemberView(View):
|
|
|
family_id = request_dict.get('familyId', None)
|
|
|
if not all([page_no, page_size, family_id]):
|
|
|
return response.json(444)
|
|
|
- member_join = FamilyMemberJoin.objects.filter(family_id=family_id).values('status', 'user__username',
|
|
|
+ member_join = FamilyMemberJoin.objects.filter(family_id=family_id).values('id', 'status', 'user__username',
|
|
|
'user__userIconUrl', 'user__phone',
|
|
|
'user__userEmail', 'updated_time',
|
|
|
'created_time',
|
|
@@ -390,6 +421,7 @@ class GatewayFamilyMemberView(View):
|
|
|
result = []
|
|
|
for item in member_join:
|
|
|
result.append({
|
|
|
+ 'joinId': item['id'],
|
|
|
'status': item['status'],
|
|
|
'userName': item['user__username'],
|
|
|
'userIconUrl': item['user__userIconUrl'],
|