refactor: 代码生成临时提交
This commit is contained in:
@@ -10,7 +10,6 @@ import com.youlai.system.model.vo.TablePageVO;
|
||||
import com.youlai.system.service.DatabaseService;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -22,9 +21,9 @@ import java.util.List;
|
||||
|
||||
@Tag(name = "09.代码生成")
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/databases")
|
||||
@RequestMapping("/api/v1/generator")
|
||||
@RequiredArgsConstructor
|
||||
public class DatabaseController {
|
||||
public class GeneratorController {
|
||||
|
||||
private final DatabaseService databaseService;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class DatabaseController {
|
||||
|
||||
|
||||
@Operation(summary = "获取预览生成代码")
|
||||
@GetMapping("/table/{tableName}/generate-preview")
|
||||
@GetMapping("/table/{tableName}/preview")
|
||||
public Result<List<TableGeneratePreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
||||
List<TableGeneratePreviewVO> list = databaseService.getTablePreviewData(tableName);
|
||||
return Result.success(list);
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.youlai.system.model.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "代码生成配置")
|
||||
@Data
|
||||
public class GeneratorConfig {
|
||||
|
||||
@Schema(description = "表名")
|
||||
private String tableName;
|
||||
|
||||
@Schema(description = "包名")
|
||||
private String packageName;
|
||||
|
||||
@Schema(description = "模块名")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "表前缀")
|
||||
private String tablePrefix;
|
||||
|
||||
@Schema(description = "是否覆盖")
|
||||
private Boolean cover;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.youlai.system.model.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "代码生成配置表单")
|
||||
@Data
|
||||
public class GeneratorConfigForm {
|
||||
|
||||
@Schema(description = "表名")
|
||||
private String tableName;
|
||||
|
||||
@Schema(description = "实体名")
|
||||
private String entityName;
|
||||
|
||||
@Schema(description = "包名")
|
||||
private String packageName;
|
||||
|
||||
@Schema(description = "模块名")
|
||||
private String moduleName;
|
||||
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "字段配置")
|
||||
private List<FieldConfig> fieldConfigs;
|
||||
|
||||
@Schema(description = "字段配置")
|
||||
@Data
|
||||
public static class FieldConfig {
|
||||
|
||||
@Schema(description = "字段名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字段类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "字段描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "是否在列表显示")
|
||||
private Boolean showInList;
|
||||
|
||||
@Schema(description = "是否在表单显示")
|
||||
private Boolean showInForm;
|
||||
|
||||
@Schema(description = "是否在查询条件显示")
|
||||
private Boolean showInQuery;
|
||||
|
||||
@Schema(description = "表单类型")
|
||||
private String formType;
|
||||
|
||||
@Schema(description = "查询方式")
|
||||
private String queryMethod;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.youlai.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.extra.template.Template;
|
||||
import cn.hutool.extra.template.TemplateConfig;
|
||||
import cn.hutool.extra.template.TemplateEngine;
|
||||
@@ -17,10 +17,7 @@ import org.springframework.stereotype.Service;
|
||||
import cn.hutool.extra.template.TemplateConfig.ResourceMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 数据库服务实现类
|
||||
@@ -67,13 +64,14 @@ public class DatabaseServiceImpl implements DatabaseService {
|
||||
|
||||
List<TableGeneratePreviewVO> list = new ArrayList<>();
|
||||
|
||||
TemplateConfig templateConfig = new TemplateConfig("templates" , ResourceMode.CLASSPATH);
|
||||
TemplateConfig templateConfig = new TemplateConfig("templates" , ResourceMode.CLASSPATH);
|
||||
TemplateEngine templateEngine = TemplateUtil.createEngine(templateConfig);
|
||||
|
||||
|
||||
Map<String, Object> bindingMap = new HashMap<>();
|
||||
bindingMap.put("tableName", "sys_user");
|
||||
bindingMap.put("author", "Ray");
|
||||
bindingMap.put("date", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||
bindingMap.put("entityName", "User" );
|
||||
bindingMap.put("lowerFirstEntityName", "user");
|
||||
bindingMap.put("tableComment", "用户");
|
||||
|
||||
Reference in New Issue
Block a user