Exemple #1
0
    def BatchDelete(userInfo, ids):
        """
        单个删除用户
        Args:
            ids (string[]): 用户主键列表
        Returns:
            returnValue (True or False): 删除结果
        """
        # 已删除用户Piuser表中的DELETEMARK设置为1

        LogService.WriteLog(userInfo, __class__.__name__,
                            FrameworkMessage.UserService,
                            sys._getframe().f_code.co_name,
                            FrameworkMessage.UserService_BatchDelete, str(ids))

        try:
            user = Piuser.objects.filter(id__in=ids)
            if len(user) == 0:
                return False
            user.update(deletemark=1)
        except Exception as e:
            return False
        # 用户已经被删除的员工的UserId设置为Null
        Pistaff.objects.filter(userid__in=Piuser.objects.filter(
            id__in=ids)).update(userid=None)
        # 清除用户的操作权限
        for id in ids:
            UserPermission.ClearUserPermissionByUserId(None, id)
        return True
Exemple #2
0
 def Delete(userInfo, id):
     """
     单个删除用户
     Args:
         id (string): 主键
     Returns:
         returnValue (True or False): 删除结果
     """
     LogService.WriteLog(userInfo, __class__.__name__,
                         FrameworkMessage.UserService,
                         sys._getframe().f_code.co_name,
                         FrameworkMessage.UserService_Delete, id)
     try:
         #已删除用户Piuser表中的DELETEMARK设置为1
         try:
             user = Piuser.objects.get(id=id)
         except Piuser.DoesNotExist as e:
             return False
         user.deletemark = 1
         user.save()
         #用户已经被删除的员工的UserId设置为Null
         Pistaff.objects.filter(userid__in=Piuser.objects.filter(
             deletemark=1)).update(userid=None)
         # 清除用户的操作权限
         UserPermission.ClearUserPermissionByUserId(None, id)
         return True
     except Exception as e:
         return False
Exemple #3
0
 def SetDeleted(userInfo, ids):
     """
     批量打删除标志
     Args:
         ids (string[]): 用户主键列表
     Returns:
         returnValue (True or False): 影响行数
     """
     LogService.WriteLog(userInfo, __class__.__name__,
                         FrameworkMessage.UserService,
                         sys._getframe().f_code.co_name,
                         FrameworkMessage.UserService_SetDeleted, str(ids))
     try:
         user = Piuser.objects.filter(id__in=ids)
         if len(user) == 0:
             return False
         user.update(deletemark=1)
     except Exception as e:
         return False
     # 清除用户的操作权限
     for id in ids:
         UserPermission.ClearUserPermissionByUserId(None, id)
     return True