def Delete(request): try: key = request.POST['key'] except: key = '' returnValue = UserSerivce.SetDeleted( CommonUtils.Current(HttpResponse(), request), [key]) if returnValue: response = HttpResponse() response.content = json.dumps({ 'Success': True, 'Data': '1', 'Message': FrameworkMessage.MSG0013 }) return response else: response = HttpResponse() response.content = json.dumps({ 'Success': False, 'Data': '0', 'Message': FrameworkMessage.MSG3020 }) return response
def SetDeleted(userInfo, ids): """ 批量打删除标志 Args: ids (string[]): 员工主键列表 Returns: returnValue (bool): 删除结果 """ LogService.WriteLog(userInfo, __class__.__name__, FrameworkMessage.StaffService, sys._getframe().f_code.co_name, FrameworkMessage.StaffService_SetDeleted, str(ids)) try: try: UserSerivce.SetDeleted(None, Pistaff.objects.filter(id__in=ids).values_list('userid', flat=True)) Piuserrole.objects.filter(userid__in=Pistaff.objects.filter(id__in=ids)).delete() except Pistaff.DoesNotExist as e: pass Pistafforganize.objects.filter(staffid__in=ids).update(deletemark = 1) Pistaff.objects.filter(id__in=ids).update(deletemark = 1) return True except Exception as e: return False
def DeleteUser(userInfo, staffId): """ 删除员工关联的用户 Args: staffId (string): 员工主键 Returns: returnValue (bool): 删除结果 """ LogService.WriteLog(userInfo, __class__.__name__, FrameworkMessage.StaffService, sys._getframe().f_code.co_name, FrameworkMessage.StaffService_DeleteUser, staffId) try: try: staff = Pistaff.objects.get(id = staffId) ids = [staff.userid] UserSerivce.SetDeleted(None, ids) except Pistaff.DoesNotExist as e: pass staff = Pistaff.objects.get(id = staffId) staff.userid = None staff.save() return True except Exception as e: return False