public Result downModelParams(String uuid, HttpServletResponse response) {
if (StringUtils.isBlank(uuid)) {
throw new IllegalArgumentException(“参数不能为空”);
}
AiModel aiModel = aiModelMapper.selectModelByUuid(uuid);
if (aiModel == null || aiModel.getParams() == null) {
throw new IllegalArgumentException(“模型参数为空”);
}
Map<String, String> map = new LinkedHashMap<>();
map.put(“1”, “ID”);
map.put(“2”, “标题”);
map.put(“3”, “数据类型”);
List
package com.beagledata.gaea.workbench.common;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.;
import java.net.URLEncoder;
import java.util.;
/**
- Created by mahongfei on 2019/3/21.
/
public class CsvUtil {
/*
-
@Author: mahongfei
-
@description: 生成并下载csv文件
*/
public static void exportDataFile(HttpServletResponse response,
List
OutputStream out = response.getOutputStream();
response.reset();
response.setContentType("application/csv;charset=UTF-8");
response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode(fileName+".csv", "UTF-8"));
response.setCharacterEncoding("UTF-8");
while ((len = in.read(buffer)) > 0) {
out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
out.write(buffer, 0, len);
}
out.close();
} catch (FileNotFoundException e) {
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
public static String getBOM() {
byte b[] = {(byte)0xEF, (byte)0xBB, (byte)0xBF};
return new String(b);
}
}