mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-05-08 14:26:18 +08:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60d227a416 | ||
|
|
8794d1e51d | ||
|
|
5397cd1221 | ||
|
|
6d1f29b17c | ||
|
|
48054f3a6b | ||
|
|
8515dd3110 | ||
|
|
64fbaade24 | ||
|
|
412aa510d0 | ||
|
|
536ab42ec1 | ||
|
|
3af7114c7f | ||
|
|
b447d98423 | ||
|
|
068472d8cb | ||
|
|
e008e4df4e | ||
|
|
17d668ab87 | ||
|
|
fc271338c6 | ||
|
|
46110ee55f | ||
|
|
8f4e09d01a | ||
|
|
d1062f1622 | ||
|
|
45643663bd |
64
README.md
64
README.md
@@ -1,6 +1,6 @@
|
||||
# SpringBootCodeGenerator
|
||||
----
|
||||
又名`JAVA在线代码生成平台`、`sql转java`、`大狼狗代码生成器`、`mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`<br>
|
||||
又名`Java代码生成器`、`JAVA在线代码生成平台`、`sql转java`、`大狼狗代码生成器`、`mybatis在线生成器`、`SQL转Java JPA、MYBATIS实现类代码生成平台`<br>
|
||||

|
||||

|
||||

|
||||
@@ -16,17 +16,37 @@
|
||||
>For reducing the repetitive CRUD work<br>
|
||||
> #以解放双手为目的,减少大量的`重复CRUD工作`
|
||||
>
|
||||
>mainly support mysql, support oracle and pgsql as well<br>
|
||||
>Support mysql, oracle and pgsql<br>
|
||||
> #支持`MySQL`、Oracle、PgSQL三大主流数据库
|
||||
>
|
||||
>generate to many popular templates by ddl-sql/insert-sql/simple json<br>
|
||||
> 可通过`建表SQL语句`或`INSERT语句`或者`简单JSON`生成`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper`相关模板代码.
|
||||
>Generate to many predefined popular templates by DDL-SQL/Insert-SQL/Simple JSON<br>
|
||||
> 可通过`建表SQL语句`或`INSERT语句`或者`简单JSON`生成预设的`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper`相关模板代码.
|
||||
>
|
||||
>thanks for your using and feedback,I'm inspired by the 600PV every day and github more than 900 stars <br>
|
||||
> 感谢大家的使用和反馈,每天六百的PV和获得超过九百多的星星是我前进和继续做下去的动力。
|
||||
>Thanks for your using and feedback,I'm inspired by the 1500+PV (AVG) every day and github more than 1.9K stars <br>
|
||||
> 感谢大家的使用和反馈,每天1500的PV和获得超过九百多的星星是我前进和继续做下去的动力。
|
||||
>
|
||||
>hope everyone can keep good balance on work and life , stay health and safety , be smooth on work as well<br>
|
||||
> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利!
|
||||
>Hope everyone can keep good balance on work and life , stay health and safety . I wish you success in your new position and get promoted step by step. <br>
|
||||
> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利,步步高升!
|
||||
>Please submit your issue and template , or pull your good idea into the PR <br>
|
||||
> 提交你的问题和生成模板,或者提交你的好主意到PR。
|
||||
|
||||
|
||||
# Url
|
||||
|
||||
- 感谢`卡卡`将他部署在[BEJSON](https://java.bejson.com/generator)上,目前是besjon专供的`金牌工具`(线上版本不一定是最新的,会有延迟,请谅解,谢谢).<br>
|
||||
- 感谢`jully.top`部署的副本 [https://jully.top/generator/](https://jully.top/generator/)。<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>
|
||||
|
||||
| 访问地址 | http://localhost:1234/generator |
|
||||
|:-----------------------|:--------------------------------------------------------------|
|
||||
| BEJSON 在线地址 | https://java.bejson.com/generator/ |
|
||||
| Jully 在线地址 | https://jully.top/generator/ |
|
||||
| DEVTOOLS 在线地址(Demised) | https://java.devtools.cn |
|
||||
| CSDN BLOG | https://zhengkai.blog.csdn.net |
|
||||
| GITEE仓库 | https://gitee.com/moshowgame/SpringBootCodeGenerator/releases |
|
||||
| GITHUB仓库 | https://github.com/moshowgame/SpringBootCodeGenerator |
|
||||
|
||||
# Tips or Features
|
||||
- 支持`DDL SQL`/`INSERT SQL`/`SIMPLE JSON`三种生成模式
|
||||
@@ -39,27 +59,22 @@
|
||||
- 可设置`表名前缀`,例如sys_user前缀为sys_之后可以正确生成user类
|
||||
- 可在`applicaltion.yml`中的`OEM.mode`设置`js/css引入模式`为`local`(本地模式,默认)/`CDN`(云CDN模式,在线网站推荐,省流量)
|
||||
- OEM信息可以在`applicaltion.yml`中的`OEM`中更改
|
||||
- *支持公共js/css的Local/CDN模式切换,方便`本地`或者`工具站`进行部署,可以在`application.yml`的`OEM.Mode=`进行设置,之后请在`header-CDN.html`/`header-local.html`中检查对应js/css配置是否正确。
|
||||
|
||||
# Url
|
||||
|
||||
感谢`卡卡`将他部署在[BEJSON](https://java.bejson.com/generator)上,目前是besjon专供的金牌工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).<br>
|
||||
|
||||
感谢`三叔`将他部署在[DEVTOOLS](https://java.devtools.cn/)上,继续作为Golden Tool开放给大家使用。<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 |
|
||||
|:--------------|:--------------------------------------------------------------|
|
||||
| BEJSON 在线地址 | https://java.bejson.com/generator |
|
||||
| DEVTOOLS 在线地址 | https://java.devtools.cn |
|
||||
| CSDN BLOG | https://zhengkai.blog.csdn.net |
|
||||
| GITEE仓库 | https://gitee.com/moshowgame/SpringBootCodeGenerator/releases |
|
||||
| GITHUB仓库 | https://github.com/moshowgame/SpringBootCodeGenerator |
|
||||
|
||||
# 更新预告
|
||||
1.计划引入DJANGO等其他语言的ORM模板,欢迎大家submit相关代码供参考
|
||||
2.计划升级一下UI界面
|
||||
|
||||
# Update Logs
|
||||
| 更新日期 | 更新内容 |
|
||||
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 2024.04.21 | 修复CDN版本cdn.staticfile.org域名备份失败问题,已同步更新到cdn.staticfile.net(本地版本则不受影响)
|
||||
| 2024.01.26 | 修复大写下滑线列名转驼峰问题(感谢@Nisus-Liu
|
||||
的PR) |
|
||||
| 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模板。 |
|
||||
| 2022.09.28 | MySQL to Java type conversion 数据库类型转换优化(感谢@jadelike得贡献) |
|
||||
| 2022.07.02 | add the script to install and run,添加批处理以便直接构建或运行项目。 |
|
||||
@@ -155,6 +170,7 @@ Thanks for `JetBrains` providing us the `Licenses for Open Source Development`
|
||||
|
||||
<img src="./codegenerator1.png">
|
||||
<img src="./codegenerator2.png">
|
||||
<img src="./site_analysis-2024.png">
|
||||
<img src="./site_analysis.png">
|
||||
<img src="./donate.png">
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 198 KiB |
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>com.softdev.system</groupId>
|
||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>2023</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>generator-web</artifactId>
|
||||
@@ -17,7 +17,6 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -37,12 +36,17 @@
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>-->
|
||||
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>-->
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.softdev.system.generator.entity.ReturnT;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
// import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author zhengkai.blog.csdn.net
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.softdev.system.generator.config;
|
||||
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
// import jakarta.servlet.DispatcherType;
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -11,7 +14,6 @@ import org.springframework.http.converter.StringHttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.softdev.system.generator.config;
|
||||
|
||||
// import jakarta.servlet.*;
|
||||
// import jakarta.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -18,8 +21,8 @@ public class XssFilter implements Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper(
|
||||
(HttpServletRequest) request);
|
||||
|
||||
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest)request);
|
||||
chain.doFilter(xssRequest, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
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 javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.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 javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class GeneratorController {
|
||||
|
||||
//3.generate the code by freemarker templates with parameters . Freemarker根据参数和模板生成代码
|
||||
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());
|
||||
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;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author zhengkai.blog.csdn.net
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ReturnT extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -14,6 +14,9 @@ public class StringUtils {
|
||||
* @return
|
||||
*/
|
||||
public static String upperCaseFirst(String str) {
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return str;
|
||||
}
|
||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
|
||||
@@ -40,7 +43,7 @@ public class StringUtils {
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < underscoreName.length(); i++) {
|
||||
char ch = underscoreName.charAt(i);
|
||||
if ("_".charAt(0) == ch) {
|
||||
if ('_' == ch) {
|
||||
flag = true;
|
||||
} else {
|
||||
if (flag) {
|
||||
@@ -54,11 +57,76 @@ public class StringUtils {
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
public static boolean isNotNull(String str){
|
||||
return org.apache.commons.lang3.StringUtils.isNotEmpty(str);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
/**
|
||||
* 转 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* any str ==> lowerCamel
|
||||
*/
|
||||
public static String toLowerCamel(String str) {
|
||||
if (str == null || str.trim().isEmpty()) {
|
||||
return str;
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
char pre = '\0';
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char ch = str.charAt(i);
|
||||
if (ch == '-' || ch == '—' || ch == '_') {
|
||||
ch = '_';
|
||||
pre = ch;
|
||||
continue;
|
||||
}
|
||||
char ch2 = ch;
|
||||
if (pre == '_') {
|
||||
ch2 = Character.toUpperCase(ch);
|
||||
pre = ch2;
|
||||
} else if (pre >= 'A' && pre <= 'Z') {
|
||||
pre = ch;
|
||||
ch2 = Character.toLowerCase(ch);
|
||||
} else {
|
||||
pre = ch;
|
||||
}
|
||||
result.append(ch2);
|
||||
}
|
||||
|
||||
return lowerCaseFirst(result.toString());
|
||||
}
|
||||
|
||||
public static boolean isNotNull(String str) {
|
||||
return org.apache.commons.lang3.StringUtils.isNotEmpty(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.softdev.system.generator.util;
|
||||
|
||||
import com.softdev.system.generator.util.mysqlJavaTypeUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.softdev.system.generator.entity.ClassInfo;
|
||||
import com.softdev.system.generator.entity.FieldInfo;
|
||||
import com.softdev.system.generator.entity.NonCaseString;
|
||||
import com.softdev.system.generator.entity.ParamInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -34,7 +32,7 @@ public class TableParseUtil {
|
||||
public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
|
||||
throws IOException {
|
||||
//process the param
|
||||
String tableSql = paramInfo.getTableSql();
|
||||
NonCaseString tableSql = NonCaseString.of(paramInfo.getTableSql());
|
||||
String nameCaseType = MapUtil.getString(paramInfo.getOptions(),"nameCaseType");
|
||||
Boolean isPackageType = MapUtil.getBoolean(paramInfo.getOptions(),"isPackageType");
|
||||
|
||||
@@ -42,15 +40,20 @@ public class TableParseUtil {
|
||||
throw new CodeGenerateException("Table structure can not be empty. 表结构不能为空。");
|
||||
}
|
||||
//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"
|
||||
tableSql = tableSql.trim().replaceAll("\\\\n`", "").replaceAll("\\+", "").replaceAll("``", "`").replaceAll("\\\\", "");
|
||||
// table Name
|
||||
String tableName = null;
|
||||
if (tableSql.contains("TABLE") && tableSql.contains("(")) {
|
||||
tableName = tableSql.substring(tableSql.indexOf("TABLE") + 5, tableSql.indexOf("("));
|
||||
} else if (tableSql.contains("table") && tableSql.contains("(")) {
|
||||
tableName = tableSql.substring(tableSql.indexOf("table") + 5, tableSql.indexOf("("));
|
||||
int tableKwIx = tableSql.indexOf("TABLE"); // 包含判断和位置一次搞定
|
||||
if (tableKwIx > -1 && tableSql.contains("(")) {
|
||||
tableName = tableSql.substring(tableKwIx + 5, tableSql.indexOf("(")).get();
|
||||
} else {
|
||||
throw new CodeGenerateException("Table structure incorrect.表结构不正确。");
|
||||
}
|
||||
@@ -88,9 +91,11 @@ public class TableParseUtil {
|
||||
String classComment = null;
|
||||
//mysql是comment=,pgsql/oracle是comment on table,
|
||||
//2020-05-25 优化表备注的获取逻辑
|
||||
if (tableSql.contains("comment=") || tableSql.contains("comment on table")) {
|
||||
String classCommentTmp = (tableSql.contains("comment=")) ?
|
||||
tableSql.substring(tableSql.lastIndexOf("comment=") + 8).trim() : tableSql.substring(tableSql.lastIndexOf("comment on table") + 17).trim();
|
||||
if (tableSql.containsAny("comment=", "comment on table")) {
|
||||
int ix = tableSql.lastIndexOf("comment=");
|
||||
String classCommentTmp = (ix > -1) ?
|
||||
tableSql.substring(ix + 8).trim().get() :
|
||||
tableSql.substring(tableSql.lastIndexOf("comment on table") + 17).trim().get();
|
||||
if (classCommentTmp.contains("`")) {
|
||||
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf("`") + 1);
|
||||
classCommentTmp = classCommentTmp.substring(0, classCommentTmp.indexOf("`"));
|
||||
@@ -109,7 +114,7 @@ public class TableParseUtil {
|
||||
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,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
||||
String commentPattenStr1 = "comment `(.*?)\\`";
|
||||
@@ -149,7 +154,8 @@ public class TableParseUtil {
|
||||
if (fieldLineList.length > 0) {
|
||||
int i = 0;
|
||||
//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
||||
for (String columnLine : fieldLineList) {
|
||||
for (String columnLine0 : fieldLineList) {
|
||||
NonCaseString columnLine = NonCaseString.of(columnLine0);
|
||||
i++;
|
||||
columnLine = columnLine.replaceAll("\n", "").replaceAll("\t", "").trim();
|
||||
// `userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
@@ -158,13 +164,10 @@ public class TableParseUtil {
|
||||
// 2019-2-22 zhengkai 要在条件中使用复杂的表达式
|
||||
// 2019-4-29 zhengkai 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )
|
||||
// 2020-10-20 zhengkai 优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)
|
||||
boolean specialFlag = (!columnLine.contains("key ") && !columnLine.contains("constraint") && !columnLine.contains("using") && !columnLine.contains("unique ")
|
||||
&& !(columnLine.contains("primary ") && columnLine.indexOf("storage") + 3 > columnLine.indexOf("("))
|
||||
&& !columnLine.contains("fulltext ") && !columnLine.contains("index ")
|
||||
&& !columnLine.contains("pctincrease")
|
||||
&& !columnLine.contains("buffer_pool") && !columnLine.contains("tablespace")
|
||||
&& !(columnLine.contains("primary ") && i > 3));
|
||||
if (specialFlag) {
|
||||
// 2023-8-27 L&J 改用工具方法判断, 且修改变量名(非特殊标识), 方法抽取
|
||||
boolean notSpecialFlag = isNotSpecialColumnLine(columnLine, i);
|
||||
|
||||
if (notSpecialFlag) {
|
||||
//如果是oracle的number(x,x),可能出现最后分割残留的,x),这里做排除处理
|
||||
if (columnLine.length() < 5) {
|
||||
continue;
|
||||
@@ -174,7 +177,7 @@ public class TableParseUtil {
|
||||
columnLine = columnLine.replaceAll("`", " ").replaceAll("\"", " ").replaceAll("'", "").replaceAll(" ", " ").trim();
|
||||
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
||||
try {
|
||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
||||
columnName = columnLine.substring(0, columnLine.indexOf(" ")).get();
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
System.out.println("err happened: " + columnLine);
|
||||
throw e;
|
||||
@@ -182,16 +185,15 @@ public class TableParseUtil {
|
||||
|
||||
// field Name
|
||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||
// 2023-8-27 L&J 支持原始列名任意命名风格, 不依赖用户是否输入下划线
|
||||
String fieldName = null;
|
||||
if (ParamInfo.NAME_CASE_TYPE.CAMEL_CASE.equals(nameCaseType)) {
|
||||
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||
if (fieldName.contains("_")) {
|
||||
fieldName = fieldName.replaceAll("_", "");
|
||||
}
|
||||
// 2024-1-27 L&J 适配任意(maybe)原始风格转小写驼峰
|
||||
fieldName = StringUtils.toLowerCamel(columnName);
|
||||
} 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)) {
|
||||
fieldName = StringUtils.lowerCaseFirst(columnName.toUpperCase());
|
||||
fieldName = StringUtils.toUnderline(columnName.toUpperCase(), true);
|
||||
} else {
|
||||
fieldName = columnName;
|
||||
}
|
||||
@@ -228,12 +230,12 @@ public class TableParseUtil {
|
||||
while (columnCommentMatcher.find()) {
|
||||
String columnCommentTmp = columnCommentMatcher.group();
|
||||
//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();
|
||||
}
|
||||
} else if (columnLine.contains(" comment")) {
|
||||
//20200518 zhengkai 修复包含comment关键字的问题
|
||||
String commentTmp = columnLine.substring(columnLine.lastIndexOf("comment") + 7).trim();
|
||||
String commentTmp = columnLine.substring(columnLine.lastIndexOf("comment") + 7).trim().get();
|
||||
// '用户ID',
|
||||
if (commentTmp.contains("`") || commentTmp.indexOf("`") != commentTmp.lastIndexOf("`")) {
|
||||
commentTmp = commentTmp.substring(commentTmp.indexOf("`") + 1, commentTmp.lastIndexOf("`"));
|
||||
@@ -275,6 +277,24 @@ public class TableParseUtil {
|
||||
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生成类信息
|
||||
*
|
||||
|
||||
@@ -47,7 +47,7 @@ spring:
|
||||
#mvc:
|
||||
# static-path-pattern: /statics/**
|
||||
OEM:
|
||||
version: 2023.1
|
||||
version: 2024.4
|
||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||
title: JAVA在线代码生成
|
||||
|
||||
@@ -47,7 +47,7 @@ spring:
|
||||
#mvc:
|
||||
# static-path-pattern: /statics/**
|
||||
OEM:
|
||||
version: 2023.1
|
||||
version: 2024.4
|
||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||
title: JAVA代码生成平台
|
||||
|
||||
@@ -47,7 +47,7 @@ spring:
|
||||
#mvc:
|
||||
# static-path-pattern: /statics/**
|
||||
OEM:
|
||||
version: 2023.1
|
||||
version: 2024.4
|
||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||
title: JAVA在线代码生成
|
||||
|
||||
@@ -36,6 +36,9 @@ const vm = new Vue({
|
||||
" 'user_name' varchar(255) NOT NULL COMMENT '用户名',\n" +
|
||||
" 'status' tinyint(1) 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" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'",
|
||||
options: {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version": "20201222"}
|
||||
{"version": "20231022"}
|
||||
@@ -271,5 +271,25 @@
|
||||
"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> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3,31 +3,31 @@
|
||||
<!--#################-->
|
||||
|
||||
<!--jquery | vue | element-ui | axios-->
|
||||
<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/element-ui/2.15.0/index.min.js"></script>
|
||||
<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.net/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/vue/2.6.12/vue.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/element-ui/2.15.14/index.min.js"></script>
|
||||
<link rel="stylesheet" href="//cdn.staticfile.net/element-ui/2.15.0/theme-chalk/index.min.css">
|
||||
<script src="//cdn.staticfile.net/axios/0.1.0/axios.min.js"></script>
|
||||
|
||||
<script src="${request.contextPath}/statics/js/common.js"></script>
|
||||
<link rel="stylesheet" href="${request.contextPath}/statics/css/main.css">
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdn.staticfile.org/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
<!-- import codemirror -->
|
||||
<script src="//cdn.staticfile.org/codemirror/5.59.1/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/5.59.1/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/5.59.1/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/5.59.1/theme/idea.min.css">
|
||||
<script src="//cdn.staticfile.net/codemirror/6.65.7/codemirror.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/codemirror/6.65.7/mode/sql/sql.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/codemirror/6.65.7/mode/xml/xml.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/codemirror/6.65.7/mode/clike/clike.min.js"></script>
|
||||
<script src="//cdn.staticfile.net/codemirror/6.65.7/mode/javascript/javascript.min.js"></script>
|
||||
<link rel="stylesheet" href="//cdn.staticfile.net/codemirror/6.65.7/codemirror.min.css">
|
||||
<link rel="stylesheet" href="//cdn.staticfile.net/codemirror/6.65.7/theme/idea.min.css">
|
||||
|
||||
<!--bootsrap -->
|
||||
<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/admin-lte/2.3.7/css/AdminLTE.min.css">
|
||||
<link rel="stylesheet" href="//cdn.staticfile.net/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="//cdn.staticfile.net/admin-lte/2.3.11/css/AdminLTE.min.css">
|
||||
27
generator-web/src/test/java/FooTest.java
Normal file
27
generator-web/src/test/java/FooTest.java
Normal file
@@ -0,0 +1,27 @@
|
||||
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));
|
||||
|
||||
System.out.println(StringUtils.underlineToCamelCase("CREATE_TIME"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.softdev.system.generator.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class StringUtilsTest {
|
||||
|
||||
@Test
|
||||
public void toLowerCamel() {
|
||||
System.out.println(StringUtils.toLowerCamel("hello_world"));
|
||||
System.out.println(StringUtils.toLowerCamel("HELLO_WO-RLD-IK"));
|
||||
System.out.println(StringUtils.toLowerCamel("HELLO_WORLD-IKabc"));
|
||||
System.out.println(StringUtils.toLowerCamel("HELLO-WORLD-IKabc"));
|
||||
System.out.println(StringUtils.toLowerCamel("HELLO-123WORLD-IKabc"));
|
||||
System.out.println(StringUtils.toLowerCamel("helloWorldOKla"));
|
||||
assertEquals("helloWorldChina", StringUtils.toLowerCamel("hello_-_world-cHina"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upperCaseFirstShouldReturnStringWithFirstLetterCapitalized() {
|
||||
assertEquals("Hello", StringUtils.upperCaseFirst("hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upperCaseFirstShouldReturnEmptyStringWhenInputIsEmpty() {
|
||||
assertEquals("", StringUtils.upperCaseFirst(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lowerCaseFirstShouldReturnStringWithFirstLetterLowercased() {
|
||||
assertEquals("hello", StringUtils.lowerCaseFirst("Hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lowerCaseFirstShouldReturnEmptyStringWhenInputIsEmpty() {
|
||||
assertEquals("", StringUtils.lowerCaseFirst(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void underlineToCamelCaseShouldReturnCamelCaseString() {
|
||||
assertEquals("helloWorld", StringUtils.underlineToCamelCase("hello_world"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void underlineToCamelCaseShouldReturnEmptyStringWhenInputIsEmpty() {
|
||||
assertEquals("", StringUtils.underlineToCamelCase(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toUnderlineShouldReturnUnderlinedString() {
|
||||
assertEquals("hello_world", StringUtils.toUnderline("helloWorld", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toUnderlineShouldReturnEmptyStringWhenInputIsEmpty() {
|
||||
assertEquals("", StringUtils.toUnderline("", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toCamelShouldReturnCamelCaseString() {
|
||||
assertEquals("helloWorld", StringUtils.toLowerCamel("hello_world"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toCamelShouldReturnEmptyStringWhenInputIsEmpty() {
|
||||
assertEquals("", StringUtils.toLowerCamel(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotNullShouldReturnTrueWhenStringIsNotEmpty() {
|
||||
assertTrue(StringUtils.isNotNull("hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotNullShouldReturnFalseWhenStringIsEmpty() {
|
||||
assertFalse(StringUtils.isNotNull(""));
|
||||
}
|
||||
}
|
||||
15
pom.xml
15
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.softdev.system</groupId>
|
||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>2023</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
@@ -23,7 +23,7 @@
|
||||
<!-- 指定编码 -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- 指定jdk版本 -->
|
||||
<java.version>1.8</java.version>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -49,9 +49,16 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
<version>2.0.34</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>
|
||||
<scope>provided</scope>
|
||||
</dependency> -->
|
||||
<!-- 支持 @ConfigurationProperties 注解 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -124,7 +131,7 @@
|
||||
<repository>
|
||||
<id>alimaven</id>
|
||||
<name>aliyun maven</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
BIN
site_analysis-2024.png
Normal file
BIN
site_analysis-2024.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 239 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 147 KiB |
Reference in New Issue
Block a user