Search in sources :

Example 1 with DataListBuilderImpl

use of com.rebuild.core.support.general.DataListBuilderImpl in project rebuild by getrebuild.

the class GeneralListController method dataList.

@PostMapping("data-list")
public JSON dataList(@PathVariable String entity, HttpServletRequest request) {
    JSONObject query = (JSONObject) ServletUtils.getRequestJson(request);
    DataListBuilder builder = new DataListBuilderImpl(query, getRequestUser(request));
    return builder.getJSONResult();
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) DataListBuilder(com.rebuild.core.support.general.DataListBuilder) DataListBuilderImpl(com.rebuild.core.support.general.DataListBuilderImpl)

Example 2 with DataListBuilderImpl

use of com.rebuild.core.support.general.DataListBuilderImpl in project rebuild by getrebuild.

the class DataExporter method exportCsv.

/**
 * 导出到指定文件
 *
 * @param dest
 */
protected void exportCsv(File dest) {
    DataListBuilderImpl control = new DataListBuilderImpl(queryData, getUser());
    List<String> head = this.buildHead(control);
    try (FileOutputStream fos = new FileOutputStream(dest, true)) {
        try (OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8)) {
            try (BufferedWriter writer = new BufferedWriter(osw)) {
                writer.write("\ufeff");
                writer.write(mergeLine(head));
                for (List<String> row : this.buildData(control)) {
                    writer.newLine();
                    writer.write(mergeLine(row));
                    count++;
                }
                writer.flush();
            }
        }
    } catch (IOException e) {
        throw new RebuildException("Cannot write .csv file", e);
    }
}
Also used : DataListBuilderImpl(com.rebuild.core.support.general.DataListBuilderImpl) RebuildException(com.rebuild.core.RebuildException)

Aggregations

DataListBuilderImpl (com.rebuild.core.support.general.DataListBuilderImpl)2 JSONObject (com.alibaba.fastjson.JSONObject)1 RebuildException (com.rebuild.core.RebuildException)1 DataListBuilder (com.rebuild.core.support.general.DataListBuilder)1