/**

示例：

    参数 sql :  select * from tableName where 'Id' = #{id} and 'state' = #{state}

    参数 params : {id:12343,state:1}

    返回结果： select * from tableName where 'Id' = 12343 and 'state' = 1

*/

export function replaceSqlParams(sql, params) {
    return sql.replace(/#\{([^}]+)\}/g, (match, p1) => {
        if (params.hasOwnProperty(p1)) {
            return typeof params[p1] === 'string' ? `'${params[p1]}'` : params[p1];
        }
        throw new Error(`缺少参数: ${p1}`);
    });
}