def _populate_valid_params(params=None, valid_keys=None):
    """构建只包含有效keys的params

    :param params: 需要过滤的params
    :type params: dict

    :param valid_keys: 有效的关键key列表
    :type valid_keys: list

    :return: 只包含有效keys的params
    """
    if params is None or valid_keys is None:
        return None
    valid_params = dict()
    for key in valid_keys:
        if params.get(key) is not None:
            valid_params[key] = params[key]
    if len(valid_params) == 0:
        valid_params = None
    return valid_params
