工程实践
【magic-api】通过文件返回文本内容示例
· 三面体
import com.alibaba.fastjson.JSON import cn.hutool.core.util.StrUtil import response; var geojsonName = path.geojsonName; if (StrUtil.isBlankIfStr(geojsonName)){
magic-api
import com.alibaba.fastjson.JSON
import cn.hutool.core.util.StrUtil
import response;
var geojsonName = path.geojsonName;
if (StrUtil.isBlankIfStr(geojsonName)){
return;
}
geojsonName = StrUtil.removeAll(geojsonName,".geojson")
var features = db.xc.select("""
SELECT * FROM geojson WHERE geojson_name = #{geojsonName} AND delete_flag = 0
""")
if (features.size() == 0){
return;
}
var template = JSON.parse(features[0].template);
template.features = features.map(item=>JSON.parse(item.features));
// return template;
return response.download(JSON.toJSONString(template), String.format("%s.geojson", geojsonName));