def METHOD_NAME(self, user, with_group=True, flat=False):
    """ 获取用户的授权规则 """
    perm_ids = set()
    # user
    user_perm_ids = AssetPermission.users.through.objects.filter(user_id=user.id) \
        .values_list('assetpermission_id', flat=True).distinct()
    perm_ids.update(user_perm_ids)
    # group
    if with_group:
        groups = user.groups.all()
        group_perm_ids = self.get_permissions_for_user_groups(groups, flat=True)
        perm_ids.update(group_perm_ids)
    perms = self.get_permissions(ids=perm_ids)
    if flat:
        return perms.values_list('id', flat=True)
    return perms