mirror of
https://github.com/vran-dev/databasir.git
synced 2025-08-09 23:11:00 +08:00
feat: use plantuml to export er diagram
This commit is contained in:
@@ -22,9 +22,10 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.springframework.data.domain.Sort.Direction.DESC;
|
||||
|
||||
@@ -75,9 +76,10 @@ public class DocumentController {
|
||||
Long version,
|
||||
@RequestParam DocumentFileType fileType) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String fileName = "project[" + projectId + "]." + fileType.getFileExtension();
|
||||
String projectName = projectService.getOne(projectId).getName();
|
||||
String fileName = projectName + "." + fileType.getFileExtension();
|
||||
headers.setContentDisposition(ContentDisposition.attachment()
|
||||
.filename("demo.md", StandardCharsets.UTF_8)
|
||||
.filename(fileName)
|
||||
.build());
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
return ResponseEntity.ok()
|
||||
@@ -85,6 +87,14 @@ public class DocumentController {
|
||||
.body(out -> documentService.export(projectId, version, fileType, out));
|
||||
}
|
||||
|
||||
@GetMapping(Routes.Document.EXPORT_TYPES)
|
||||
public JsonData<List<DocumentFileTypeResponse>> getDocumentFileTypes() {
|
||||
List<DocumentFileTypeResponse> types = Arrays.stream(DocumentFileType.values())
|
||||
.map(type -> new DocumentFileTypeResponse(type.getName(), type.getFileExtension(), type))
|
||||
.collect(Collectors.toList());
|
||||
return JsonData.ok(types);
|
||||
}
|
||||
|
||||
@GetMapping(Routes.Document.GET_SIMPLE_ONE)
|
||||
@Operation(summary = "获取文档(无详情信息)")
|
||||
public JsonData<DatabaseDocumentSimpleResponse> getSimpleByProjectId(@PathVariable Integer projectId,
|
||||
|
@@ -92,6 +92,8 @@ public interface Routes {
|
||||
|
||||
String EXPORT = BASE + "/projects/{projectId}/document_files";
|
||||
|
||||
String EXPORT_TYPES = BASE + "/document_file_types";
|
||||
|
||||
String LIST_TABLES = BASE + "/projects/{projectId}/tables";
|
||||
}
|
||||
|
||||
|
@@ -11,15 +11,30 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.web.config.EnableSpringDataWebSupport;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Configuration
|
||||
@EnableSpringDataWebSupport
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
|
||||
ThreadPoolTaskExecutor mvcExecutor = new ThreadPoolTaskExecutor();
|
||||
int maxCorePoolSize = 64;
|
||||
int availableProcessorCount = Runtime.getRuntime().availableProcessors();
|
||||
int corePoolSize = Math.min(maxCorePoolSize, availableProcessorCount);
|
||||
mvcExecutor.setCorePoolSize(corePoolSize);
|
||||
mvcExecutor.setMaxPoolSize(maxCorePoolSize);
|
||||
mvcExecutor.setThreadNamePrefix("mvc-executor-");
|
||||
mvcExecutor.initialize();
|
||||
configurer.setTaskExecutor(mvcExecutor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
server.port=8080
|
||||
logging.level.org.jooq=INFO
|
||||
logging.level.com.databasir.core.domain.document.generator=debug
|
||||
spring.jooq.sql-dialect=mysql
|
||||
springdoc.swagger-ui.path=/open-api.html
|
||||
# flyway
|
||||
|
@@ -16,4 +16,5 @@ spring.flyway.locations=classpath:db/migration
|
||||
databasir.db.driver-directory=drivers
|
||||
databasir.jwt.secret=${DATABASIR_JWT_SECRET:${random.uuid}}
|
||||
# api doc
|
||||
springdoc.api-docs.enabled=false
|
||||
springdoc.api-docs.enabled=false
|
||||
spring.mvc.async.request-timeout=3600000
|
Reference in New Issue
Block a user