mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-06-17 20:13:39 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b447d98423 | ||
|
|
068472d8cb | ||
|
|
e008e4df4e | ||
|
|
17d668ab87 | ||
|
|
fc271338c6 | ||
|
|
46110ee55f | ||
|
|
8f4e09d01a | ||
|
|
d1062f1622 | ||
|
|
45643663bd |
26
README.md
26
README.md
@@ -39,27 +39,33 @@
|
|||||||
- 可设置`表名前缀`,例如sys_user前缀为sys_之后可以正确生成user类
|
- 可设置`表名前缀`,例如sys_user前缀为sys_之后可以正确生成user类
|
||||||
- 可在`applicaltion.yml`中的`OEM.mode`设置`js/css引入模式`为`local`(本地模式,默认)/`CDN`(云CDN模式,在线网站推荐,省流量)
|
- 可在`applicaltion.yml`中的`OEM.mode`设置`js/css引入模式`为`local`(本地模式,默认)/`CDN`(云CDN模式,在线网站推荐,省流量)
|
||||||
- OEM信息可以在`applicaltion.yml`中的`OEM`中更改
|
- OEM信息可以在`applicaltion.yml`中的`OEM`中更改
|
||||||
|
- *支持公共js/css的Local/CDN模式切换,方便`本地`或者`工具站`进行部署,可以在`application.yml`的`OEM.Mode=`进行设置,之后请在`header-CDN.html`/`header-local.html`中检查对应js/css配置是否正确。
|
||||||
|
|
||||||
# Url
|
# Url
|
||||||
|
|
||||||
感谢`卡卡`将他部署在[BEJSON](https://java.bejson.com/generator)上,目前是besjon专供的金牌工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).<br>
|
感谢`卡卡`将他部署在[BEJSON](https://java.bejson.com/generator)上,目前是besjon专供的金牌工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).<br>
|
||||||
|
感谢`jully.top`部署的副本 [https://jully.top/generator/](https://jully.top/generator/)。<br>
|
||||||
感谢`三叔`将他部署在[DEVTOOLS](https://java.devtools.cn/)上,继续作为Golden Tool开放给大家使用。<br>
|
感谢`三叔`将他部署在[DEVTOOLS](https://java.devtools.cn/) (Demised)上,继续作为Golden Tool开放给大家使用。<br>
|
||||||
|
感谢`七牛`提供的云js/css免费加速服务,它尽可能全面收录优秀的开源库,并免费为之提供 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>
|
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>
|
||||||
|
|
||||||
| 访问地址 | http://localhost:1234/generator |
|
| 访问地址 | http://localhost:1234/generator |
|
||||||
|:--------------|:--------------------------------------------------------------|
|
|:-----------------------|:--------------------------------------------------------------|
|
||||||
| BEJSON 在线地址 | https://java.bejson.com/generator |
|
| BEJSON 在线地址 | https://java.bejson.com/generator |
|
||||||
| DEVTOOLS 在线地址 | https://java.devtools.cn |
|
| Jully 在线地址 | https://jully.top/generator/ |
|
||||||
| CSDN BLOG | https://zhengkai.blog.csdn.net |
|
| DEVTOOLS 在线地址(Demised) | https://java.devtools.cn |
|
||||||
| GITEE仓库 | https://gitee.com/moshowgame/SpringBootCodeGenerator/releases |
|
| CSDN BLOG | https://zhengkai.blog.csdn.net |
|
||||||
| GITHUB仓库 | https://github.com/moshowgame/SpringBootCodeGenerator |
|
| GITEE仓库 | https://gitee.com/moshowgame/SpringBootCodeGenerator/releases |
|
||||||
|
| GITHUB仓库 | https://github.com/moshowgame/SpringBootCodeGenerator |
|
||||||
|
|
||||||
|
|
||||||
# Update Logs
|
# Update Logs
|
||||||
| 更新日期 | 更新内容 |
|
| 更新日期 | 更新内容 |
|
||||||
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| 2023.10.22 | 工具站CDN更新。 |
|
||||||
|
| 2023.08.31 | (感谢@Nisus-Liu的PR)<br>fix 驼峰列名转命名风格错误问题<br>增强转下划线命名风格, 对原始风格不敏感. 支持各种命名风格的列名 to 下划线<br>增加 NonCaseString 大小写不敏感字符串包装类, 简化编码<br>几点代码小优化。 |
|
||||||
|
| 2023.07.11 | 安全更新,正式支持SpringBoot3,javax升级到jakarta。 |
|
||||||
|
| 2023.01.02 | 新增TkMybatis模板(感谢@sgj666的建议)。 |
|
||||||
| 2023.01.01 | 新增GCP BigQuery/Dataflow JJS/QlikSense BI模板。 |
|
| 2023.01.01 | 新增GCP BigQuery/Dataflow JJS/QlikSense BI模板。 |
|
||||||
| 2022.09.28 | MySQL to Java type conversion 数据库类型转换优化(感谢@jadelike得贡献) |
|
| 2022.09.28 | MySQL to Java type conversion 数据库类型转换优化(感谢@jadelike得贡献) |
|
||||||
| 2022.07.02 | add the script to install and run,添加批处理以便直接构建或运行项目。 |
|
| 2022.07.02 | add the script to install and run,添加批处理以便直接构建或运行项目。 |
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 198 KiB |
@@ -7,7 +7,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.softdev.system</groupId>
|
<groupId>com.softdev.system</groupId>
|
||||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||||
<version>3.0</version>
|
<version>2023</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>generator-web</artifactId>
|
<artifactId>generator-web</artifactId>
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -42,7 +41,11 @@
|
|||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
</dependency>-->
|
</dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
|
|||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhengkai.blog.csdn.net
|
* @author zhengkai.blog.csdn.net
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.softdev.system.generator.config;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||||
|
import jakarta.servlet.DispatcherType;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -11,7 +12,6 @@ import org.springframework.http.converter.StringHttpMessageConverter;
|
|||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import javax.servlet.DispatcherType;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.softdev.system.generator.config;
|
package com.softdev.system.generator.config;
|
||||||
|
|
||||||
import javax.servlet.*;
|
import jakarta.servlet.*;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,8 +19,8 @@ public class XssFilter implements Filter {
|
|||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
|
||||||
(HttpServletRequest) request);
|
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest)request);
|
||||||
chain.doFilter(xssRequest, response);
|
chain.doFilter(xssRequest, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package com.softdev.system.generator.config;
|
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.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
|
||||||
import javax.servlet.ReadListener;
|
|
||||||
import javax.servlet.ServletInputStream;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletRequestWrapper;
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class GeneratorController {
|
|||||||
|
|
||||||
//3.generate the code by freemarker templates with parameters . Freemarker根据参数和模板生成代码
|
//3.generate the code by freemarker templates with parameters . Freemarker根据参数和模板生成代码
|
||||||
Map<String, String> result = generatorService.getResultByParams(paramInfo.getOptions());
|
Map<String, String> result = generatorService.getResultByParams(paramInfo.getOptions());
|
||||||
log.info("result {}",result);
|
// log.info("result {}",result);
|
||||||
log.info("table:{} - time:{} ", MapUtil.getString(result,"tableName"),new Date());
|
log.info("table:{} - time:{} ", MapUtil.getString(result,"tableName"),new Date());
|
||||||
return ReturnT.ok().put("outputJson",result);
|
return ReturnT.ok().put("outputJson",result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
package com.softdev.system.generator.entity;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String 包装类
|
||||||
|
* <p>
|
||||||
|
* 忽略大小写
|
||||||
|
**考虑增加这个类是, 如果在 StringUtils 中加工具方法, 使用起来代码非常冗长且不方便
|
||||||
|
* @author Nisus
|
||||||
|
* @see String
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class NonCaseString implements CharSequence {
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public static NonCaseString of(String str) {
|
||||||
|
assert str != null;
|
||||||
|
return new NonCaseString(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link String#indexOf(String)} 增强, 忽略大小写
|
||||||
|
*/
|
||||||
|
public int indexOf(String m) {
|
||||||
|
String text = this.value;
|
||||||
|
if (text == null || m == null || text.length() < m.length()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return text.toLowerCase().indexOf(m.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link String#lastIndexOf(String)} 增强, 忽略大小写
|
||||||
|
*/
|
||||||
|
public int lastIndexOf(String m) {
|
||||||
|
String text = this.value;
|
||||||
|
if (text == null || m == null || text.length() < m.length()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return text.toLowerCase().lastIndexOf(m.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否包含, 大小写不敏感
|
||||||
|
* <pre
|
||||||
|
* "abcxyz" 包含 "abc" => true
|
||||||
|
* "abcxyz" 包含 "ABC" => true
|
||||||
|
* "abcxyz" 包含 "aBC" => true
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param m 被包含字符串
|
||||||
|
*/
|
||||||
|
public boolean contains(String m) {
|
||||||
|
String text = this.value;
|
||||||
|
if (text.length() < m.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return text.toLowerCase().contains(m.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任意一个包含返回true
|
||||||
|
* <pre>
|
||||||
|
* containsAny("abcdef", "a", "b)
|
||||||
|
* 等价
|
||||||
|
* "abcdef".contains("a") || "abcdef".contains("b")
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param matchers 多个要判断的被包含项
|
||||||
|
*/
|
||||||
|
public boolean containsAny(String... matchers) {
|
||||||
|
for (String matcher : matchers) {
|
||||||
|
if (contains(matcher)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所有都包含才返回true
|
||||||
|
*
|
||||||
|
* @param matchers 多个要判断的被包含项
|
||||||
|
*/
|
||||||
|
public boolean containsAllIgnoreCase(String... matchers) {
|
||||||
|
for (String matcher : matchers) {
|
||||||
|
if (contains(matcher) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonCaseString trim() {
|
||||||
|
return NonCaseString.of(this.value.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonCaseString replace(char oldChar, char newChar) {
|
||||||
|
return NonCaseString.of(this.value.replace(oldChar, newChar));
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonCaseString replaceAll(String regex, String replacement) {
|
||||||
|
return NonCaseString.of(this.value.replaceAll(regex, replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonCaseString substring(int beginIndex) {
|
||||||
|
return NonCaseString.of(this.value.substring(beginIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
public NonCaseString substring(int beginIndex, int endIndex) {
|
||||||
|
return NonCaseString.of(this.value.substring(beginIndex, endIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNotEmpty() {
|
||||||
|
return !this.value.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int length() {
|
||||||
|
return this.value.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char charAt(int index) {
|
||||||
|
return this.value.charAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence subSequence(int start, int end) {
|
||||||
|
return this.value.subSequence(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] split(String regex) {
|
||||||
|
return this.value.split(regex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 原始字符串
|
||||||
|
*/
|
||||||
|
public String get() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.softdev.system.generator.entity;
|
package com.softdev.system.generator.entity;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -11,6 +11,7 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* @author zhengkai.blog.csdn.net
|
* @author zhengkai.blog.csdn.net
|
||||||
*/
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class ReturnT extends HashMap<String, Object> {
|
public class ReturnT extends HashMap<String, Object> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class StringUtils {
|
|||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
for (int i = 0; i < underscoreName.length(); i++) {
|
for (int i = 0; i < underscoreName.length(); i++) {
|
||||||
char ch = underscoreName.charAt(i);
|
char ch = underscoreName.charAt(i);
|
||||||
if ("_".charAt(0) == ch) {
|
if ('_' == ch) {
|
||||||
flag = true;
|
flag = true;
|
||||||
} else {
|
} else {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -54,6 +54,42 @@ public class StringUtils {
|
|||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转 user_name 风格
|
||||||
|
*
|
||||||
|
* 不管原始是什么风格
|
||||||
|
*/
|
||||||
|
public static String toUnderline(String str, boolean upperCase) {
|
||||||
|
if (str == null || str.trim().isEmpty()) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
boolean preIsUnderscore = false;
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
char ch = str.charAt(i);
|
||||||
|
if (ch == '_') {
|
||||||
|
preIsUnderscore = true;
|
||||||
|
} else if (ch == '-') {
|
||||||
|
ch = '_';
|
||||||
|
preIsUnderscore = true; // -A -> _a
|
||||||
|
} else if (ch >= 'A' && ch <= 'Z') {
|
||||||
|
// A -> _a
|
||||||
|
if (!preIsUnderscore && i > 0) { // _A -> _a
|
||||||
|
result.append("_");
|
||||||
|
}
|
||||||
|
preIsUnderscore = false;
|
||||||
|
} else {
|
||||||
|
preIsUnderscore = false;
|
||||||
|
}
|
||||||
|
result.append(upperCase ? Character.toUpperCase(ch) : Character.toLowerCase(ch));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isNotNull(String str){
|
public static boolean isNotNull(String str){
|
||||||
return org.apache.commons.lang3.StringUtils.isNotEmpty(str);
|
return org.apache.commons.lang3.StringUtils.isNotEmpty(str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
package com.softdev.system.generator.util;
|
package com.softdev.system.generator.util;
|
||||||
|
|
||||||
import com.softdev.system.generator.util.mysqlJavaTypeUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.softdev.system.generator.entity.ClassInfo;
|
import com.softdev.system.generator.entity.ClassInfo;
|
||||||
import com.softdev.system.generator.entity.FieldInfo;
|
import com.softdev.system.generator.entity.FieldInfo;
|
||||||
|
import com.softdev.system.generator.entity.NonCaseString;
|
||||||
import com.softdev.system.generator.entity.ParamInfo;
|
import com.softdev.system.generator.entity.ParamInfo;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -34,7 +32,7 @@ public class TableParseUtil {
|
|||||||
public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
|
public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
//process the param
|
//process the param
|
||||||
String tableSql = paramInfo.getTableSql();
|
NonCaseString tableSql = NonCaseString.of(paramInfo.getTableSql());
|
||||||
String nameCaseType = MapUtil.getString(paramInfo.getOptions(),"nameCaseType");
|
String nameCaseType = MapUtil.getString(paramInfo.getOptions(),"nameCaseType");
|
||||||
Boolean isPackageType = MapUtil.getBoolean(paramInfo.getOptions(),"isPackageType");
|
Boolean isPackageType = MapUtil.getBoolean(paramInfo.getOptions(),"isPackageType");
|
||||||
|
|
||||||
@@ -42,15 +40,20 @@ public class TableParseUtil {
|
|||||||
throw new CodeGenerateException("Table structure can not be empty. 表结构不能为空。");
|
throw new CodeGenerateException("Table structure can not be empty. 表结构不能为空。");
|
||||||
}
|
}
|
||||||
//deal with special character
|
//deal with special character
|
||||||
tableSql = tableSql.trim().replaceAll("'", "`").replaceAll("\"", "`").replaceAll(",", ",").toLowerCase();
|
tableSql = tableSql.trim()
|
||||||
|
.replaceAll("'", "`")
|
||||||
|
.replaceAll("\"", "`")
|
||||||
|
.replaceAll(",", ",")
|
||||||
|
// 这里全部转小写, 会让驼峰风格的字段名丢失驼峰信息(真有驼峰sql字段名的呢(* ̄︶ ̄)); 下文使用工具方法处理包含等
|
||||||
|
// .toLowerCase()
|
||||||
|
;
|
||||||
//deal with java string copy \n"
|
//deal with java string copy \n"
|
||||||
tableSql = tableSql.trim().replaceAll("\\\\n`", "").replaceAll("\\+", "").replaceAll("``", "`").replaceAll("\\\\", "");
|
tableSql = tableSql.trim().replaceAll("\\\\n`", "").replaceAll("\\+", "").replaceAll("``", "`").replaceAll("\\\\", "");
|
||||||
// table Name
|
// table Name
|
||||||
String tableName = null;
|
String tableName = null;
|
||||||
if (tableSql.contains("TABLE") && tableSql.contains("(")) {
|
int tableKwIx = tableSql.indexOf("TABLE"); // 包含判断和位置一次搞定
|
||||||
tableName = tableSql.substring(tableSql.indexOf("TABLE") + 5, tableSql.indexOf("("));
|
if (tableKwIx > -1 && tableSql.contains("(")) {
|
||||||
} else if (tableSql.contains("table") && tableSql.contains("(")) {
|
tableName = tableSql.substring(tableKwIx + 5, tableSql.indexOf("(")).get();
|
||||||
tableName = tableSql.substring(tableSql.indexOf("table") + 5, tableSql.indexOf("("));
|
|
||||||
} else {
|
} else {
|
||||||
throw new CodeGenerateException("Table structure incorrect.表结构不正确。");
|
throw new CodeGenerateException("Table structure incorrect.表结构不正确。");
|
||||||
}
|
}
|
||||||
@@ -88,9 +91,11 @@ public class TableParseUtil {
|
|||||||
String classComment = null;
|
String classComment = null;
|
||||||
//mysql是comment=,pgsql/oracle是comment on table,
|
//mysql是comment=,pgsql/oracle是comment on table,
|
||||||
//2020-05-25 优化表备注的获取逻辑
|
//2020-05-25 优化表备注的获取逻辑
|
||||||
if (tableSql.contains("comment=") || tableSql.contains("comment on table")) {
|
if (tableSql.containsAny("comment=", "comment on table")) {
|
||||||
String classCommentTmp = (tableSql.contains("comment=")) ?
|
int ix = tableSql.lastIndexOf("comment=");
|
||||||
tableSql.substring(tableSql.lastIndexOf("comment=") + 8).trim() : tableSql.substring(tableSql.lastIndexOf("comment on table") + 17).trim();
|
String classCommentTmp = (ix > -1) ?
|
||||||
|
tableSql.substring(ix + 8).trim().get() :
|
||||||
|
tableSql.substring(tableSql.lastIndexOf("comment on table") + 17).trim().get();
|
||||||
if (classCommentTmp.contains("`")) {
|
if (classCommentTmp.contains("`")) {
|
||||||
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf("`") + 1);
|
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf("`") + 1);
|
||||||
classCommentTmp = classCommentTmp.substring(0, classCommentTmp.indexOf("`"));
|
classCommentTmp = classCommentTmp.substring(0, classCommentTmp.indexOf("`"));
|
||||||
@@ -109,7 +114,7 @@ public class TableParseUtil {
|
|||||||
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
||||||
|
|
||||||
// 正常( ) 内的一定是字段相关的定义。
|
// 正常( ) 内的一定是字段相关的定义。
|
||||||
String fieldListTmp = tableSql.substring(tableSql.indexOf("(") + 1, tableSql.lastIndexOf(")"));
|
String fieldListTmp = tableSql.substring(tableSql.indexOf("(") + 1, tableSql.lastIndexOf(")")).get();
|
||||||
|
|
||||||
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
||||||
String commentPattenStr1 = "comment `(.*?)\\`";
|
String commentPattenStr1 = "comment `(.*?)\\`";
|
||||||
@@ -149,7 +154,8 @@ public class TableParseUtil {
|
|||||||
if (fieldLineList.length > 0) {
|
if (fieldLineList.length > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
||||||
for (String columnLine : fieldLineList) {
|
for (String columnLine0 : fieldLineList) {
|
||||||
|
NonCaseString columnLine = NonCaseString.of(columnLine0);
|
||||||
i++;
|
i++;
|
||||||
columnLine = columnLine.replaceAll("\n", "").replaceAll("\t", "").trim();
|
columnLine = columnLine.replaceAll("\n", "").replaceAll("\t", "").trim();
|
||||||
// `userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
// `userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
@@ -158,13 +164,10 @@ public class TableParseUtil {
|
|||||||
// 2019-2-22 zhengkai 要在条件中使用复杂的表达式
|
// 2019-2-22 zhengkai 要在条件中使用复杂的表达式
|
||||||
// 2019-4-29 zhengkai 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )
|
// 2019-4-29 zhengkai 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )
|
||||||
// 2020-10-20 zhengkai 优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)
|
// 2020-10-20 zhengkai 优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)
|
||||||
boolean specialFlag = (!columnLine.contains("key ") && !columnLine.contains("constraint") && !columnLine.contains("using") && !columnLine.contains("unique ")
|
// 2023-8-27 zhangfei 改用工具方法判断, 且修改变量名(非特殊标识), 方法抽取
|
||||||
&& !(columnLine.contains("primary ") && columnLine.indexOf("storage") + 3 > columnLine.indexOf("("))
|
boolean notSpecialFlag = isNotSpecialColumnLine(columnLine, i);
|
||||||
&& !columnLine.contains("fulltext ") && !columnLine.contains("index ")
|
|
||||||
&& !columnLine.contains("pctincrease")
|
if (notSpecialFlag) {
|
||||||
&& !columnLine.contains("buffer_pool") && !columnLine.contains("tablespace")
|
|
||||||
&& !(columnLine.contains("primary ") && i > 3));
|
|
||||||
if (specialFlag) {
|
|
||||||
//如果是oracle的number(x,x),可能出现最后分割残留的,x),这里做排除处理
|
//如果是oracle的number(x,x),可能出现最后分割残留的,x),这里做排除处理
|
||||||
if (columnLine.length() < 5) {
|
if (columnLine.length() < 5) {
|
||||||
continue;
|
continue;
|
||||||
@@ -174,7 +177,7 @@ public class TableParseUtil {
|
|||||||
columnLine = columnLine.replaceAll("`", " ").replaceAll("\"", " ").replaceAll("'", "").replaceAll(" ", " ").trim();
|
columnLine = columnLine.replaceAll("`", " ").replaceAll("\"", " ").replaceAll("'", "").replaceAll(" ", " ").trim();
|
||||||
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
||||||
try {
|
try {
|
||||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
columnName = columnLine.substring(0, columnLine.indexOf(" ")).get();
|
||||||
} catch (StringIndexOutOfBoundsException e) {
|
} catch (StringIndexOutOfBoundsException e) {
|
||||||
System.out.println("err happened: " + columnLine);
|
System.out.println("err happened: " + columnLine);
|
||||||
throw e;
|
throw e;
|
||||||
@@ -182,6 +185,7 @@ public class TableParseUtil {
|
|||||||
|
|
||||||
// field Name
|
// field Name
|
||||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||||
|
// 2023-8-27 zhangfei 支持原始列名任意命名风格, 不依赖用户是否输入下划线
|
||||||
String fieldName = null;
|
String fieldName = null;
|
||||||
if (ParamInfo.NAME_CASE_TYPE.CAMEL_CASE.equals(nameCaseType)) {
|
if (ParamInfo.NAME_CASE_TYPE.CAMEL_CASE.equals(nameCaseType)) {
|
||||||
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||||
@@ -189,9 +193,9 @@ public class TableParseUtil {
|
|||||||
fieldName = fieldName.replaceAll("_", "");
|
fieldName = fieldName.replaceAll("_", "");
|
||||||
}
|
}
|
||||||
} else if (ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE.equals(nameCaseType)) {
|
} else if (ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE.equals(nameCaseType)) {
|
||||||
fieldName = StringUtils.lowerCaseFirst(columnName);
|
fieldName = StringUtils.toUnderline(columnName, false);
|
||||||
} else if (ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE.equals(nameCaseType)) {
|
} else if (ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE.equals(nameCaseType)) {
|
||||||
fieldName = StringUtils.lowerCaseFirst(columnName.toUpperCase());
|
fieldName = StringUtils.toUnderline(columnName.toUpperCase(), true);
|
||||||
} else {
|
} else {
|
||||||
fieldName = columnName;
|
fieldName = columnName;
|
||||||
}
|
}
|
||||||
@@ -228,12 +232,12 @@ public class TableParseUtil {
|
|||||||
while (columnCommentMatcher.find()) {
|
while (columnCommentMatcher.find()) {
|
||||||
String columnCommentTmp = columnCommentMatcher.group();
|
String columnCommentTmp = columnCommentMatcher.group();
|
||||||
//System.out.println(columnCommentTmp);
|
//System.out.println(columnCommentTmp);
|
||||||
fieldComment = tableSql.substring(tableSql.indexOf(columnCommentTmp) + columnCommentTmp.length()).trim();
|
fieldComment = tableSql.substring(tableSql.indexOf(columnCommentTmp) + columnCommentTmp.length()).trim().get();
|
||||||
fieldComment = fieldComment.substring(0, fieldComment.indexOf("`")).trim();
|
fieldComment = fieldComment.substring(0, fieldComment.indexOf("`")).trim();
|
||||||
}
|
}
|
||||||
} else if (columnLine.contains(" comment")) {
|
} else if (columnLine.contains(" comment")) {
|
||||||
//20200518 zhengkai 修复包含comment关键字的问题
|
//20200518 zhengkai 修复包含comment关键字的问题
|
||||||
String commentTmp = columnLine.substring(columnLine.lastIndexOf("comment") + 7).trim();
|
String commentTmp = columnLine.substring(columnLine.lastIndexOf("comment") + 7).trim().get();
|
||||||
// '用户ID',
|
// '用户ID',
|
||||||
if (commentTmp.contains("`") || commentTmp.indexOf("`") != commentTmp.lastIndexOf("`")) {
|
if (commentTmp.contains("`") || commentTmp.indexOf("`") != commentTmp.lastIndexOf("`")) {
|
||||||
commentTmp = commentTmp.substring(commentTmp.indexOf("`") + 1, commentTmp.lastIndexOf("`"));
|
commentTmp = commentTmp.substring(commentTmp.indexOf("`") + 1, commentTmp.lastIndexOf("`"));
|
||||||
@@ -275,6 +279,24 @@ public class TableParseUtil {
|
|||||||
return codeJavaInfo;
|
return codeJavaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isNotSpecialColumnLine(NonCaseString columnLine, int lineSeq) {
|
||||||
|
return (
|
||||||
|
!columnLine.containsAny(
|
||||||
|
"key ",
|
||||||
|
"constraint",
|
||||||
|
"using",
|
||||||
|
"unique ",
|
||||||
|
"fulltext ",
|
||||||
|
"index ",
|
||||||
|
"pctincrease",
|
||||||
|
"buffer_pool",
|
||||||
|
"tablespace"
|
||||||
|
)
|
||||||
|
&& !(columnLine.contains("primary ") && columnLine.indexOf("storage") + 3 > columnLine.indexOf("("))
|
||||||
|
&& !(columnLine.contains("primary ") && lineSeq > 3)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解析JSON生成类信息
|
* 解析JSON生成类信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ spring:
|
|||||||
#mvc:
|
#mvc:
|
||||||
# static-path-pattern: /statics/**
|
# static-path-pattern: /statics/**
|
||||||
OEM:
|
OEM:
|
||||||
version: 2023.1
|
version: 2023.10
|
||||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||||
title: JAVA在线代码生成
|
title: JAVA在线代码生成
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ spring:
|
|||||||
#mvc:
|
#mvc:
|
||||||
# static-path-pattern: /statics/**
|
# static-path-pattern: /statics/**
|
||||||
OEM:
|
OEM:
|
||||||
version: 2023.1
|
version: 2023.10
|
||||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||||
title: JAVA代码生成平台
|
title: JAVA代码生成平台
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ spring:
|
|||||||
#mvc:
|
#mvc:
|
||||||
# static-path-pattern: /statics/**
|
# static-path-pattern: /statics/**
|
||||||
OEM:
|
OEM:
|
||||||
version: 2023.1
|
version: 2023.10
|
||||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||||
title: JAVA在线代码生成
|
title: JAVA在线代码生成
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ const vm = new Vue({
|
|||||||
" 'user_name' varchar(255) NOT NULL COMMENT '用户名',\n" +
|
" 'user_name' varchar(255) NOT NULL COMMENT '用户名',\n" +
|
||||||
" 'status' tinyint(1) NOT NULL COMMENT '状态',\n" +
|
" 'status' tinyint(1) NOT NULL COMMENT '状态',\n" +
|
||||||
" 'create_time' datetime NOT NULL COMMENT '创建时间',\n" +
|
" 'create_time' datetime NOT NULL COMMENT '创建时间',\n" +
|
||||||
|
//下面可以留着方便开发调试时打开
|
||||||
|
// " `updateTime` datetime NOT NULL COMMENT '更新时间',\n" +
|
||||||
|
// " ABc_under_Line-Hypen-CamelCase varchar comment '乱七八糟的命名风格',\n" +
|
||||||
" PRIMARY KEY ('user_id')\n" +
|
" PRIMARY KEY ('user_id')\n" +
|
||||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'",
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'",
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version": "20201222"}
|
{"version": "20231022"}
|
||||||
@@ -271,5 +271,25 @@
|
|||||||
"description": "GCP Dataflow JJS"
|
"description": "GCP Dataflow JJS"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "tk-mybatis",
|
||||||
|
"templates": [
|
||||||
|
{
|
||||||
|
"id": "401",
|
||||||
|
"name": "tk-entity",
|
||||||
|
"description": "tk-entity"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "402",
|
||||||
|
"name": "tk-mapper",
|
||||||
|
"description": "tk-mapper"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "403",
|
||||||
|
"name": "tk-controller",
|
||||||
|
"description": "tk-controller"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller;</#if>
|
||||||
|
<#if isAutoImport?exists && isAutoImport==true>
|
||||||
|
import ${packageName}.entity.${classInfo.className};
|
||||||
|
import ${packageName}.mapper.${classInfo.className}Mapper;
|
||||||
|
import org.springframework.data.domain.Example;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
</#if>
|
||||||
|
/**
|
||||||
|
* @description ${classInfo.classComment}
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy-MM-dd')}
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/${classInfo.className?uncap_first}")
|
||||||
|
public class ${classInfo.className}Controller {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ${classInfo.className}Mapper ${classInfo.className?uncap_first}Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增或编辑
|
||||||
|
*/
|
||||||
|
@PostMapping("/save")
|
||||||
|
public Object save(${classInfo.className} ${classInfo.className?uncap_first}){
|
||||||
|
if(${classInfo.className?uncap_first}Mapper.selectCount(${classInfo.className?uncap_first})>0){
|
||||||
|
${classInfo.className?uncap_first}Mapper.insert(${classInfo.className?uncap_first});
|
||||||
|
}else{
|
||||||
|
${classInfo.className?uncap_first}Mapper.updateByPrimaryKeySelective(${classInfo.className?uncap_first});
|
||||||
|
}
|
||||||
|
return ${returnUtilSuccess}("新增或编辑成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@PostMapping("/delete")
|
||||||
|
public Object delete(int id){
|
||||||
|
if(${classInfo.className?uncap_first}Mapper.selectCount(${classInfo.className?uncap_first})>0){
|
||||||
|
${classInfo.className?uncap_first}Mapper.deleteByPrimaryKey(id);
|
||||||
|
return ${returnUtilSuccess}("删除成功");
|
||||||
|
}else{
|
||||||
|
return ${returnUtilFailure}("没有找到该对象");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
*/
|
||||||
|
@PostMapping("/find")
|
||||||
|
public Object find(int id){
|
||||||
|
Optional<${classInfo.className}> ${classInfo.className?uncap_first}=${classInfo.className?uncap_first}Mapper.selectOne(id);
|
||||||
|
if(${classInfo.className?uncap_first}.isPresent()){
|
||||||
|
return ${returnUtilSuccess}(${classInfo.className?uncap_first}.get());
|
||||||
|
}else{
|
||||||
|
return ${returnUtilFailure}("没有找到该对象");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
*/
|
||||||
|
@PostMapping("/list")
|
||||||
|
public Object list(${classInfo.className} ${classInfo.className?uncap_first},
|
||||||
|
@RequestParam(required = false, defaultValue = "0") int pageNumber,
|
||||||
|
@RequestParam(required = false, defaultValue = "10") int pageSize) {
|
||||||
|
//TBC
|
||||||
|
return ${classInfo.className?uncap_first}Mapper.selectList(${classInfo.className?uncap_first});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.entity;</#if>
|
||||||
|
|
||||||
|
<#if isAutoImport?exists && isAutoImport==true>
|
||||||
|
<#if isLombok?exists && isLombok==true>import lombok.Data;</#if>
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import io.mybatis.provider.Entity;
|
||||||
|
<#if isSwagger?exists && isSwagger==true>
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;</#if>
|
||||||
|
</#if>
|
||||||
|
/**
|
||||||
|
* @description ${classInfo.classComment}
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy-MM-dd')}
|
||||||
|
*/
|
||||||
|
<#if isLombok?exists && isLombok==true>@Data</#if>
|
||||||
|
<#if isComment?exists && isComment==true>@Entity.Table("${classInfo.originTableName}")</#if><#if isSwagger?exists && isSwagger==true>
|
||||||
|
@ApiModel("${classInfo.classComment}")</#if>
|
||||||
|
public class ${classInfo.className} implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
//@Entity.Column(id = true)
|
||||||
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
<#if isComment?exists && isComment==true>/**
|
||||||
|
* ${fieldItem.fieldComment}
|
||||||
|
*/</#if><#if isSwagger?exists && isSwagger==true>
|
||||||
|
@ApiModelProperty("${fieldItem.fieldComment}")</#if>
|
||||||
|
<#if isComment?exists && isComment==true>@Entity.Column("${fieldItem.columnName}")</#if>
|
||||||
|
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
|
||||||
|
|
||||||
|
</#list>
|
||||||
|
public ${classInfo.className}() {
|
||||||
|
}
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
<#if isLombok?exists && isLombok==false>
|
||||||
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
public ${fieldItem.fieldClass} get${fieldItem.fieldName?cap_first}() {
|
||||||
|
return ${fieldItem.fieldName};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set${fieldItem.fieldName?cap_first}(${fieldItem.fieldClass} ${fieldItem.fieldName}) {
|
||||||
|
this.${fieldItem.fieldName} = ${fieldItem.fieldName};
|
||||||
|
}
|
||||||
|
</#list>
|
||||||
|
</#if>
|
||||||
|
</#if>
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if>
|
||||||
|
<#if isAutoImport?exists && isAutoImport==true>import ${packageName}.entity.${classInfo.className};
|
||||||
|
|
||||||
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
|
<#list classInfo.fieldList as fieldItem >
|
||||||
|
<#if fieldItem.fieldClass == "Date">
|
||||||
|
<#assign importDdate = true />
|
||||||
|
</#if>
|
||||||
|
</#list>
|
||||||
|
</#if>
|
||||||
|
import java.util.List;
|
||||||
|
import io.mybatis.mapper.Mapper;
|
||||||
|
</#if>
|
||||||
|
/**
|
||||||
|
* @description ${classInfo.classComment}
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy-MM-dd')}
|
||||||
|
*/
|
||||||
|
@org.apache.ibatis.annotations.Mapper
|
||||||
|
public interface ${classInfo.className}Mapper extends Mapper<${classInfo.className},Integer> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<!--jquery | vue | element-ui | axios-->
|
<!--jquery | vue | element-ui | axios-->
|
||||||
<script src="//cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script>
|
<script src="//cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script>
|
||||||
<script src="//cdn.staticfile.org/vue/2.6.12/vue.min.js"></script>
|
<script src="//cdn.staticfile.org/vue/2.6.12/vue.min.js"></script>
|
||||||
<script src="//cdn.staticfile.org/element-ui/2.15.0/index.min.js"></script>
|
<script src="//cdn.staticfile.org/element-ui/2.15.14/index.min.js"></script>
|
||||||
<link rel="stylesheet" href="//cdn.staticfile.org/element-ui/2.15.0/theme-chalk/index.min.css">
|
<link rel="stylesheet" href="//cdn.staticfile.org/element-ui/2.15.0/theme-chalk/index.min.css">
|
||||||
<script src="//cdn.staticfile.org/axios/0.1.0/axios.min.js"></script>
|
<script src="//cdn.staticfile.org/axios/0.1.0/axios.min.js"></script>
|
||||||
|
|
||||||
@@ -19,15 +19,15 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- import codemirror -->
|
<!-- import codemirror -->
|
||||||
<script src="//cdn.staticfile.org/codemirror/5.59.1/codemirror.min.js"></script>
|
<script src="//cdn.staticfile.org/codemirror/6.65.7/codemirror.min.js"></script>
|
||||||
<script src="//cdn.staticfile.org/codemirror/5.59.1/mode/sql/sql.min.js"></script>
|
<script src="//cdn.staticfile.org/codemirror/6.65.7/mode/sql/sql.min.js"></script>
|
||||||
<script src="//cdn.staticfile.org/codemirror/5.59.1/mode/xml/xml.min.js"></script>
|
<script src="//cdn.staticfile.org/codemirror/6.65.7/mode/xml/xml.min.js"></script>
|
||||||
<script src="//cdn.staticfile.org/codemirror/5.59.1/mode/clike/clike.min.js"></script>
|
<script src="//cdn.staticfile.org/codemirror/6.65.7/mode/clike/clike.min.js"></script>
|
||||||
<script src="//cdn.staticfile.org/codemirror/5.59.1/mode/javascript/javascript.min.js"></script>
|
<script src="//cdn.staticfile.org/codemirror/6.65.7/mode/javascript/javascript.min.js"></script>
|
||||||
<link rel="stylesheet" href="//cdn.staticfile.org/codemirror/5.59.1/codemirror.min.css">
|
<link rel="stylesheet" href="//cdn.staticfile.org/codemirror/6.65.7/codemirror.min.css">
|
||||||
<link rel="stylesheet" href="//cdn.staticfile.org/codemirror/5.59.1/theme/idea.min.css">
|
<link rel="stylesheet" href="//cdn.staticfile.org/codemirror/6.65.7/theme/idea.min.css">
|
||||||
|
|
||||||
<!--bootsrap -->
|
<!--bootsrap -->
|
||||||
<link rel="stylesheet" href="${request.contextPath}/statics/css/all-skins.min.css">
|
<link rel="stylesheet" href="${request.contextPath}/statics/css/all-skins.min.css">
|
||||||
<link rel="stylesheet" href="//cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
|
<link rel="stylesheet" href="//cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="//cdn.staticfile.org/admin-lte/2.3.7/css/AdminLTE.min.css">
|
<link rel="stylesheet" href="//cdn.staticfile.org/admin-lte/2.3.11/css/AdminLTE.min.css">
|
||||||
25
generator-web/src/test/java/FooTest.java
Normal file
25
generator-web/src/test/java/FooTest.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import com.softdev.system.generator.util.StringUtils;
|
||||||
|
|
||||||
|
public class FooTest {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// String updateTime = StringUtils.underlineToCamelCase("updateTime");
|
||||||
|
// System.out.println(updateTime);
|
||||||
|
|
||||||
|
|
||||||
|
// System.out.println(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "userName"));
|
||||||
|
// System.out.println(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, "userNAme-UUU"));
|
||||||
|
|
||||||
|
System.out.println(StringUtils.toUnderline("userName",false));
|
||||||
|
System.out.println(StringUtils.toUnderline("UserName",false));
|
||||||
|
System.out.println(StringUtils.toUnderline("user_NameGgg_x-UUU",false));
|
||||||
|
System.out.println(StringUtils.toUnderline("username",false));
|
||||||
|
|
||||||
|
System.out.println(StringUtils.toUnderline("userName",true));
|
||||||
|
System.out.println(StringUtils.toUnderline("UserName",true));
|
||||||
|
System.out.println(StringUtils.toUnderline("user_NameGgg_x-UUU",true));
|
||||||
|
System.out.println(StringUtils.toUnderline("username",true));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
15
pom.xml
15
pom.xml
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
<groupId>com.softdev.system</groupId>
|
<groupId>com.softdev.system</groupId>
|
||||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||||
<version>3.0</version>
|
<version>2023</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.6.3</version>
|
<version>3.0.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<!-- 指定编码 -->
|
<!-- 指定编码 -->
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!-- 指定jdk版本 -->
|
<!-- 指定jdk版本 -->
|
||||||
<java.version>1.8</java.version>
|
<java.version>11</java.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -49,9 +49,16 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.83</version>
|
<version>2.0.34</version>
|
||||||
</dependency>
|
</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>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<!-- 支持 @ConfigurationProperties 注解 -->
|
<!-- 支持 @ConfigurationProperties 注解 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 147 KiB |
Reference in New Issue
Block a user