2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-19 19:32:32 +08:00
|
|
|
function SqlWrapMapConfigAdapter() {
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = SqlWrapMapConfigAdapter;
|
|
|
|
|
|
|
|
|
2016-05-23 22:20:42 +08:00
|
|
|
SqlWrapMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfig, params, context, callback) {
|
2016-05-19 19:32:32 +08:00
|
|
|
if (requestMapConfig && Array.isArray(requestMapConfig.layers)) {
|
|
|
|
requestMapConfig.layers = requestMapConfig.layers.map(function(layer) {
|
|
|
|
if (layer.options) {
|
|
|
|
var sqlQueryWrap = layer.options.sql_wrap;
|
|
|
|
if (sqlQueryWrap) {
|
|
|
|
var layerSql = layer.options.sql;
|
|
|
|
if (layerSql) {
|
|
|
|
layer.options.sql_raw = layerSql;
|
|
|
|
layer.options.sql = sqlQueryWrap.replace(/<%=\s*sql\s*%>/g, layerSql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return layer;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return callback(null, requestMapConfig);
|
|
|
|
};
|