|
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -174,5 +175,25 @@ public class CodegenController {
|
|
|
// 输出
|
|
|
writeAttachment(response, "codegen.zip", outputStream.toByteArray());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/downloadAll")
|
|
|
+ @Parameter(name = "tableIds", description = "表编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('infra:codegen:download')")
|
|
|
+ public void downloadCodegenNew(@RequestParam("ids") List<Long> tableId,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ // 生成代码
|
|
|
+ Map<String, String> codes = new HashMap<>();
|
|
|
+ for (Long id : tableId) {
|
|
|
+ codes.putAll(codegenService.generationCodesNew(id));
|
|
|
+ }
|
|
|
+ // 构建 zip 包
|
|
|
+ String[] paths = codes.keySet().toArray(new String[0]);
|
|
|
+ ByteArrayInputStream[] ins =
|
|
|
+ codes.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new);
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ ZipUtil.zip(outputStream, paths, ins);
|
|
|
+ // 输出
|
|
|
+ writeAttachment(response, "codegen.zip", outputStream.toByteArray());
|
|
|
+ }
|
|
|
}
|