refactor(generator): 重构代码生成功能,由指定路径生成模式调整为下载模式,更方便复杂场景

Closes #40
This commit is contained in:
2024-03-15 00:24:16 +08:00
parent ab97a08f48
commit df0c0dd7dc
9 changed files with 128 additions and 127 deletions

View File

@@ -21,6 +21,8 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -32,7 +34,6 @@ import top.charles7c.continew.admin.generator.model.resp.GeneratePreviewResp;
import top.charles7c.continew.admin.generator.model.resp.TableResp;
import top.charles7c.continew.admin.generator.service.GeneratorService;
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
import top.charles7c.continew.starter.extension.crud.model.query.PageQuery;
import top.charles7c.continew.starter.extension.crud.model.resp.PageResp;
import top.charles7c.continew.starter.web.model.R;
@@ -102,9 +103,7 @@ public class GeneratorController {
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@SaCheckPermission("tool:generator:list")
@PostMapping("/{tableName}")
public R<Void> generate(@PathVariable String tableName) {
ValidationUtils.throwIf(projectProperties.isProduction(), "仅支持在开发环境生成代码");
generatorService.generate(tableName);
return R.ok("生成成功,请查看生成代码是否正确");
public void generate(@PathVariable String tableName, HttpServletRequest request, HttpServletResponse response) {
generatorService.generate(tableName, request, response);
}
}

View File

@@ -8,7 +8,7 @@ generator:
- gen_field_config
## 类型映射
typeMappings:
MySQL:
MYSQL:
Integer:
- int
- tinyint

View File

@@ -277,7 +277,6 @@ CREATE TABLE IF NOT EXISTS `gen_config` (
`table_name` varchar(64) NOT NULL COMMENT '表名称',
`module_name` varchar(60) NOT NULL COMMENT '模块名称',
`package_name` varchar(60) NOT NULL COMMENT '包名称',
`frontend_path` varchar(255) DEFAULT NULL COMMENT '前端路径',
`business_name` varchar(50) NOT NULL COMMENT '业务名称',
`author` varchar(100) NOT NULL COMMENT '作者',
`table_prefix` varchar(20) DEFAULT NULL COMMENT '表前缀',

View File

@@ -462,7 +462,6 @@ CREATE TABLE IF NOT EXISTS "gen_config" (
"table_name" varchar(64) NOT NULL,
"module_name" varchar(60) NOT NULL,
"package_name" varchar(60) NOT NULL,
"frontend_path" varchar(255) DEFAULT NULL,
"business_name" varchar(50) NOT NULL,
"author" varchar(100) NOT NULL,
"table_prefix" varchar(20) DEFAULT NULL,
@@ -474,7 +473,6 @@ CREATE TABLE IF NOT EXISTS "gen_config" (
COMMENT ON COLUMN "gen_config"."table_name" IS '表名称';
COMMENT ON COLUMN "gen_config"."module_name" IS '模块名称';
COMMENT ON COLUMN "gen_config"."package_name" IS '包名称';
COMMENT ON COLUMN "gen_config"."frontend_path" IS '前端路径';
COMMENT ON COLUMN "gen_config"."business_name" IS '业务名称';
COMMENT ON COLUMN "gen_config"."author" IS '作者';
COMMENT ON COLUMN "gen_config"."table_prefix" IS '表前缀';