10 Commits

23 changed files with 343 additions and 754 deletions

View File

@@ -10,41 +10,42 @@
>powered by `Moshow郑锴(大狼狗)` , [https://zhengkai.blog.csdn.net](https://zhengkai.blog.csdn.net)
# Description
>The `Spring Boot Code Generator` , Based on SpringBoot3 and Freemarker<br>
> #基于`SpringBoot3``Freemarker`代码生成平台
>
>Release your hands from tedious and repetitive CRUD tasks.<br>
> #从繁琐重复的`CRUD工作`中释放你的双手
>
>Support mysql+oracle+pgsql , the most popular databases standard SQL<br>
> #支持`MySQL`、OraclePgSQL三大主流数据库
>
>Generate various templates through table creation DDL statements, Insert SQL statements, Select SQL statements(*New), and simple JSON.<br>
> 通过建表DDL语句、插入SQL语句、选择SQL语句(*新)以及简单JSON生成各种模板`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper`.
>
>Thank you all for your use and feedback. The daily PV visits of 1.5k in BeJSON and 2K Stars on GitHub are the greatest encouragement and motivation. <br>
> 感谢大家的使用与反馈BeJSON上每天1.5K的PV访问量👀和 Github上2K的✨Stars是最大的鼓励与动力
>
>May everyone maintain a work-life balance, stay healthy and safe. Wishing you all success in your work and continuous advancements!. <br>
> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利,步步高升
>
>Welcome to submit your issue and useful templates , or put your good idea into PR <br>
> 欢迎提交你的问题和常用有用模板或者提交你的好主意到PR。
> 🚀 `Spring Boot Code Generator` — a powerful code generation platform built on SpringBoot3 & Freemarker
> 基于 `SpringBoot3``Freemarker` 的高效代码生成平台
> 👐 Say goodbye to repetitive CRUD work — free your hands and boost productivity
> 💡 告别繁琐重复的 CRUD 操作,释放你的双手,让开发更高效!
> 🛠️ Supports MySQL, Oracle, and PostgreSQL — the most popular SQL dialects
> 📦 支持主流数据库:`MySQL`、`Oracle`、`PgSQL`,标准 SQL 一网打尽
> ⚙️ Generate templates from DDL, INSERT SQL, SELECT SQL, or simple JSON — covering JPA, JdbcTemplate, Mybatis, MybatisPlus, BeetlSQL, CommonMapper
> 🧩 通过建表 DDL、插入 SQL、选择 SQL简单 JSON,一键生成 `JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper` 等模板代码
> 🙏 Thanks for your continued support! BeJSON once peaked at 1.5K daily PV 👀, and now maintains a steady flow of around 600 visits — plus 2K+ GitHub Stars ✨. Your feedback remains our greatest motivation to keep improving!
> ❤️ 感谢大家一直以来的支持BeJSON 曾创下日均访问量 1.5K 👀 的高峰,目前稳定在约 600 左右,GitHub Star 数也已突破 2K ✨。你们的反馈始终是我们不断前进的最大动力
> 🌈 Wishing everyone balance, health, and success — may your code be bug-free and your coffee strong ☕
> 💬 祝大家工作顺利,生活平衡,身体健康,步步高升,代码无 bug咖啡够劲
> 📬 Feel free to submit issues, share useful templates, or contribute your brilliant ideas via PR
> 🤝 欢迎提交问题、分享常用模板,或将你的灵感通过 PR 实现!
> 🙌 Special thanks to BeJSON 前站长 `三叔` 的慧眼与支持,让项目得以脱颖而出,感恩!
# URL
- 感谢`卡卡`将他部署在[BEJSON](https://java.bejson.com/generator)上目前是BeJSON专供的`金牌工具`(线上版本不一定是最新的,会有延迟,请谅解,谢谢).<br>
- 感谢`卡卡`部署在[BEJSON](https://java.bejson.com/generator)上目前是BeJSON专供的`金牌工具`<br>
- 感谢`jully.top`部署的副本 [https://jully.top/generator/](https://jully.top/generator/)。<br>
- 感谢`BootCDN`提供稳定、快速、免费的前端开源项目 CDN 加速服务
- Thanks for `JetBrains` providing us the `Licenses for Open Source Development` [Get free access to all JetBrains tools for developing your open source project!](https://www.jetbrains.com/community/opensource/#support) .<br>
- 感谢`staticfile`CDN提供稳定、快速、免费的静态文件CDN加速服务(在线版本)
| 访问地址 | http://localhost:1234/generator |
|:-----------------------|:--------------------------------------------------------------|
| BEJSON 金牌工具 在线地址 | https://java.bejson.com/generator/ |
| JSON.CN 金牌工具 在线地址 | https://java.json.cn/generator/ |
| BEJSON 金牌工具 在线地址 | https://java.bejson.com/generator/ |
| JSON.CN 金牌工具 在线地址 | https://java.json.cn/generator/ |
| Jully 在线地址 | https://jully.top/generator/ |
| DEVTOOLS 在线地址Demised | https://java.devtools.cn |
| NeverWaive 在线地址 | https://codegenerator.neverwaive.cn/ |
| CSDN BLOG | https://zhengkai.blog.csdn.net |
| GITEE仓库 | https://gitee.com/moshowgame/SpringBootCodeGenerator/releases |
| GITHUB仓库 | https://github.com/moshowgame/SpringBootCodeGenerator |
@@ -65,16 +66,19 @@
# Branch Detail 分支介绍
- Master主力分支基于SpringBoot3+需要JDK17+
- JDK11兼容分支基于SpringBoot2+支持JDK8/JDK11/JDK17等版本请自行(切换jdk11分支)[https://github.com/moshowgame/SpringBootCodeGenerator/tree/jdk11]
- NewUI新UI界面改版尝鲜
- JDK11兼容分支版本落后,基于SpringBoot2+支持JDK8/JDK11等旧JDK版本[https://github.com/moshowgame/SpringBootCodeGenerator/tree/jdk11]
# 更新预告
1.计划优化一下前端界面,改善由于静态资源加载问题导致的访问缓慢问题,目前正在开发中
2.根据大家Raised的Issue优化一下模板
1.计划加入AI来帮忙生成更多样式的模板
2.改进JSqlParser Engine (Select SQL and Create SQL)
# Update Logs
| 更新日期 | 更新内容 |
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 2025.09.14 | 优化JSqlParser Engine(DDL Create SQL和Select SQL),适配更高级复杂的SQL |
| 2025.09.13 | JSqlParser Engine全新升级目前Select SQL模式相对稳定! <br>更新SpringBoot等类库版本修复漏洞<br>修复CDN问题切换为staticfile.org |
| 2025.09.06 | 处理建表字段包含 using 字符时无法生成对应字段的情况(感谢@wubiaoo的反馈和@willxiang的PR) |
| 2025.03.31 | 优化说明 |
| 2025.03.16 | NewUI V2前端优化<br>移除不必要内容优化Local和CDN静态文件引入。<br><br>修复由于SQL类型大写导致无法转换的问题。感谢@zzy-design的反馈<br><br>JPA模板优化感谢@PenroseYang的反馈<br>修复不开启Lombok情况下Set/Get方法生成问题;<br>修复importDdate判断为true后没有引入日期类的问题<br> |
| 2024.12.29 | 优化前端加载速度优化输出代码着色CDN改字节跳动静态资源公共库。<br> |
| 2024.12.23 | 新增InsertSQL模式采用JSQLParser引擎进行封装<br>优化代码封装<br>CDN恢复为staticfile.org加速(如果本地卡的话建议切换local模式)。<br> |
@@ -189,6 +193,9 @@
- [CSDN【SpringBoot2启示录】专栏](https://blog.csdn.net/moshowgame/category_9274885.html)
## Stargazers over time
[![Stargazers over time](https://starchart.cc/moshowgame/SpringBootCodeGenerator.svg?variant=adaptive)](https://starchart.cc/moshowgame/SpringBootCodeGenerator)
2025 NewUI V2版本
<img src="./newui_version_2.png">
配置模板

View File

@@ -32,16 +32,16 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/statics/**").addResourceLocations("classpath:/statics/");
}
@Bean
public FilterRegistrationBean xssFilterRegistration() {
FilterRegistrationBean registration = new FilterRegistrationBean();
registration.setDispatcherTypes(DispatcherType.REQUEST);
registration.setFilter(new XssFilter());
registration.addUrlPatterns("/*");
registration.setName("xssFilter");
registration.setOrder(Integer.MAX_VALUE);
return registration;
}
// @Bean
// public FilterRegistrationBean xssFilterRegistration() {
// FilterRegistrationBean registration = new FilterRegistrationBean();
// registration.setDispatcherTypes(DispatcherType.REQUEST);
// registration.setFilter(new XssFilter());
// registration.addUrlPatterns("/*");
// registration.setName("xssFilter");
// registration.setOrder(Integer.MAX_VALUE);
// return registration;
// }
// @Override
// public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
@@ -74,8 +74,20 @@ public class WebMvcConfig implements WebMvcConfigurer {
//自定义配置...
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setReaderFeatures(JSONReader.Feature.FieldBased, JSONReader.Feature.SupportArrayToBean);
config.setWriterFeatures(JSONWriter.Feature.WriteMapNullValue, JSONWriter.Feature.PrettyFormat);
// 添加更多解析特性以提高容错性
config.setReaderFeatures(
JSONReader.Feature.FieldBased,
JSONReader.Feature.SupportArrayToBean,
// JSONReader.Feature.IgnoreNoneFieldGetter,
JSONReader.Feature.InitStringFieldAsEmpty
);
config.setWriterFeatures(
JSONWriter.Feature.WriteMapNullValue,
JSONWriter.Feature.PrettyFormat
);
converter.setFastJsonConfig(config);
converter.setDefaultCharset(StandardCharsets.UTF_8);
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));

View File

@@ -1,31 +0,0 @@
package com.softdev.system.generator.config;
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* XSS过滤
*
* @author Mark sunlightcs@gmail.com
*/
public class XssFilter implements Filter {
@Override
public void init(FilterConfig config) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest)request);
chain.doFilter(xssRequest, response);
}
@Override
public void destroy() {
}
}

View File

@@ -1,142 +0,0 @@
package com.softdev.system.generator.config;
import jakarta.servlet.ReadListener;
import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* XSS过滤处理
*
* @author Mark sunlightcs@gmail.com
*/
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
/**
* 没被包装过的HttpServletRequest特殊场景需要自己过滤
*/
HttpServletRequest orgRequest;
/**
* html过滤
*/
private final static HTMLFilter htmlFilter = new HTMLFilter();
public XssHttpServletRequestWrapper(HttpServletRequest request) {
super(request);
orgRequest = request;
}
@Override
public ServletInputStream getInputStream() throws IOException {
//非json类型直接返回
if(!MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(super.getHeader(HttpHeaders.CONTENT_TYPE))){
return super.getInputStream();
}
//为空,直接返回
String json = IOUtils.toString(super.getInputStream(), "utf-8");
if (StringUtils.isBlank(json)) {
return super.getInputStream();
}
//xss过滤
json = xssEncode(json);
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
return new ServletInputStream() {
@Override
public boolean isFinished() {
return true;
}
@Override
public boolean isReady() {
return true;
}
@Override
public void setReadListener(ReadListener readListener) {
}
@Override
public int read() throws IOException {
return bis.read();
}
};
}
@Override
public String getParameter(String name) {
String value = super.getParameter(xssEncode(name));
if (StringUtils.isNotBlank(value)) {
value = xssEncode(value);
}
return value;
}
@Override
public String[] getParameterValues(String name) {
String[] parameters = super.getParameterValues(name);
if (parameters == null || parameters.length == 0) {
return null;
}
for (int i = 0; i < parameters.length; i++) {
parameters[i] = xssEncode(parameters[i]);
}
return parameters;
}
@Override
public Map<String,String[]> getParameterMap() {
Map<String,String[]> map = new LinkedHashMap<>();
Map<String,String[]> parameters = super.getParameterMap();
for (String key : parameters.keySet()) {
String[] values = parameters.get(key);
for (int i = 0; i < values.length; i++) {
values[i] = xssEncode(values[i]);
}
map.put(key, values);
}
return map;
}
@Override
public String getHeader(String name) {
String value = super.getHeader(xssEncode(name));
if (StringUtils.isNotBlank(value)) {
value = xssEncode(value);
}
return value;
}
private String xssEncode(String input) {
return htmlFilter.filter(input);
}
/**
* 获取最原始的request
*/
public HttpServletRequest getOrgRequest() {
return orgRequest;
}
/**
* 获取最原始的request
*/
public static HttpServletRequest getOrgRequest(HttpServletRequest request) {
if (request instanceof XssHttpServletRequestWrapper) {
return ((XssHttpServletRequestWrapper) request).getOrgRequest();
}
return request;
}
}

View File

@@ -41,14 +41,6 @@ public class GeneratorController {
public ModelAndView indexPage() {
return new ModelAndView("newui2").addObject("value",valueUtil);
}
@GetMapping("/newui2")
public ModelAndView newui2() {
return new ModelAndView("newui2").addObject("value",valueUtil);
}
@GetMapping("/main")
public ModelAndView mainPage() {
return new ModelAndView("main").addObject("value",valueUtil);
}
@RequestMapping("/template/all")
@ResponseBody
@@ -87,6 +79,10 @@ public class GeneratorController {
//SelectSqlBySQLPraser模式:parse select sql by JSqlParser
classInfo = generatorService.generateSelectSqlBySQLPraser(paramInfo);
break;
case "create-sql":
//CreateSqlBySQLPraser模式:parse create sql by JSqlParser
classInfo = generatorService.generateCreateSqlBySQLPraser(paramInfo);
break;
default:
//默认模式parse DDL table structure from sql
classInfo = generatorService.processTableIntoClassInfo(paramInfo);

View File

@@ -25,6 +25,7 @@ public interface GeneratorService {
* @return
*/
ClassInfo generateSelectSqlBySQLPraser(ParamInfo paramInfo) throws Exception;
ClassInfo generateCreateSqlBySQLPraser(ParamInfo paramInfo) throws Exception;
/**
* 解析DDL-SQL生成类信息
* @auther: zhengkai.blog.csdn.net

View File

@@ -7,23 +7,29 @@ import com.softdev.system.generator.entity.*;
import com.softdev.system.generator.util.*;
import freemarker.template.TemplateException;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.parser.CCJSqlParserManager;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.create.table.ColumnDefinition;
import net.sf.jsqlparser.statement.create.table.CreateTable;
import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select;
import net.sf.jsqlparser.statement.select.SelectItem;
import net.sf.jsqlparser.util.TablesNamesFinder;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static net.sf.jsqlparser.parser.feature.Feature.createTable;
/**
* GeneratorService
*
@@ -81,14 +87,39 @@ public class GeneratorServiceImpl implements GeneratorService {
@Override
public ClassInfo generateSelectSqlBySQLPraser(ParamInfo paramInfo) throws Exception {
ClassInfo classInfo = new ClassInfo();
PlainSelect select = (PlainSelect) CCJSqlParserUtil.parse(paramInfo.getTableSql());
List<SelectItem<?>> columnNameList = select.getSelectItems();
log.info("tableName:{}", select.getFromItem().toString());
String processedSql = paramInfo.getTableSql().trim()
.replaceAll("'", "`") // 将单引号替换为反引号
.replaceAll("\"", "`") // 将双引号替换为反引号
.replaceAll("", ","); // 将中文逗号替换为英文逗号
Statement statement = null;
CCJSqlParserManager parserManager = new CCJSqlParserManager();
statement = parserManager.parse(new StringReader(processedSql));
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder(); // 创建表名发现者对象
List<String> tableNameList = tablesNamesFinder.getTableList(statement); // 获取到表名列表
//一般这里应该只解析到一个表名,除非多个表名,取第一个
if (!CollectionUtils.isEmpty(tableNameList)) {
String tableName = tableNameList.get(0).trim();
classInfo.setTableName(tableName);
classInfo.setOriginTableName(tableName);
String className = StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName)).replaceAll("`", "");
if (className.contains("_")) {
className = className.replaceAll("_", "");
}
classInfo.setClassName(className);
classInfo.setClassComment(paramInfo.getTableSql());
}
//解析查询元素
Select select = null;
select = (Select) CCJSqlParserUtil.parse(paramInfo.getTableSql());
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
List<SelectItem<?>> selectItems = plainSelect.getSelectItems();
// field List
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
columnNameList.forEach(t->{
selectItems.forEach(t->{
FieldInfo fieldInfo = new FieldInfo();
String fieldName = ((Column)t.getExpression()).getColumnName();
String fieldName = ((Column)t.getExpression()).getColumnName().replaceAll("`", "");
String aliasName = t.getAlias() != null ? t.getAlias().getName() : ((Column)t.getExpression()).getColumnName();
//存储原始字段名
fieldInfo.setFieldComment(aliasName);fieldInfo.setColumnName(aliasName);
@@ -96,21 +127,15 @@ public class GeneratorServiceImpl implements GeneratorService {
fieldName=fieldName.contains(".")?fieldName.substring(fieldName.indexOf(".")+1):fieldName;
//转换前
fieldInfo.setColumnName(fieldName);
switch ((String) paramInfo.getOptions().get("nameCaseType")) {
case ParamInfo.NAME_CASE_TYPE.CAMEL_CASE:
fieldName = switch ((String) paramInfo.getOptions().get("nameCaseType")) {
case ParamInfo.NAME_CASE_TYPE.CAMEL_CASE ->
// 2024-1-27 L&J 适配任意(maybe)原始风格转小写驼峰
fieldName = StringUtilsPlus.toLowerCamel(aliasName);
break;
case ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE:
fieldName = StringUtilsPlus.toUnderline(aliasName, false);
break;
case ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE:
fieldName = StringUtilsPlus.toUnderline(aliasName.toUpperCase(), true);
break;
default:
fieldName = aliasName;
break;
}
StringUtilsPlus.toLowerCamel(aliasName);
case ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE -> StringUtilsPlus.toUnderline(aliasName, false);
case ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE ->
StringUtilsPlus.toUnderline(aliasName.toUpperCase(), true);
default -> aliasName;
};
//转换后
fieldInfo.setFieldName(fieldName);
@@ -119,18 +144,80 @@ public class GeneratorServiceImpl implements GeneratorService {
fieldList.add(fieldInfo);
});
classInfo.setFieldList(fieldList);
String tableName = select.getFromItem().toString();
classInfo.setTableName(tableName);
//如果表名有空格,取空格前的第一个单词作为类名
if(tableName.indexOf(" ")>0){
classInfo.setClassName(StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName.substring(0,tableName.indexOf(" ")))));
}else{
classInfo.setClassName(StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName)));
}
log.info("classInfo:{}", JSON.toJSONString(classInfo));
return classInfo;
}
/**
* 根据SQL解析器解析表结构
* @author zhengkai.blog.csdn.net
* @param paramInfo
* @return
* @throws Exception
*/
@Override
public ClassInfo generateCreateSqlBySQLPraser(ParamInfo paramInfo) throws Exception {
ClassInfo classInfo = new ClassInfo();
Statement statement = null;
// 对SQL进行预处理以提高解析成功率
String processedSql = paramInfo.getTableSql().trim()
.replaceAll("'", "`") // 将单引号替换为反引号
.replaceAll("\"", "`") // 将双引号替换为反引号
.replaceAll("", ","); // 将中文逗号替换为英文逗号
try {
statement = CCJSqlParserUtil.parse(processedSql);
}catch (Exception e) {
e.printStackTrace();
throw new SqlException("SQL语法错误:"+e.getMessage());
}
// 确保是CREATE TABLE语句
if (!(statement instanceof CreateTable createTable)) {
throw new SqlException("检测到SQL语句不是DLL CREATE TABLE语句");
}
// 提取表名
String tableName = createTable.getTable().getName().replaceAll("`", "");
classInfo.setTableName(tableName);
String className = StringUtilsPlus.upperCaseFirst(StringUtilsPlus.underlineToCamelCase(tableName));
if (className.contains("_")) {
className = className.replaceAll("_", "");
}
classInfo.setClassName(className);
classInfo.setOriginTableName(tableName);
classInfo.setClassComment(paramInfo.getTableSql());
// 提取字段信息
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
List<ColumnDefinition> columnDefinitions = createTable.getColumnDefinitions();
if (columnDefinitions != null) {
for (ColumnDefinition columnDefinition : columnDefinitions) {
FieldInfo fieldInfo = new FieldInfo();
String columnName = columnDefinition.getColumnName().replaceAll("`", "");
fieldInfo.setColumnName(columnName);
fieldInfo.setFieldComment(columnDefinition.toString());
// 根据命名规则转换字段名
String fieldName = switch ((String) paramInfo.getOptions().get("nameCaseType")) {
case ParamInfo.NAME_CASE_TYPE.CAMEL_CASE -> StringUtilsPlus.toLowerCamel(columnName);
case ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE -> StringUtilsPlus.toUnderline(columnName, false);
case ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE ->
StringUtilsPlus.toUnderline(columnName.toUpperCase(), true);
default -> columnName;
};
fieldInfo.setFieldName(fieldName);
// 设置字段类型为String因为无法准确推测类型
fieldInfo.setFieldClass("String");
fieldList.add(fieldInfo);
}
}
classInfo.setFieldList(fieldList);
log.info("classInfo:{}", JSON.toJSONString(classInfo));
return classInfo;
}
/**
* 解析DDL SQL生成类信息(默认模式|核心模式)
*

View File

@@ -0,0 +1,35 @@
package com.softdev.system.generator.util;
import java.io.Serial;
/**
* @author xuxueli 2018-05-02 21:10:28
*/
public class SqlException extends RuntimeException {
@Serial
private static final long serialVersionUID = 42L;
public SqlException() {
super();
}
public SqlException(String msg) {
super(msg);
}
public SqlException(String msg, Throwable cause) {
super(msg, cause);
}
public SqlException(Throwable cause) {
super(cause);
}
public SqlException(String message, Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@@ -49,15 +49,15 @@ spring:
#mvc:
# static-path-pattern: /statics/**
OEM:
version: 2025 March
version: 2025 September
header: SQL转Java JPA、MYBATIS实现类代码生成平台
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
title: JAVA在线代码生成
slogan: Release your hands from tedious and repetitive CRUD tasks.
description: <p>SpringBootCodeGenerator又名`大狼狗代码生成器`、`SQL转JAVA`、`SQL转JPA`、`SQL转Mybatis`、`Mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`。</p><p>——从繁琐重复的`CRUD工作`中释放你的双手可通过DDL SQL语句或Select SQL语句或简单Json -> 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper等相关模板代码。</p>
slogan: 👐 Free your hands from boring CRUD—let the code write itself! ⚡
description: <p>💻 SpringBootCodeGenerator又名 `大狼狗代码生成器`🐺🐶,支持 SQL 一键转 JAVA/JPA/Mybatis/MybatisPlus 等多种模板,轻松搞定 CRUD彻底解放双手 ✋!只需提供 DDL、SELECT SQL 或简单 JSON 👉 即可生成 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper 等代码模板。</p><p>🔥🔥🔥 全新 JSqlParser 引擎上线,强力支持 DDL CREATE SQL与 SELECT SQL 解析!欢迎体验 & 反馈 💬!</p><p>👨‍💻 面向开发者的高效利器,已服务数万工程师,欢迎 Star ⭐、Fork 🍴、提 Issue 💬,一起打造更强大的代码生成平台!</p>
author: BEJSON.com
packageName: www.bejson.com
copyright: Powered by <a href="https://zhengkai.blog.csdn.net" target="_blank">Moshow郑锴</a> , Might the holy light be with you !
copyright: Powered by <a href="https://zhengkai.blog.csdn.net" target="_blank">Moshow郑锴</a><a href="https://www.bejson.com/">BeJSON</a> — may the holy light guide your code, your coffee, and your commits! ⚡🧙‍♂️💻
returnUtilSuccess: ResponseUtil.success
returnUtilFailure: ResponseUtil.error
outputStr: www.bejson.com

View File

@@ -47,16 +47,16 @@ spring:
#mvc:
# static-path-pattern: /statics/**
OEM:
version: 2025 March
version: 2025 September
header: SQL转Java JPA、MYBATIS实现类代码生成平台
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
title: JAVA代码生成平台
slogan: Release your hands from tedious and repetitive CRUD tasks.
description: <p>SpringBootCodeGenerator又名`大狼狗代码生成器`、`SQL转JAVA`、`SQL转JPA`、`SQL转Mybatis`、`Mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`。</p><p>——从繁琐重复的`CRUD工作`中释放你的双手可通过DDL SQL语句或Select SQL语句或简单Json -> 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper等相关模板代码。</p>
title: 大狼狗代码生成
slogan: 👐 Free your hands from boring CRUD—let the code write itself! ⚡
description: <p>💻 SpringBootCodeGenerator又名 `大狼狗代码生成器`🐺🐶,支持 SQL 一键转 JAVA/JPA/Mybatis/MybatisPlus 等多种模板,轻松搞定 CRUD彻底解放双手 ✋!只需提供 DDL、SELECT SQL 或简单 JSON 👉 即可生成 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper 等代码模板。</p><p>🔥🔥🔥 全新 JSqlParser 引擎上线,强力支持 DDL CREATE SQL与 SELECT SQL 解析!欢迎体验 & 反馈 💬!</p><p>👨‍💻 面向开发者的高效利器,已服务数万工程师,欢迎 Star ⭐、Fork 🍴、提 Issue 💬,一起打造更强大的代码生成平台!</p>
author: zhengkai.blog.csdn.net
packageName: com.software.system
copyright: Powered by <a href="https://zhengkai.blog.csdn.net" target="_blank">Moshow郑锴</a> , Might the holy light be with you !
copyright: Powered by <a href="https://zhengkai.blog.csdn.net" target="_blank">Moshow郑锴</a> — may the holy light guide your code, your coffee, and your commits! ⚡🧙‍♂️💻
returnUtilSuccess: ResponseUtil.success
returnUtilFailure: ResponseUtil.error
outputStr: http://zhengkai.blog.csdn.net
mode: CDN
mode: local

View File

@@ -0,0 +1,64 @@
server:
port: 1235
http2:
enabled: true
servlet:
context-path: /generator
#tomcat:
# remote-ip-header: x-forward-for
# uri-encoding: UTF-8
# max-threads: 10
# background-processor-delay: 30
# basedir: ${user.home}/tomcat/
undertow:
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
# 不要设置过大,如果过大,启动项目会报错:打开文件数过多
io-threads: 4
# 阻塞任务线程池, 当执行类似servlet请求阻塞IO操作, undertow会从这个线程池中取得线程
# 它的值设置取决于系统线程执行任务的阻塞系数默认值是IO线程数*8
worker-threads: 64
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
# 每块buffer的空间大小,越小的空间被利用越充分,不要设置太大,以免影响其他应用,合适即可
buffer-size: 1024
# 是否分配的直接内存(NIO直接分配的堆外内存)
direct-buffers: true
spring:
banner:
charset: UTF-8
web:
encoding:
force: true
charset: UTF-8
application:
name: spring-boot-code-generator
freemarker:
request-context-attribute: request
suffix: .html
content-type: text/html
enabled: true
cache: false
charset: UTF-8
allow-request-override: false
expose-request-attributes: true
expose-session-attributes: true
expose-spring-macro-helpers: true
settings:
number_format: 0.##
default_encoding: UTF-8
#template_loader: /templates/
#mvc:
# static-path-pattern: /statics/**
OEM:
version: 2025 September
header: SQL转Java JPA、MYBATIS实现类代码生成平台
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
title: JAVA在线代码生成
slogan: 👐 Free your hands from boring CRUD—let the code write itself! ⚡
description: <p>💻 SpringBootCodeGenerator又名 `大狼狗代码生成器`🐺🐶,支持 SQL 一键转 JAVA/JPA/Mybatis/MybatisPlus 等多种模板,轻松搞定 CRUD彻底解放双手 ✋!只需提供 DDL、SELECT SQL 或简单 JSON 👉 即可生成 生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper 等代码模板。</p><p>🔥🔥🔥 全新 JSqlParser 引擎上线,强力支持 DDL CREATE SQL与 SELECT SQL 解析!欢迎体验 & 反馈 💬!</p><p>👨‍💻 面向开发者的高效利器,已服务数万工程师,欢迎 Star ⭐、Fork 🍴、提 Issue 💬,一起打造更强大的代码生成平台!</p>
author: https://www.json.cn/
packageName: www.json.cn
copyright: ✨ Powered by <a href="https://zhengkai.blog.csdn.net" target="_blank">Moshow郑锴</a><a href="https://www.json.cn/">JSON</a> — may the holy light guide your code, your coffee, and your commits! ⚡🧙‍♂️💻
returnUtilSuccess: ResponseUtil.success
returnUtilFailure: ResponseUtil.error
outputStr: www.json.cn
mode: local

View File

@@ -123,8 +123,9 @@ const vm = new Vue({
//get value from codemirror
vm.formData.tableSql=$.inputArea.getValue();
axios.post(basePath+"/code/generate",vm.formData).then(function(res){
if(res.code===500){
error("生成失败请检查SQL语句!!!");
if(res.status===500||res.data.code===500){
console.log(res);
error("生成失败请检查SQL语句!!!"+res.data.msg);
return;
}
setAllCookie();

View File

@@ -1,30 +0,0 @@
<!--###################################################-->
<!--### CDN version : by https://cdn.bytedance.com/ -->
<!--###################################################-->
<!--jquery | vue | element-ui | axios-->
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js"></script>
<script src="//lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/axios/0.26.0/axios.min.js"></script>
<script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/index.min.js"></script>
<link href="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/theme-chalk/index.min.css" type="text/css" rel="stylesheet" />
<!-- bootstrap -->
<script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap/5.1.3/js/bootstrap.bundle.min.js" type="application/javascript"></script>
<link href="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap/5.1.3/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<!-- 引入 Bootstrap Icons CSS -->
<link href="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/bootstrap-icons/1.8.1/font/bootstrap-icons.min.css" type="text/css" rel="stylesheet" />
<!--common.js-->
<script src="${request.contextPath}/statics/js/common.js"></script>
<!-- <link rel="stylesheet" href="${request.contextPath}/statics/css/main.css"> -->
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/toastr.js/2.1.4/toastr.min.js"></script>
<!-- Toastr CSS -->
<link href="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/toastr.js/2.1.4/toastr.min.css" rtype="text/css" rel="stylesheet" >
<!-- import codemirror -->
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/codemirror.min.js"></script>
<script src="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/mode/sql/sql.min.js"></script>
<link href="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/codemirror.min.css" type="text/css" rel="stylesheet" >
<link href="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/theme/idea.min.css" type="text/css" rel="stylesheet" >

View File

@@ -1,31 +0,0 @@
<!--###################################################-->
<!--### CDN version -->
<!--###################################################-->
<!--jquery | vue | element-ui | axios-->
<script src="${request.contextPath}/statics/libs/jquery/jquery.min.js"></script>
<script src="${request.contextPath}/statics/libs/vue/vue.min.js"></script>
<script src="${request.contextPath}/statics/libs/axios/axios.min.js"></script>
<script src="${request.contextPath}/statics/libs/element-ui/index.min.js"></script>
<link href="${request.contextPath}/statics/libs/element-ui/index.min.css" type="text/css" rel="stylesheet" />
<!-- bootstrap -->
<script src="${request.contextPath}/statics/libs/bootstrap/bootstrap.bundle.min.js" type="application/javascript"></script>
<link href="${request.contextPath}/statics/libs/bootstrap/bootstrap.min.css" type="text/css" rel="stylesheet" />
<!-- 引入 Bootstrap Icons CSS -->
<link href="${request.contextPath}/statics/libs/bootstrap-icons/bootstrap-icons.min.css" type="text/css" rel="stylesheet" />
<!--common.js-->
<script src="${request.contextPath}/statics/js/common.js"></script>
<!-- <link rel="stylesheet" href="${request.contextPath}/statics/css/main.css"> -->
<script src="${request.contextPath}/statics/libs/toastr.js/toastr.min.js"></script>
<!-- Toastr CSS -->
<link href="${request.contextPath}/statics/libs/toastr.js/toastr.min.css" rtype="text/css" rel="stylesheet" >
<!-- import codemirror -->
<script src="${request.contextPath}/statics/libs/codemirror/codemirror.min.js"></script>
<link href="${request.contextPath}/statics/libs/codemirror/codemirror.min.css" type="text/css" rel="stylesheet" >
<script src="${request.contextPath}/statics/libs/codemirror/mode/clike/clike.min.js"></script>
<script src="${request.contextPath}/statics/libs/codemirror/mode/sql/sql.min.js"></script>
<link href="${request.contextPath}/statics/libs/codemirror/theme/idea.min.css" type="text/css" rel="stylesheet" >

View File

@@ -1,26 +0,0 @@
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>${(value.title)!!}</title>
<meta name="keywords" content="${(value.keywords)!!}">
<script>
/*统计代码,便于统计流量,请勿移除,谢谢!*/
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?97fd5ca1a4298ac8349c7e0de9029a0f";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
//set base path for fixing the revertProxy forwarding path issue
var basePath = "${request.contextPath}";
console.log("basePath",basePath)
</script>
<#if value.mode=='local'>
<#include "/header-local-v2.html">
<#else>
<#include "/header-CDN-v2.html">
</#if>

View File

@@ -1,124 +0,0 @@
<!DOCTYPE html>
<!--
by https://zhengkai.blog.csdn.net
-->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<#include "/header.html">
<title>${(value.title)!!}</title>
</head>
<body class="hold-transition layout-top-nav">
<div class="wrapper">
<!-- 导航栏 -->
<nav class="main-header navbar navbar-expand-md navbar-light navbar-white">
<div class="container">
<a href="#" class="navbar-brand">
<img src="${request.contextPath}/statics/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">
<span class="brand-text font-weight-light">${(value.title)!!}</span>
</a>
<button class="navbar-toggler order-1" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse order-3" id="navbarCollapse">
<i class="fa fa-fw fa-space-shuttle"></i><a>${(value.slogan)!!}</a>
</div>
<!-- 右侧导航栏链接 -->
<ul class="order-1 order-md-4 navbar-nav navbar-no-expand ml-auto">
<li class="nav-item">
<a href="https://github.com/moshowgame/SpringBootCodeGenerator/issues" target="_blank"><i class="fa fa-fw fa-share-square"></i>Raise Issue</a>
<a href="https://github.com/moshowgame/SpringBootCodeGenerator" target="_blank"><i class="fa fa-fw fa-star"></i>Github </a>
</li>
</ul>
</div>
</nav>
<!-- /.navbar -->
<!-- Content Wrapper. 包含页面内容 -->
<div class="content-wrapper">
<!-- 主体内容 -->
<div class="content">
<div class="container">
<div class="row">
<!-- /.col-md-6 -->
<div class="col-lg-12">
<blockquote class="quote-secondary">
${(value.description)!!}
</blockquote>
<!-- <div class="card">
<div class="card-header">
<h5 class="card-title m-0">输入SQL</h5>
</div>
<div class="card-body">
<textarea id="inputArea" placeholder="请输入表结构信息..." style="height: 250px;line-height : 10px;" v-model="formData.tableSql"></textarea>
</div>
</div>
<div class="card">
<div class="card-header">
<h5 class="card-title m-0">生成设置</h5>
</div>
<div class="card-body">
<h6 class="card-title">特殊标题处理</h6>
<p class="card-text">支持引入其他额外内容。</p>
</div>
</div>
<div class="card">
<div class="card-header">
<h5 class="card-title m-0">输出代码</h5>
</div>
<div class="card-body">
<textarea id="outputArea" placeholder="请输入表结构信息..." style="height: 250px;" v-model="outputStr"></textarea>
</div>
</div> -->
<#include "/main-v2.html">
</div>
<!-- /.col-md-6 -->
</div>
<!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- 控制侧边栏内容在这里 -->
</aside>
<!-- /.control-sidebar -->
<!-- Main Footer -->
<footer class="main-footer">
<!-- To the right -->
<div class="float-right d-none d-sm-inline">
Version ${(value.version)!!}
</div>
<!-- Default to the left -->
<strong>${(value.copyright)!!} <a href="https://zhengkai.blog.csdn.net" target="_blank"><i class="fa fa-fw fa-thumbs-up"></i>zhengkai.blog.csdn.net</a> <a href="https://github.com/moshowgame/SpringBootCodeGenerator/blob/master/donate.png?raw=true" target="_blank"><i class="fa fa-fw fa-credit-card"></i>打赏</a>
</footer>
</div>
<!-- ./wrapper -->
</body>
</html>

View File

@@ -1,234 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<#include "/header.html">
<style>
/* .el-form-item__content{
line-height : 10px;
} */
/*.el-form-item--mini .el-form-item__content, .el-form-item--mini .el-form-item__label{
line-height : 10px;
}*/
/* .el-button-group-top {
padding-top: 5px;
} */
.el-button--primary.is-plain.is-disabled, .el-button--primary.is-plain.is-disabled:active, .el-button--primary.is-plain.is-disabled:focus, .el-button--primary.is-plain.is-disabled:hover {
color: #f9faff;
background-color: #91979d;
border-color: #d9ecff;
font-weight: bold;
}
</style>
</head>
<body>
<div id="rrapp" v-cloak>
<div>
<el-form ref="form" :inline="true" :model="formData" label-width="100px">
<div class="card">
<div class="card-header">
<h5 class="card-title m-0">输入SQL</h5>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="折叠">
<i class="fas fa-minus"></i>
</button>
<!-- <button type="button" class="btn btn-tool" data-card-widget="remove" title="移除">
<i class="fas fa-times"></i>
</button> -->
</div>
</div>
<div class="card-body">
<!-- <textarea id="inputArea" placeholder="请输入表结构信息..." style="height: 250px;line-height : 10px;" v-model="formData.tableSql"></textarea> -->
<!-- input area-->
<textarea id="inputArea" placeholder="请输入表结构信息..." style="height: 250px;line-height : 10px;" v-model="formData.tableSql"></textarea>
</div>
</div>
<hr>
<div class="card">
<div class="card-header">
<h5 class="card-title m-0">生成设置</h5>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="折叠">
<i class="fas fa-minus"></i>
</button>
<!-- <button type="button" class="btn btn-tool" data-card-widget="remove" title="移除">
<i class="fas fa-times"></i>
</button> -->
</div>
</div>
<div class="card-body">
<!-- setting area-->
<el-form-item label="作者">
<el-input v-model="formData.options.authorName"></el-input>
</el-form-item>
<el-form-item label="包名">
<el-input v-model="formData.options.packageName"></el-input>
</el-form-item>
<el-form-item label="返回(成功)">
<el-input v-model="formData.options.returnUtilSuccess"></el-input>
</el-form-item>
<el-form-item label="返回(失败)">
<el-input v-model="formData.options.returnUtilFailure"></el-input>
</el-form-item>
<el-form-item label="忽略前缀">
<el-input v-model="formData.options.ignorePrefix"></el-input>
</el-form-item>
<el-form-item label="输入类型">
<el-select v-model="formData.options.dataType" >
<el-option label="DDL SQL" value="sql"></el-option>
<el-option label="JSON" value="json"></el-option>
<el-option label="INSERT SQL" value="insert-sql">
<el-option label="SELECT SQL by SQL Parser" value="select-sql">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="TinyInt转换">
<el-select v-model="formData.options.tinyintTransType">
<el-option value="boolean" label="boolean"></el-option>
<el-option value="Boolean" label="Boolean"></el-option>
<el-option value="Integer" label="Integer"></el-option>
<el-option value="int" label="int"></el-option>
<el-option value="String" label="String"></el-option>
<el-option value="Short" label="Short"></el-option>
</el-select>
</el-form-item>
<el-form-item label="时间类型">
<el-select v-model="formData.options.timeTransType">
<el-option value="Date" label="Date"></el-option>
<el-option value="DateTime" label="DateTime"></el-option>
<el-option value="Time" label="Time"></el-option>
<el-option value="Timestamp" label="Timestamp"></el-option>
<el-option value="Calendar" label="Calendar"></el-option>
<el-option value="LocalDate" label="LocalDate"></el-option>
<el-option value="LocalDateTime" label="LocalDateTime"></el-option>
<el-option value="LocalTime" label="LocalTime"></el-option>
</el-select>
</el-form-item>
<el-form-item label="命名类型">
<el-select v-model="formData.options.nameCaseType">
<el-option label="驼峰" value="CamelCase"></el-option>
<el-option label="下划线" value="UnderScoreCase"></el-option>
</el-select>
</el-form-item>
<el-form-item label="包装类型">
<el-switch v-model="formData.options.isPackageType"></el-switch>
</el-form-item>
<el-form-item label="swaggerUI">
<el-switch v-model="formData.options.isSwagger"></el-switch>
</el-form-item>
<el-form-item label="字段注释">
<el-switch v-model="formData.options.isComment"></el-switch>
</el-form-item>
<el-form-item label="自动引包">
<el-switch v-model="formData.options.isAutoImport"></el-switch>
</el-form-item>
<el-form-item label="带包路径">
<el-switch v-model="formData.options.isWithPackage"></el-switch>
</el-form-item>
<el-form-item label="Lombok">
<el-switch v-model="formData.options.isLombok"></el-switch>
</el-form-item>
</div>
</div>
<hr>
<div class="card">
<div class="card-header">
<!-- <h5 class="card-title m-0">输出代码</h5> -->
<el-button type="primary" icon="el-icon-caret-right" @click="generate">生成</el-button>
<el-button type="primary" icon="el-icon-document-copy" @click="copy" plain>复制</el-button>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="折叠">
<i class="fas fa-minus"></i>
</button>
<!-- <button type="button" class="btn btn-tool" data-card-widget="remove" title="移除">
<i class="fas fa-times"></i>
</button> -->
</div>
</div>
<div class="card-body">
<!--generate button-->
<span v-if="historicalData.length>0" >
<el-button-group>
<el-button type="primary" plain disabled round>历史记录</el-button>
<span v-for="(item, index) in historicalData" :key="index">
<el-button @click="switchHistoricalData" >{{item}}</el-button>
</span>
</el-button-group>
</span>
</div>
</div>
<hr>
<div class="card">
<div class="card-header">
<h5 class="card-title m-0">模板选择</h5>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="折叠">
<i class="fas fa-minus"></i>
</button>
<!-- <button type="button" class="btn btn-tool" data-card-widget="remove" title="移除">
<i class="fas fa-times"></i>
</button> -->
</div>
</div>
<div class="card-body">
<!--templates area-->
<el-form ref="form" :inline="true" :model="formData" label-width="100px" size="mini">
<div v-for="(item, index) in templates" :key="index">
<el-button-group >
<el-button type="primary" plain disabled>{{item.group}}</el-button>
<span v-for="(childItem, index) in item.templates" :key="index">
<el-button @click="setOutputModel">{{childItem.name}}</el-button>
</span>
</el-button-group>
</div>
<!-- <el-button-group>
<el-button type="primary" plain disabled>MybatisPlus</el-button>
<el-button @click="setOutputModel">Controller</el-button>
<el-button @click="setOutputModel">Mapper</el-button>
</el-button-group>-->
</el-form>
</div>
</div>
<hr>
<div class="card">
<div class="card-header">
<h5 class="card-title m-0">输出代码</h5>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="折叠">
<i class="fas fa-minus"></i>
</button>
<!-- <button type="button" class="btn btn-tool" data-card-widget="remove" title="移除">
<i class="fas fa-times"></i>
</button> -->
</div>
</div>
<div class="card-body">
<textarea id="outputArea" placeholder="请输入表结构信息..." style="height: 250px;" v-model="outputStr"></textarea>
</div>
</div>
</el-form>
</div>
</div>
<script src="${request.contextPath}/statics/js/main.js"></script>
<script>
//console.log(vm);
vm.formData.options.authorName="${(value.author)!!}";
vm.formData.options.packageName="${(value.packageName)!!}";
vm.formData.options.returnUtilSuccess="${(value.returnUtilSuccess)!!}";
vm.formData.options.returnUtilFailure="${(value.returnUtilFailure)!!}";
vm.outputStr="${(value.outputStr)!!}";
loadAllCookie()
</script>
</body>
</html>

View File

@@ -1,31 +1,31 @@
<!--###################################################-->
<!--### CDN version : by https://cdn.bytedance.com/ -->
<!--### StaticFile CDN : by https://www.staticfile.org/ -->
<!--###################################################-->
<!--jquery | vue | element-ui | axios-->
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js"></script>
<script src="//lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/axios/0.26.0/axios.min.js"></script>
<script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/index.min.js"></script>
<link href="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/theme-chalk/index.min.css" type="text/css" rel="stylesheet" />
<script src="//cdn.staticfile.net/jquery/3.6.0/jquery.min.js"></script>
<script src="//cdn.staticfile.net/vue/2.6.14/vue.min.js"></script>
<script src="//cdn.staticfile.net/axios/0.26.0/axios.min.js"></script>
<script src="//cdn.staticfile.net/element-ui/2.15.7/index.min.js"></script>
<link href="//cdn.staticfile.net/element-ui/2.15.7/theme-chalk/index.min.css" type="text/css" rel="stylesheet" />
<!-- bootstrap -->
<script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap/5.1.3/js/bootstrap.bundle.min.js" type="application/javascript"></script>
<link href="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/bootstrap/5.1.3/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script src="//cdn.staticfile.net/bootstrap/5.1.3/js/bootstrap.bundle.min.js" type="application/javascript"></script>
<link href="//cdn.staticfile.net/bootstrap/5.1.3/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<!-- 引入 Bootstrap Icons CSS -->
<link href="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/bootstrap-icons/1.8.1/font/bootstrap-icons.min.css" type="text/css" rel="stylesheet" />
<link href="//cdn.staticfile.net/bootstrap-icons/1.8.1/font/bootstrap-icons.min.css" type="text/css" rel="stylesheet" />
<!--common.js-->
<script src="${request.contextPath}/statics/js/common.js"></script>
<!-- <link rel="stylesheet" href="${request.contextPath}/statics/css/main.css"> -->
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/toastr.js/2.1.4/toastr.min.js"></script>
<script src="//cdn.staticfile.net/toastr.js/2.1.4/toastr.min.js"></script>
<!-- Toastr CSS -->
<link href="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/toastr.js/2.1.4/toastr.min.css" rtype="text/css" rel="stylesheet" >
<link href="//cdn.staticfile.net/toastr.js/2.1.4/toastr.min.css" rtype="text/css" rel="stylesheet" >
<!-- import codemirror -->
<script src="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/codemirror.min.js"></script>
<script src="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/mode/sql/sql.min.js"></script>
<script src="//lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/codemirror/5.65.2/mode/clike/clike.min.js" type="application/javascript"></script>
<link href="//lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/codemirror.min.css" type="text/css" rel="stylesheet" >
<link href="//lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/codemirror/5.65.2/theme/idea.min.css" type="text/css" rel="stylesheet" >
<script src="//cdn.staticfile.net/codemirror/5.65.2/codemirror.min.js"></script>
<script src="//cdn.staticfile.net/codemirror/5.65.2/mode/sql/sql.min.js"></script>
<script src="//cdn.staticfile.net/codemirror/5.65.2/mode/clike/clike.min.js" type="application/javascript"></script>
<link href="//cdn.staticfile.net/codemirror/5.65.2/codemirror.min.css" type="text/css" rel="stylesheet" >
<link href="//cdn.staticfile.net/codemirror/5.65.2/theme/idea.min.css" type="text/css" rel="stylesheet" >

View File

@@ -25,6 +25,7 @@
<!-- import codemirror -->
<script src="${request.contextPath}/statics/libs/codemirror/codemirror.min.js"></script>
<link href="${request.contextPath}/statics/libs/codemirror/codemirror.min.css" type="text/css" rel="stylesheet" >
<script src="${request.contextPath}/statics/libs/codemirror/mode/sql/sql.min.js"></script>
<script src="${request.contextPath}/statics/libs/codemirror/mode/clike/clike.min.js"></script>
<link href="${request.contextPath}/statics/libs/codemirror/codemirror.min.css" type="text/css" rel="stylesheet" >
<link href="${request.contextPath}/statics/libs/codemirror/theme/idea.min.css" type="text/css" rel="stylesheet" >

View File

@@ -62,7 +62,7 @@
</div>
<small>${(value.slogan)!!}</small>
<div class="links">
View in <a href="https://github.com/moshowgame/SpringBootCodeGenerator/" target="_blank">GitHub</a> <a href="https://gitee.com/moshowgame/SpringBootCodeGenerator/" target="_blank">Gitee</a>
<a href="https://github.com/moshowgame/SpringBootCodeGenerator/" target="_blank">GitHub</a> <a href="https://zhengkai.blog.csdn.net/" target="_blank">CSDN</a>
</div>
</div>
<div class="container">
@@ -100,6 +100,15 @@
</div>
<div class="card-body">
<el-form-item label="🌟🌟🌟引擎">
<el-select v-model="formData.options.dataType">
<el-option label="DDL SQL@自研SQL解析引擎" value="sql"></el-option>
<el-option label="SELECT SQL@JSqlParser引擎" value="select-sql"></el-option>
<el-option label="CREATE SQL@JSqlParser引擎" value="create-sql"></el-option>
<el-option label="JSON(Beta)" value="json"></el-option>
<el-option label="INSERT SQL" value="insert-sql"></el-option>
</el-select>
</el-form-item>
<el-form-item label="作者">
<el-input v-model="formData.options.authorName"></el-input>
</el-form-item>
@@ -115,14 +124,6 @@
<el-form-item label="忽略前缀">
<el-input v-model="formData.options.ignorePrefix"></el-input>
</el-form-item>
<el-form-item label="输入类型">
<el-select v-model="formData.options.dataType">
<el-option label="DDL SQL" value="sql"></el-option>
<el-option label="JSON" value="json"></el-option>
<el-option label="INSERT SQL" value="insert-sql"></el-option>
<el-option label="SELECT SQL by SQL Parser" value="select-sql"></el-option>
</el-select>
</el-form-item>
<el-form-item label="TinyInt转换">
<el-select v-model="formData.options.tinyintTransType">
<el-option value="boolean" label="boolean"></el-option>

36
pom.xml
View File

@@ -11,19 +11,26 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.1</version>
<version>3.5.5</version>
</parent>
<modules>
<module>generator-web</module>
</modules>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<properties>
<!-- 指定编码 -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- 指定jdk版本 -->
<java.version>11</java.version>
<java.version>17</java.version>
</properties>
<dependencies>
@@ -32,7 +39,7 @@
<dependency>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
<version>5.0</version>
<version>5.3</version>
</dependency>
<dependency>
@@ -63,25 +70,25 @@
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.53</version>
<version>2.0.58</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>2.0.53</version>
<version>2.0.58</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2-extension-spring6 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring6</artifactId>
<version>2.0.53</version>
<version>2.0.58</version>
</dependency>
<!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>
<!-- 支持 @ConfigurationProperties 注解 -->
@@ -110,7 +117,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<version>1.18.40</version>
</dependency>
<!-- freemarker -->
@@ -137,13 +144,13 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
<version>3.18.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.18.0</version>
<version>2.20.0</version>
</dependency>
</dependencies>
@@ -159,12 +166,7 @@
</plugins>
</build>
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>