mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-05-08 22:37:27 +08:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60d227a416 | ||
|
|
8794d1e51d | ||
|
|
5397cd1221 | ||
|
|
6d1f29b17c | ||
|
|
48054f3a6b | ||
|
|
8515dd3110 | ||
|
|
64fbaade24 | ||
|
|
412aa510d0 | ||
|
|
536ab42ec1 | ||
|
|
3af7114c7f | ||
|
|
b447d98423 | ||
|
|
068472d8cb | ||
|
|
e008e4df4e | ||
|
|
17d668ab87 | ||
|
|
fc271338c6 | ||
|
|
46110ee55f | ||
|
|
8f4e09d01a | ||
|
|
d1062f1622 | ||
|
|
45643663bd | ||
|
|
bc123b8f27 | ||
|
|
107c1035e5 | ||
|
|
37e83ef76c | ||
|
|
781a7ff4ca | ||
|
|
a658ff5a0b | ||
|
|
aac82f2109 | ||
|
|
e968a3bfe1 | ||
|
|
cffaac2508 | ||
|
|
69a0dede9b | ||
|
|
732dd246cb | ||
|
|
d3820a2552 | ||
|
|
7e93e91478 | ||
|
|
aa38125294 | ||
|
|
adab6d7809 | ||
|
|
dac7d20eb8 | ||
|
|
482e004978 | ||
|
|
94a424ac11 | ||
|
|
f6844ee7c5 | ||
|
|
a1fc04af8c | ||
|
|
efef2aefc4 | ||
|
|
f88a8c2940 | ||
|
|
1144a2137e | ||
|
|
1c6efb400b | ||
|
|
371ff03a5f | ||
|
|
ec949f97e0 | ||
|
|
78975fc86d | ||
|
|
b387240235 | ||
|
|
ab705bfa2f |
5
@install.cmd
Normal file
5
@install.cmd
Normal file
@@ -0,0 +1,5 @@
|
||||
REM JDK must equal or more than : 11
|
||||
java -version
|
||||
REM maven installing libraries
|
||||
mvn clean compile
|
||||
pause
|
||||
4
@run.cmd
Normal file
4
@run.cmd
Normal file
@@ -0,0 +1,4 @@
|
||||
java -jar "./generator-web/target/generator-web-3.0.jar"
|
||||
pause
|
||||
mvn clean compile package
|
||||
pause
|
||||
175
README.md
175
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,20 +16,40 @@
|
||||
>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三种生成模式
|
||||
- 支持`DDL SQL`/`INSERT SQL`/`SIMPLE JSON`三种生成模式
|
||||
- `自动记忆`最近生成的内容,最多保留9个
|
||||
- 提供众多`通用模板`,易于使用,复制粘贴加简单修改即可完成CRUD操作
|
||||
- 支持`特殊字符`模板(`#`请用`井`代替;`$`请用`¥`代替)
|
||||
@@ -39,76 +59,78 @@
|
||||
- 可设置`表名前缀`,例如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
|
||||
|更新日期|更新内容|
|
||||
|:----|:----|
|
||||
|2021.08.07|新增当前模板保持功能,重新生成代码后依然会保持在当前选择模板。<br>新增renren-fast模板。|
|
||||
|2021.08.05|解决 update 方法语法错误;调整部分语句避免sonarLint告警(感谢@Henry586的PR);<br>add swagger-yml.ftl(感谢@fuuqiu的PR);<br>支持common-mapper&修复entity和plusentity的swagger引包错误(感谢@chentianming11的PR)|
|
||||
|2021.03.24|修复Mybatis.XML中缺失test=关键字问题。(感谢@BWHN/YUEHUI的反馈)。|
|
||||
|2021.01.18|OEM信息优化,支持多配置文件模式,支持在application*.yml自定义信息,以及切换local/cdn模式。|
|
||||
|2021.01.17|生成后自动trim掉前后空格输出。<br>完善ReadMe文档。<br>优化云CDN引入部分。<br>优化returnUtil部分。<br>表明前缀选项(感谢@wwlg的建议)。 <br>是否带字段注释设置(感谢@fengpojian的建议)。<br>优化Mybatis的''!=判断(感谢@zhongsb的建议)。<br>Mybatis-Plus增加Service层(感谢@yf466532479的建议)。 |
|
||||
|2021.01.16|全新3.0版本:<br>一、前端半vue半js化,更多动态加载项。<br>二、支持更多生成设置,优化生成场景。<br>三、js导入支持本地/CDN模式,支持断网环境轻松使用。|
|
||||
|2020.10.22|1.tinyint多加一个Short类型转换(感谢@wttHero的建议)|
|
||||
|2020.10.20|1.修复mapper2 insert代码问题(感谢@mXiaoWan的PR)<br>2.优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)。<br>3.新增日期类型的转换选择(感谢@qingkediguo的建议)。<br>4.新增是否包装类型的转换选择(感谢@gzlicanyi的建议)。|
|
||||
|2020.06.28|优化Util下的BeanUtil,支持更多map.put的操作。整合CRUD模板到SQL(CRUD)模板。|
|
||||
|2020.06.21|修复FreemarkerUtil的Path问题导致JAR包运行时无法获取template的问题。|
|
||||
|2020.05.25|1.一些fix,关于封装工具类以及layui模板优化等.<br> 2.优化表备注的获取逻辑.<br> 3.生成时间格式改为yyyy-MM-dd,移除具体的时间,只保留日期|
|
||||
|2020.05.22|1.新增insert-sql模式,支持对"insert into table (xxx) values (xxx)"语句进行处理,生成java代码(感谢三叔的建议).|
|
||||
|2020.05.17|1.代码重构!异常处理优化,Freemarker相关工具类优化,简化模板生成部分,通过template.json来配置需要生成的模板,不需要配置java文件.<br> 2.修复包含comment关键字时注释无法识别的问题.(感谢@1nchaos的反馈).<br> 3.赞赏优化,感谢大家的赞赏.<br> 4.新增mapper2(Mybatis-Annotation模板)(感谢@baisi525和@CHKEGit的建议).|
|
||||
|2020.05.03|1.优化对特殊字符的处理,对于包含#和$等特殊字符的,在模板使用井和¥代替便可,escapeString方法会自动处理.<br> 2.优化mybatisplus实体类相关(感谢@chunchengmeigui的反馈).<br> 3.修优化对所有类型的判断(感谢@cnlw的反馈).<br> 4.移除swagger-entity,该功能已经包含在‘swagger-ui’的下拉选项中 <br> 5.升级hutool和lombok版本|
|
||||
|2020.03.06|1.提交一套layuimini+mybatisplus的模板.<br> 2.修复mybatisplus一些相关问题. |
|
||||
|2020.02.06|1.新增历史记录功能,自动保存最近生成的对象.<br> 2.新增swagger开关选项和修复@Column带name参数(感谢@liuyu-struggle的建议).<br> 3.去除mybatis模板中的方括号[]和修改模板里的类注释样式(感谢@gaohanghang的PR)|
|
||||
|2019.12.29|1.修复bejson安全防护策略拦截问题(感谢@liangbintao和@1808083642的反馈).<br> 2.优化字段名含date字符串的处理(感谢@smilexzh的反馈).<br> 3.控制台动态输出项目访问地址(感谢@gaohanghang的提交)|
|
||||
|2019.11.28|1.修复支持string-copy导致的以n结尾的字母不显示问题.<br> 2.jpa-entity新增swagger@ApiModel@ApiModelProperty注解和SQL字段@Column注解(感谢@yjq907的建议) |
|
||||
|2019.11.26|1.springboot2内置tomcat更换为性能更强大的undertow.<br> 2.修复tinyintTransType参数丢失问题 |
|
||||
|2019.11.24|1.java代码结构优化.<br> 2.新增简单的json生成模式.<br> 3.新增简单的正则表达式匹配模式(感谢@ydq的贡献).<br> 4.新增对复制String代码中的乱SQL代码的支持 5.优化对JSON的父子节点/处理,JSONObject和JSONArray节点处理,子节点缺失'{'头处理|
|
||||
|2019.11.23|1.移除频繁出错和被过滤的layer,改为jquery-toast.<br> 2.Util功能优化,新增json和xml.|
|
||||
|2019.11.16|优化对primary关键字的处理(感谢@liujiansgit的反馈). |
|
||||
|2019.11.15|1.添加tinyint类型转换(感谢@lixiliang&@liujiansgit的Suggestion).<br> 2.添加一键复制功能(感谢@gaohanghang的Suggestion).<br> 3.Mybatis的insert增加keyProperty="id"用于返回自增id(感谢@88888888888888888888的Suggestion).<br> 4.优化date类型的支持(感谢@SteveLsf的反馈).<br> 5.其他一些优化. |
|
||||
|2019.10.15|修复jdbcTemplates中insert语句第一个字段丢失的问题. |
|
||||
|2019.09.15|1.添加对象getset模板.<br> 2.添加sql模板.<br> 3.启动类添加日志输出,方便项目使用(感谢@gaohanghang 的pull request) |
|
||||
|2019.09.10|优化以及更新Maven依赖,减少打包体积.<br> 1.修复mapper接口load方法,但是xml中方法不匹配问题.<br> 2.移除mapper中CRUD时的@param 注解,会影响xml的解析(感谢@caojiantao的反馈).<br> 3.优化MyBatis的xml文件对Oracle的支持.(感谢@wylove1992的反馈).<br> 4.新增对boolean的处理(感谢@violinxsc的反馈)以及优化tinyint类型生成boolean类型问题(感谢@hahaYhui的反馈) |
|
||||
|2019.09.09|添加是否下划线转换为驼峰的选择(感谢@youngking28 的pull request).|
|
||||
|2019.05.18|1.优化注释.<br> 2.修改 mybatis模板中 controller注解.<br> 3.修改 mybatis模板中 dao文件使用为 mapper文件.<br> 4.修改 mybatis模板中 service实现类中的一个 bug.<br> 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper(感谢@unqin的pull request)|
|
||||
|2019.05.11|优化mybatis模块的dao和xml模板,修改dao接口注解为@Repository,所有dao参数改为包装类,删除update语句最后的UpdateTime = NOW(),修改dao接口文件的方法注释使其更符合javaDoc的标准,修改insert语句增加插入行主键的返回,修改load的方法名为selectByPrimaryKey,修改xml的update语句新增动态if判空,修改xml的insert语句新增动态插入判空,更符合mybatisGenerator标准(感谢@Archer-Wen的贡献 ).|
|
||||
|2019.04.29|新增返回封装工具类设置.<br> 优化对oracle注释comment on column的支持(感谢@liukex反馈).<br> 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 ).|
|
||||
|2019.02.11|提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request).|
|
||||
|2019.02.10|实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request).|
|
||||
|2019.01.06|修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈).<br> 修复JdbcTemplates模板两处错误(感谢@everflourish的反馈).|
|
||||
|2018.12.12|首页UI优化.<br> 新增MybatisPlus模块(感谢@三叔同事的建议).<br> 修复作者名和包名获取失败问题(感谢@Yanch1994的反馈).|
|
||||
|2018.11.22|优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导).|
|
||||
|2018.11.08|修复非字段描述"KEY FK_xxxx (xxxx)"导致生成KEY字段情况(感谢@tornadoorz反馈).|
|
||||
|2018.10.18|支持double(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈).|
|
||||
|2018.10.10|CDN变更,修复CDN不稳定导致网页js报错问题.|
|
||||
|2018.10.03|新增element-ui/bootstrap生成.|
|
||||
|2018.10.02|修复公共CDN之Layer.js404问题,导致项目无法生成.|
|
||||
|2018.09.27|优化COMMENT提取逻辑,支持多种复杂情况的注释(感谢@raodeming的反馈).|
|
||||
|2018.09.26|全新BeetlSQL模块,以及一些小细节优化(感谢@三叔同事的建议).|
|
||||
|2018.09.25|优化SQL表和字段备注的推断,包括pgsql/oralce的comment on column/table情况处理等.|
|
||||
|2018.09.18|优化SQL类型推断.<br> 优化PrimaryKey判断.<br> 修复jpacontroller中Repository拼写错误问题.|
|
||||
|2018.09.17|全新首页,静态文件全部采用CDN.新增jdbcTemplate模块.|
|
||||
|2018.09.16|1.优化oracle支持,优化DDL语句中"或者'或者空格的支持.<br> 2.补充char/clob/blob/json等类型,如果类型未知,默认为String.|
|
||||
|2018.09.15|新增Swagger-UI模板.修复一些命名和导入问题.JPA的Entity默认第一个字段为Id,如果不是请手工修改.|
|
||||
|2018.09.13|修复字段没有描述以及类型为DATE型导致的问题.新增JPA的Controller模板.|
|
||||
|2018.08.31|初始化项目.新增JPA系列Entity+Repository模板.|
|
||||
| 更新日期 | 更新内容 |
|
||||
|:-----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 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,添加批处理以便直接构建或运行项目。 |
|
||||
| 2022.02.10 | 更新springboot、fastjson、lombok依赖(感谢@Abbykawai的建议)。 |
|
||||
| 2022.02.09 | 新增JPA-STARP模板(感谢@starplatinum3的贡献)。 |
|
||||
| 2022.01.11 | 优化mybatis的mapper文件生成(感谢@chendong的贡献)。 |
|
||||
| 2021.10.31 | 优化当有索引和额外的换行时的解析逻辑(感谢@feitian124的贡献)。<br>修复部分模板参数不对应(感谢@Thixiaoxiao的贡献)。<br>新增cookie记录所需配置字段逻辑,避免重复配置(感谢@Thixiaoxiao的贡献)。 |
|
||||
| 2021.08.07 | 新增当前模板保持功能,重新生成代码后依然会保持在当前选择模板。<br>新增renren-fast模板。 |
|
||||
| 2021.08.05 | 解决 update 方法语法错误;调整部分语句避免sonarLint告警(感谢@Henry586的PR);<br>add swagger-yml.ftl(感谢@fuuqiu的PR);<br>支持common-mapper&修复entity和plusentity的swagger引包错误(感谢@chentianming11的PR) |
|
||||
| 2021.03.24 | 修复Mybatis.XML中缺失test=关键字问题。(感谢@BWHN/YUEHUI的反馈)。 |
|
||||
| 2021.01.18 | OEM信息优化,支持多配置文件模式,支持在application*.yml自定义信息,以及切换local/cdn模式。 |
|
||||
| 2021.01.17 | 生成后自动trim掉前后空格输出。<br>完善ReadMe文档。<br>优化云CDN引入部分。<br>优化returnUtil部分。<br>表明前缀选项(感谢@wwlg的建议)。 <br>是否带字段注释设置(感谢@fengpojian的建议)。<br>优化Mybatis的''!=判断(感谢@zhongsb的建议)。<br>Mybatis-Plus增加Service层(感谢@yf466532479的建议)。 |
|
||||
| 2021.01.16 | 全新3.0版本:<br>一、前端半vue半js化,更多动态加载项。<br>二、支持更多生成设置,优化生成场景。<br>三、js导入支持本地/CDN模式,支持断网环境轻松使用。 |
|
||||
| 2020.10.22 | 1.tinyint多加一个Short类型转换(感谢@wttHero的建议) |
|
||||
| 2020.10.20 | 1.修复mapper2 insert代码问题(感谢@mXiaoWan的PR)<br>2.优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)。<br>3.新增日期类型的转换选择(感谢@qingkediguo的建议)。<br>4.新增是否包装类型的转换选择(感谢@gzlicanyi的建议)。 |
|
||||
| 2020.06.28 | 优化Util下的BeanUtil,支持更多map.put的操作。整合CRUD模板到SQL(CRUD)模板。 |
|
||||
| 2020.06.21 | 修复FreemarkerUtil的Path问题导致JAR包运行时无法获取template的问题。 |
|
||||
| 2020.05.25 | 1.一些fix,关于封装工具类以及layui模板优化等.<br> 2.优化表备注的获取逻辑.<br> 3.生成时间格式改为yyyy-MM-dd,移除具体的时间,只保留日期 |
|
||||
| 2020.05.22 | 1.新增insert-sql模式,支持对"insert into table (xxx) values (xxx)"语句进行处理,生成java代码(感谢三叔的建议). |
|
||||
| 2020.05.17 | 1.代码重构!异常处理优化,Freemarker相关工具类优化,简化模板生成部分,通过template.json来配置需要生成的模板,不需要配置java文件.<br> 2.修复包含comment关键字时注释无法识别的问题.(感谢@1nchaos的反馈).<br> 3.赞赏优化,感谢大家的赞赏.<br> 4.新增mapper2(Mybatis-Annotation模板)(感谢@baisi525和@CHKEGit的建议). |
|
||||
| 2020.05.03 | 1.优化对特殊字符的处理,对于包含#和$等特殊字符的,在模板使用井和¥代替便可,escapeString方法会自动处理.<br> 2.优化mybatisplus实体类相关(感谢@chunchengmeigui的反馈).<br> 3.修优化对所有类型的判断(感谢@cnlw的反馈).<br> 4.移除swagger-entity,该功能已经包含在‘swagger-ui’的下拉选项中 <br> 5.升级hutool和lombok版本 |
|
||||
| 2020.03.06 | 1.提交一套layuimini+mybatisplus的模板.<br> 2.修复mybatisplus一些相关问题. |
|
||||
| 2020.02.06 | 1.新增历史记录功能,自动保存最近生成的对象.<br> 2.新增swagger开关选项和修复@Column带name参数(感谢@liuyu-struggle的建议).<br> 3.去除mybatis模板中的方括号[]和修改模板里的类注释样式(感谢@gaohanghang的PR) |
|
||||
| 2019.12.29 | 1.修复bejson安全防护策略拦截问题(感谢@liangbintao和@1808083642的反馈).<br> 2.优化字段名含date字符串的处理(感谢@smilexzh的反馈).<br> 3.控制台动态输出项目访问地址(感谢@gaohanghang的提交) |
|
||||
| 2019.11.28 | 1.修复支持string-copy导致的以n结尾的字母不显示问题.<br> 2.jpa-entity新增swagger@ApiModel@ApiModelProperty注解和SQL字段@Column注解(感谢@yjq907的建议) |
|
||||
| 2019.11.26 | 1.springboot2内置tomcat更换为性能更强大的undertow.<br> 2.修复tinyintTransType参数丢失问题 |
|
||||
| 2019.11.24 | 1.java代码结构优化.<br> 2.新增简单的json生成模式.<br> 3.新增简单的正则表达式匹配模式(感谢@ydq的贡献).<br> 4.新增对复制String代码中的乱SQL代码的支持 5.优化对JSON的父子节点/处理,JSONObject和JSONArray节点处理,子节点缺失'{'头处理 |
|
||||
| 2019.11.23 | 1.移除频繁出错和被过滤的layer,改为jquery-toast.<br> 2.Util功能优化,新增json和xml. |
|
||||
| 2019.11.16 | 优化对primary关键字的处理(感谢@liujiansgit的反馈). |
|
||||
| 2019.11.15 | 1.添加tinyint类型转换(感谢@lixiliang&@liujiansgit的Suggestion).<br> 2.添加一键复制功能(感谢@gaohanghang的Suggestion).<br> 3.Mybatis的insert增加keyProperty="id"用于返回自增id(感谢@88888888888888888888的Suggestion).<br> 4.优化date类型的支持(感谢@SteveLsf的反馈).<br> 5.其他一些优化. |
|
||||
| 2019.10.15 | 修复jdbcTemplates中insert语句第一个字段丢失的问题. |
|
||||
| 2019.09.15 | 1.添加对象getset模板.<br> 2.添加sql模板.<br> 3.启动类添加日志输出,方便项目使用(感谢@gaohanghang 的pull request) |
|
||||
| 2019.09.10 | 优化以及更新Maven依赖,减少打包体积.<br> 1.修复mapper接口load方法,但是xml中方法不匹配问题.<br> 2.移除mapper中CRUD时的@param 注解,会影响xml的解析(感谢@caojiantao的反馈).<br> 3.优化MyBatis的xml文件对Oracle的支持.(感谢@wylove1992的反馈).<br> 4.新增对boolean的处理(感谢@violinxsc的反馈)以及优化tinyint类型生成boolean类型问题(感谢@hahaYhui的反馈) |
|
||||
| 2019.09.09 | 添加是否下划线转换为驼峰的选择(感谢@youngking28 的pull request). |
|
||||
| 2019.05.18 | 1.优化注释.<br> 2.修改 mybatis模板中 controller注解.<br> 3.修改 mybatis模板中 dao文件使用为 mapper文件.<br> 4.修改 mybatis模板中 service实现类中的一个 bug.<br> 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper(感谢@unqin的pull request) |
|
||||
| 2019.05.11 | 优化mybatis模块的dao和xml模板,修改dao接口注解为@Repository,所有dao参数改为包装类,删除update语句最后的UpdateTime = NOW(),修改dao接口文件的方法注释使其更符合javaDoc的标准,修改insert语句增加插入行主键的返回,修改load的方法名为selectByPrimaryKey,修改xml的update语句新增动态if判空,修改xml的insert语句新增动态插入判空,更符合mybatisGenerator标准(感谢@Archer-Wen的贡献 ). |
|
||||
| 2019.04.29 | 新增返回封装工具类设置.<br> 优化对oracle注释comment on column的支持(感谢@liukex反馈).<br> 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 ). |
|
||||
| 2019.02.11 | 提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request). |
|
||||
| 2019.02.10 | 实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request). |
|
||||
| 2019.01.06 | 修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈).<br> 修复JdbcTemplates模板两处错误(感谢@everflourish的反馈). |
|
||||
| 2018.12.12 | 首页UI优化.<br> 新增MybatisPlus模块(感谢@三叔同事的建议).<br> 修复作者名和包名获取失败问题(感谢@Yanch1994的反馈). |
|
||||
| 2018.11.22 | 优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导). |
|
||||
| 2018.11.08 | 修复非字段描述"KEY FK_xxxx (xxxx)"导致生成KEY字段情况(感谢@tornadoorz反馈). |
|
||||
| 2018.10.18 | 支持double(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈). |
|
||||
| 2018.10.10 | CDN变更,修复CDN不稳定导致网页js报错问题. |
|
||||
| 2018.10.03 | 新增element-ui/bootstrap生成. |
|
||||
| 2018.10.02 | 修复公共CDN之Layer.js404问题,导致项目无法生成. |
|
||||
| 2018.09.27 | 优化COMMENT提取逻辑,支持多种复杂情况的注释(感谢@raodeming的反馈). |
|
||||
| 2018.09.26 | 全新BeetlSQL模块,以及一些小细节优化(感谢@三叔同事的建议). |
|
||||
| 2018.09.25 | 优化SQL表和字段备注的推断,包括pgsql/oralce的comment on column/table情况处理等. |
|
||||
| 2018.09.18 | 优化SQL类型推断.<br> 优化PrimaryKey判断.<br> 修复jpacontroller中Repository拼写错误问题. |
|
||||
| 2018.09.17 | 全新首页,静态文件全部采用CDN.新增jdbcTemplate模块. |
|
||||
| 2018.09.16 | 1.优化oracle支持,优化DDL语句中"或者'或者空格的支持.<br> 2.补充char/clob/blob/json等类型,如果类型未知,默认为String. |
|
||||
| 2018.09.15 | 新增Swagger-UI模板.修复一些命名和导入问题.JPA的Entity默认第一个字段为Id,如果不是请手工修改. |
|
||||
| 2018.09.13 | 修复字段没有描述以及类型为DATE型导致的问题.新增JPA的Controller模板. |
|
||||
| 2018.08.31 | 初始化项目.新增JPA系列Entity+Repository模板. |
|
||||
|
||||
# ClassInfo/TableInfo
|
||||
|名称|说明|
|
||||
@@ -148,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,6 +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("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.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;
|
||||
@@ -173,101 +176,47 @@ public class TableParseUtil {
|
||||
String columnName = "";
|
||||
columnLine = columnLine.replaceAll("`", " ").replaceAll("\"", " ").replaceAll("'", "").replaceAll(" ", " ").trim();
|
||||
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
||||
try {
|
||||
columnName = columnLine.substring(0, columnLine.indexOf(" ")).get();
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
System.out.println("err happened: " + columnLine);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
columnLine = columnLine.substring(columnLine.indexOf("`") + 1).trim();
|
||||
|
||||
String mysqlType = columnLine.split("\\s+")[1];
|
||||
if(mysqlType.contains("(")){
|
||||
mysqlType = mysqlType.substring(0, mysqlType.indexOf("("));
|
||||
}
|
||||
//swagger class
|
||||
String swaggerClass = "string" ;
|
||||
if (columnLine.contains(" tinyint")) {
|
||||
swaggerClass = "integer";
|
||||
} else if (columnLine.contains(" int") || columnLine.contains(" smallint")) {
|
||||
swaggerClass = "integer";
|
||||
} else if (columnLine.contains(" bigint")) {
|
||||
swaggerClass = "integer";
|
||||
} else if (columnLine.contains(" float")) {
|
||||
swaggerClass = "number";
|
||||
} else if (columnLine.contains(" double")) {
|
||||
swaggerClass = "number";
|
||||
} else if (columnLine.contains(" boolean")) {
|
||||
swaggerClass = "boolean";
|
||||
if(mysqlJavaTypeUtil.getMysqlSwaggerTypeMap().containsKey(mysqlType)){
|
||||
swaggerClass = mysqlJavaTypeUtil.getMysqlSwaggerTypeMap().get(mysqlType);
|
||||
}
|
||||
// field class
|
||||
// int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
String fieldClass = Object.class.getSimpleName();
|
||||
String fieldClass = "String";
|
||||
//2018-9-16 zhengk 补充char/clob/blob/json等类型,如果类型未知,默认为String
|
||||
//2018-11-22 lshz0088 处理字段类型的时候,不严谨columnLine.contains(" int") 类似这种的,可在前后适当加一些空格之类的加以区分,否则当我的字段包含这些字符的时候,产生类型判断问题。
|
||||
//2020-05-03 MOSHOW.K.ZHENG 优化对所有类型的处理
|
||||
//2020-10-20 zhengkai 新增包装类型的转换选择
|
||||
if (columnLine.contains(" tinyint")) {
|
||||
//20191115 MOSHOW.K.ZHENG 支持对tinyint的特殊处理
|
||||
fieldClass = MapUtil.getString(paramInfo.getOptions(),"tinyintTransType");;
|
||||
} else if (columnLine.contains(" int") || columnLine.contains(" smallint")) {
|
||||
fieldClass = (isPackageType)?Integer.class.getSimpleName():"int";
|
||||
} else if (columnLine.contains(" bigint")) {
|
||||
fieldClass = (isPackageType)?Long.class.getSimpleName():"long";
|
||||
} else if (columnLine.contains(" float")) {
|
||||
fieldClass = (isPackageType)?Float.class.getSimpleName():"float";
|
||||
} else if (columnLine.contains(" double")) {
|
||||
fieldClass = (isPackageType)?Double.class.getSimpleName():"double";
|
||||
} else if (columnLine.contains(" time") || columnLine.contains(" date") || columnLine.contains(" datetime") || columnLine.contains(" timestamp")) {
|
||||
fieldClass = MapUtil.getString(paramInfo.getOptions(),"timeTransType");
|
||||
} else if (columnLine.contains(" varchar") || columnLine.contains(" text") || columnLine.contains(" char")
|
||||
|| columnLine.contains(" clob") || columnLine.contains(" blob") || columnLine.contains(" json")) {
|
||||
fieldClass = String.class.getSimpleName();
|
||||
} else if (columnLine.contains(" decimal") || columnLine.contains(" number")) {
|
||||
//2018-11-22 lshz0088 建议对number类型增加int,long,BigDecimal的区分判断
|
||||
//如果startKh大于等于0,则表示有设置取值范围
|
||||
int startKh = columnLine.indexOf("(");
|
||||
if (startKh >= 0) {
|
||||
int endKh = columnLine.indexOf(")", startKh);
|
||||
String[] fanwei = columnLine.substring(startKh + 1, endKh).split(",");
|
||||
//2019-1-5 zhengk 修复@arthaschan反馈的超出范围错误
|
||||
//System.out.println("fanwei"+ JSON.toJSONString(fanwei));
|
||||
// //number(20,6) fanwei["20","6"]
|
||||
// //number(0,6) fanwei["0","6"]
|
||||
// //number(20,0) fanwei["20","0"]
|
||||
// //number(20) fanwei["20"]
|
||||
//如果括号里是1位或者2位且第二位为0,则进行特殊处理。只有有小数位,都设置为BigDecimal。
|
||||
if ((fanwei.length > 1 && "0".equals(fanwei[1])) || fanwei.length == 1) {
|
||||
int length = Integer.parseInt(fanwei[0]);
|
||||
if (fanwei.length > 1) {
|
||||
length = Integer.valueOf(fanwei[1]);
|
||||
}
|
||||
//数字范围9位及一下用Integer,大的用Long
|
||||
if (length <= 9) {
|
||||
fieldClass = (isPackageType)?Integer.class.getSimpleName():"int";
|
||||
} else {
|
||||
fieldClass = (isPackageType)?Long.class.getSimpleName():"long";
|
||||
}
|
||||
} else {
|
||||
//有小数位数一律使用BigDecimal
|
||||
fieldClass = BigDecimal.class.getSimpleName();
|
||||
}
|
||||
} else {
|
||||
fieldClass = BigDecimal.class.getSimpleName();
|
||||
}
|
||||
} else if (columnLine.contains(" boolean")) {
|
||||
//20190910 MOSHOW.K.ZHENG 新增对boolean的处理(感谢@violinxsc的反馈)以及修复tinyint类型字段无法生成boolean类型问题(感谢@hahaYhui的反馈)
|
||||
fieldClass = (isPackageType)?Boolean.class.getSimpleName():"boolean";
|
||||
} else {
|
||||
fieldClass = String.class.getSimpleName();
|
||||
if(mysqlJavaTypeUtil.getMysqlJavaTypeMap().containsKey(mysqlType)){
|
||||
fieldClass = mysqlJavaTypeUtil.getMysqlJavaTypeMap().get(mysqlType);
|
||||
}
|
||||
|
||||
// field comment,MySQL的一般位于field行,而pgsql和oralce多位于后面。
|
||||
String fieldComment = null;
|
||||
if (tableSql.contains("comment on column") && (tableSql.contains("." + columnName + " is ") || tableSql.contains(".`" + columnName + "` is"))) {
|
||||
@@ -281,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("`"));
|
||||
@@ -328,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生成类信息
|
||||
*
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.softdev.system.generator.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lvyanpu
|
||||
*/
|
||||
public final class mysqlJavaTypeUtil {
|
||||
public static final HashMap<String, String> mysqlJavaTypeMap = new HashMap<String, String>();
|
||||
public static final HashMap<String, String> mysqlSwaggerTypeMap =new HashMap<String, String>();
|
||||
|
||||
static{
|
||||
mysqlJavaTypeMap.put("bigint","Long");
|
||||
mysqlJavaTypeMap.put("int","Integer");
|
||||
mysqlJavaTypeMap.put("tinyint","Integer");
|
||||
mysqlJavaTypeMap.put("smallint","Integer");
|
||||
mysqlJavaTypeMap.put("mediumint","Integer");
|
||||
mysqlJavaTypeMap.put("integer","Integer");
|
||||
//小数
|
||||
mysqlJavaTypeMap.put("float","Float");
|
||||
mysqlJavaTypeMap.put("double","Double");
|
||||
mysqlJavaTypeMap.put("decimal","Double");
|
||||
//bool
|
||||
mysqlJavaTypeMap.put("bit","Boolean");
|
||||
//字符串
|
||||
mysqlJavaTypeMap.put("char","String");
|
||||
mysqlJavaTypeMap.put("varchar","String");
|
||||
mysqlJavaTypeMap.put("tinytext","String");
|
||||
mysqlJavaTypeMap.put("text","String");
|
||||
mysqlJavaTypeMap.put("mediumtext","String");
|
||||
mysqlJavaTypeMap.put("longtext","String");
|
||||
//日期
|
||||
mysqlJavaTypeMap.put("date","Date");
|
||||
mysqlJavaTypeMap.put("datetime","Date");
|
||||
mysqlJavaTypeMap.put("timestamp","Date");
|
||||
|
||||
|
||||
mysqlSwaggerTypeMap.put("bigint","integer");
|
||||
mysqlSwaggerTypeMap.put("int","integer");
|
||||
mysqlSwaggerTypeMap.put("tinyint","integer");
|
||||
mysqlSwaggerTypeMap.put("smallint","integer");
|
||||
mysqlSwaggerTypeMap.put("mediumint","integer");
|
||||
mysqlSwaggerTypeMap.put("integer","integer");
|
||||
mysqlSwaggerTypeMap.put("boolean","boolean");
|
||||
mysqlSwaggerTypeMap.put("float","number");
|
||||
mysqlSwaggerTypeMap.put("double","number");
|
||||
mysqlSwaggerTypeMap.put("decimal","Double");
|
||||
}
|
||||
|
||||
public static HashMap<String, String> getMysqlJavaTypeMap() {
|
||||
return mysqlJavaTypeMap;
|
||||
}
|
||||
|
||||
public static HashMap<String, String> getMysqlSwaggerTypeMap() {
|
||||
return mysqlSwaggerTypeMap;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ spring:
|
||||
#mvc:
|
||||
# static-path-pattern: /statics/**
|
||||
OEM:
|
||||
version: 3.2
|
||||
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: 3.2
|
||||
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: 3.2
|
||||
version: 2024.4
|
||||
header: SQL转Java JPA、MYBATIS实现类代码生成平台
|
||||
keywords: sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现
|
||||
title: JAVA在线代码生成
|
||||
|
||||
@@ -41,4 +41,29 @@ window.confirm = function(msg, callback){
|
||||
//判断是否为空
|
||||
function isBlank(value) {
|
||||
return !value || !/\S/.test(value)
|
||||
}
|
||||
|
||||
function setCookie(key, val, expire_second) {
|
||||
var d = new Date();
|
||||
var expires ="";
|
||||
if (expire_second){
|
||||
d.setDate(d.getTime()+(expire_second*1000));
|
||||
expires='; expires=' + d.toGMTSring();
|
||||
}
|
||||
document.cookie = key + "="+ val + expires;
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
var data = "";
|
||||
if (document.cookie){
|
||||
var arr = document.cookie.split(';');
|
||||
for (var str of arr) {
|
||||
var temp = str.split("=")
|
||||
if (temp[0].replace(/(^\s*)/g,'') === name){
|
||||
data = unescape(temp[1]);
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -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: {
|
||||
@@ -123,6 +126,7 @@ const vm = new Vue({
|
||||
error("生成失败");
|
||||
return;
|
||||
}
|
||||
setAllCookie();
|
||||
//console.log(res.outputJson);
|
||||
vm.outputJson=res.outputJson;
|
||||
// console.log(vm.outputJson["bootstrap-ui"]);
|
||||
@@ -154,3 +158,41 @@ const vm = new Vue({
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 将所有 需要 保留历史纪录的字段写入Cookie中
|
||||
*/
|
||||
function setAllCookie() {
|
||||
var arr = list_key_need_load();
|
||||
for (var str of arr){
|
||||
setOneCookie(str);
|
||||
}
|
||||
}
|
||||
|
||||
function setOneCookie(key) {
|
||||
setCookie(key, vm.formData.options[key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将所有 历史纪录 重加载回页面
|
||||
*/
|
||||
function loadAllCookie() {
|
||||
//console.log(vm);
|
||||
var arr = list_key_need_load();
|
||||
for (var str of arr){
|
||||
loadOneCookie(str);
|
||||
}
|
||||
}
|
||||
|
||||
function loadOneCookie(key) {
|
||||
if (getCookie(key)!==""){
|
||||
vm.formData.options[key] = getCookie(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 所有 需要 纪录的 字段写入数组
|
||||
* @returns {[string]}
|
||||
*/
|
||||
function list_key_need_load() {
|
||||
return ["authorName","packageName","returnUtilSuccess","returnUtilFailure","ignorePrefix","tinyintTransType","timeTransType"];
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version": "20201222"}
|
||||
{"version": "20231022"}
|
||||
@@ -229,5 +229,67 @@
|
||||
"description": "rr-service"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "jpa-starp",
|
||||
"templates": [{
|
||||
"id": "101",
|
||||
"name": "starp-entity",
|
||||
"description": "entity"
|
||||
},
|
||||
{
|
||||
"id": "102",
|
||||
"name": "starp-repository",
|
||||
"description": "repository"
|
||||
},
|
||||
{
|
||||
"id": "103",
|
||||
"name": "starp-jpa-controller",
|
||||
"description": "jpacontroller"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "bi",
|
||||
"templates": [{
|
||||
"id": "201",
|
||||
"name": "qliksense",
|
||||
"description": "qlik sense"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"group": "cloud",
|
||||
"templates": [
|
||||
{
|
||||
"id": "301",
|
||||
"name": "bigquery",
|
||||
"description": "GCP BigQuery"
|
||||
},
|
||||
{
|
||||
"id": "302",
|
||||
"name": "dataflowjjs",
|
||||
"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,94 @@
|
||||
//***************************
|
||||
//[${classInfo.classComment} - ${classInfo.tableName}]
|
||||
//AUTHOR ${authorName}
|
||||
//HISTORY ${.now?string('yyyy-MM-dd')}
|
||||
//***************************
|
||||
|
||||
//***************************
|
||||
//load all
|
||||
[${classInfo.tableName}]:
|
||||
LOAD * FROM ['LIB://QVD/${classInfo.className}.qvd'](qvd);
|
||||
|
||||
//***************************
|
||||
//load columns
|
||||
[${classInfo.tableName}]:
|
||||
LOAD
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
"${fieldItem.columnName}" as "${fieldItem.fieldName}"<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
FROM
|
||||
['LIB://QVD/${classInfo.className}.qvd'](qvd);
|
||||
;
|
||||
|
||||
//load inline
|
||||
[${classInfo.tableName}]:
|
||||
LOAD * INLINE
|
||||
[
|
||||
<#list classInfo.fieldList as fieldItem >${fieldItem.columnName} <#if fieldItem_has_next>,</#if></#list>
|
||||
<#list classInfo.fieldList as fieldItem >${fieldItem.fieldName} <#if fieldItem_has_next>,</#if></#list>
|
||||
<#list classInfo.fieldList as fieldItem >${fieldItem.fieldComment} <#if fieldItem_has_next>,</#if></#list>
|
||||
];
|
||||
|
||||
//***************************
|
||||
//load from api data connection (wrap on)
|
||||
LIB CONNECT TO '${classInfo.tableName}_api';
|
||||
|
||||
RestConnectorMasterTable:
|
||||
SQL SELECT
|
||||
"__KEY_root",
|
||||
(SELECT
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
"${fieldItem.columnName}"
|
||||
</#list>
|
||||
"__FK_object"
|
||||
FROM "object" FK "__FK_object")
|
||||
FROM JSON (wrap on) "root" PK "__KEY_root"
|
||||
// WITH CONNECTION (
|
||||
// Url "https://localhost:8080/${classInfo.tableName}_api",
|
||||
// QUERY "page" "1",
|
||||
// QUERY "size" "100",
|
||||
// HTTPHEADER "token" "123456",
|
||||
// BODY "Post body here")
|
||||
;
|
||||
|
||||
[${classInfo.className}]:
|
||||
LOAD
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
[${fieldItem.columnName}] as [${fieldItem.fieldName}]
|
||||
</#list>
|
||||
[__FK_object] AS [__KEY_root]
|
||||
RESIDENT RestConnectorMasterTable
|
||||
WHERE NOT IsNull([__FK_stores]);
|
||||
|
||||
DROP TABLE [${classInfo.className}];
|
||||
DROP TABLE RestConnectorMasterTable;
|
||||
|
||||
//***************************
|
||||
//load from api data connection (wrap off)
|
||||
LIB CONNECT TO '${classInfo.tableName}_api';
|
||||
[${classInfo.className}]:
|
||||
SQL SELECT
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
[${fieldItem.fieldName}] as [${fieldItem.fieldName}]<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
FROM JSON(wrap off) "${classInfo.className}"
|
||||
// WITH CONNECTION (
|
||||
// Url "https://localhost:8080/${classInfo.tableName}_api",
|
||||
// QUERY "page" "1",
|
||||
// QUERY "size" "100",
|
||||
// HTTPHEADER "token" "123456",
|
||||
// BODY "Post body here")
|
||||
;
|
||||
|
||||
//***************************
|
||||
//load from sql data connection
|
||||
LIB CONNECT TO '${classInfo.tableName}_db';
|
||||
|
||||
SQL SELECT
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
[${fieldItem.columnName}] as [${fieldItem.fieldName}]<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
FROM
|
||||
${classInfo.tableName}
|
||||
WHERE
|
||||
Create_Time > '2023-01-01 00:00:00';
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
SELECT * FROM 'your_project.your_dataset.${tableName}' t
|
||||
order by t.id desc
|
||||
LIMIT 100
|
||||
;
|
||||
|
||||
SELECT * FROM 'your_project.your_dataset.${tableName}_error_records' t
|
||||
order by t.timestamp desc
|
||||
LIMIT 100
|
||||
;
|
||||
|
||||
bigquery table -> SCHEMA -> Edit as text , then input below text:
|
||||
[
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
{"name":"${fieldItem.columnName}",type:"STRING","mode":"NULLABLE","description": "${fieldItem.fieldName} - ${fieldItem.fieldComment}"}<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* GCP - dataflow job jjs for [${classInfo.classComment} - ${classInfo.tableName}]
|
||||
* AUTHOR ${authorName}
|
||||
*
|
||||
* User-defined function (UDF) to transform events as part of a Dataflow template job.
|
||||
* upload to GCS and create dataflow job with this js file and method as 'process'
|
||||
* @param {string} inJson input Pub/Sub JSON message (stringified)
|
||||
* @return {string} outJson output JSON message (stringified)
|
||||
*/
|
||||
function process(inJson) {
|
||||
//for local js debug
|
||||
//var obj = JSON.parse(JSON.stringify(inJson));
|
||||
//for online jjs
|
||||
var obj = JSON.parse(inJson);
|
||||
var includePubsubMessage = obj.data && obj.attributes;
|
||||
var data = includePubsubMessage ? obj.data : obj;
|
||||
//debug and show error if you need special logic
|
||||
if(data.hasOwnProperty('show_error')){
|
||||
throw new ERROR("show_error:"+JSON.stringify(data))
|
||||
}
|
||||
// INSERT CUSTOM TRANSFORMATION LOGIC HERE
|
||||
var tableObj= {};
|
||||
tableObj.insert_time=new Date().toUTCString()
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
tableObj.${fieldItem.columnName}=data.${fieldItem.fieldName}
|
||||
</#list>
|
||||
return JSON.stringify(tableObj);
|
||||
}
|
||||
|
||||
//field name = field name
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
tableObj.${fieldItem.fieldName}=data.${fieldItem.fieldName}
|
||||
</#list>
|
||||
|
||||
//column name = column name
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
tableObj.${fieldItem.columnName}=data.${fieldItem.columnName}
|
||||
</#list>
|
||||
@@ -19,13 +19,13 @@ public class ${classInfo.className}DaoImpl implements I${classInfo.className}Dao
|
||||
|
||||
@Override
|
||||
public int add(${classInfo.className} ${classInfo.className?uncap_first}) {
|
||||
return jdbcTemplate.update("insert into ${classInfo.tableName} (<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem >${fieldItem.columnName}<#if fieldItem_has_next>,</#if></#list></#if> ) values (<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem >?<#if fieldItem_has_next>,</#if></#list></#if> )",
|
||||
return jdbcTemplate.update("insert into ${classInfo.originTableName} (<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem >${fieldItem.columnName}<#if fieldItem_has_next>,</#if></#list></#if> ) values (<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem >?<#if fieldItem_has_next>,</#if></#list></#if> )",
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem >${classInfo.className?uncap_first}.get${fieldItem.fieldName?cap_first}()<#if fieldItem_has_next>,</#if></#list></#if>);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(${classInfo.className} ${classInfo.className?uncap_first}) {
|
||||
return jdbcTemplate.update("UPDATE ${classInfo.tableName} SET <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index gt 0 >${fieldItem.columnName}=?<#if fieldItem_has_next>,</#if></#if></#list></#if>"
|
||||
return jdbcTemplate.update("UPDATE ${classInfo.originTableName} SET <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index gt 0 >${fieldItem.columnName}=?<#if fieldItem_has_next>,</#if></#if></#list></#if>"
|
||||
+" where <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index = 0>${fieldItem.columnName}=?<#break ></#if></#list></#if>",
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem ><#if fieldItem_index gt 0 >${classInfo.className?uncap_first}.get${fieldItem.fieldName?cap_first}(),</#if></#list>
|
||||
@@ -35,12 +35,12 @@ public class ${classInfo.className}DaoImpl implements I${classInfo.className}Dao
|
||||
|
||||
@Override
|
||||
public int delete(int id) {
|
||||
return jdbcTemplate.update("DELETE from ${classInfo.tableName} where <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index = 0>${fieldItem.columnName}=?<#break ></#if></#list></#if>",id);
|
||||
return jdbcTemplate.update("DELETE from ${classInfo.originTableName} where <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index = 0>${fieldItem.columnName}=?<#break ></#if></#list></#if>",id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ${classInfo.className} findById(int id) {
|
||||
List<${classInfo.className}> list = jdbcTemplate.query("select * from ${classInfo.tableName} where <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index = 0>${fieldItem.columnName}=?<#break ></#if></#list></#if>", new Object[]{id}, new BeanPropertyRowMapper<${classInfo.className}>(${classInfo.className}.class));
|
||||
List<${classInfo.className}> list = jdbcTemplate.query("select * from ${classInfo.originTableName} where <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0><#list classInfo.fieldList as fieldItem ><#if fieldItem_index = 0>${fieldItem.columnName}=?<#break ></#if></#list></#if>", new Object[]{id}, new BeanPropertyRowMapper<${classInfo.className}>(${classInfo.className}.class));
|
||||
if(list!=null && !list.isEmpty() ){
|
||||
return list.get(0);
|
||||
}else{
|
||||
@@ -50,7 +50,7 @@ public class ${classInfo.className}DaoImpl implements I${classInfo.className}Dao
|
||||
|
||||
@Override
|
||||
public List<${classInfo.className}> findAllList(Map<String,Object> params) {
|
||||
List<${classInfo.className}> list = jdbcTemplate.query("select * from ${classInfo.tableName}", new Object[]{}, new BeanPropertyRowMapper<${classInfo.className}>(${classInfo.className}.class));
|
||||
List<${classInfo.className}> list = jdbcTemplate.query("select * from ${classInfo.originTableName}", new Object[]{}, new BeanPropertyRowMapper<${classInfo.className}>(${classInfo.className}.class));
|
||||
if(list!=null && !list.isEmpty() ){
|
||||
return list;
|
||||
}else{
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<#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 javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.GeneratedValue;
|
||||
<#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')}
|
||||
*/
|
||||
@Entity
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
<#if isLombok?exists && isLombok==true>@Data</#if>
|
||||
<#if isComment?exists && isComment==true>@Table(name="${classInfo.originTableName}")</#if><#if isSwagger?exists && isSwagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
public class ${classInfo.className} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@ApiModelProperty("id")
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
<#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>@Column(name="${fieldItem.columnName}")</#if>
|
||||
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
|
||||
|
||||
</#list>
|
||||
public ${classInfo.className}() {
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if isLombok?exists && isLombok==false>
|
||||
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};
|
||||
}
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
import ${packageName}.entity.${classInfo.className};
|
||||
import ${packageName}.repository.${classInfo.className}Repository;
|
||||
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.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
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')}
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "${classInfo.className?uncap_first}")
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/${classInfo.className?uncap_first}")
|
||||
public class ${classInfo.className}Controller {
|
||||
|
||||
@Autowired
|
||||
private ${classInfo.className}Repository ${classInfo.className?uncap_first}Repository;
|
||||
|
||||
/**
|
||||
* 新增或编辑
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperation(value = "save ${classInfo.className}", notes = "save ${classInfo.className}")
|
||||
public Object save(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first}){
|
||||
try {
|
||||
return ReturnT.success(${classInfo.className?uncap_first}Repository.save(${classInfo.className?uncap_first}));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ReturnT.error("保存失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation(value = "delete ${classInfo.className}", notes = "delete ${classInfo.className}")
|
||||
public Object delete(int id){
|
||||
Optional<${classInfo.className}> ${classInfo.className?uncap_first}=${classInfo.className?uncap_first}Repository.findById(id);
|
||||
if(${classInfo.className?uncap_first}.isPresent()){
|
||||
${classInfo.className?uncap_first}Repository.deleteById(id);
|
||||
return ${returnUtilSuccess}("删除成功");
|
||||
}else{
|
||||
return ${returnUtilFailure}("没有找到该对象");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
@PostMapping("/find")
|
||||
@ApiOperation(value = "find ${classInfo.className} by id", notes = "find ${classInfo.className} by id")
|
||||
public Object find(int id){
|
||||
Optional<${classInfo.className}> ${classInfo.className?uncap_first}=${classInfo.className?uncap_first}Repository.findById(id);
|
||||
if(${classInfo.className?uncap_first}.isPresent()){
|
||||
return ${returnUtilSuccess}(${classInfo.className?uncap_first}.get());
|
||||
}else{
|
||||
return ${returnUtilFailure}("没有找到该对象");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
@ApiOperation(value = "list ${classInfo.className}", notes = "list ${classInfo.className}")
|
||||
public Object list(@RequestBody ${classInfo.className} ${classInfo.className?uncap_first},
|
||||
@RequestParam(required = false, defaultValue = "0") int pageNumber,
|
||||
@RequestParam(required = false, defaultValue = "10") int pageSize) {
|
||||
|
||||
try {
|
||||
//创建匹配器,需要查询条件请修改此处代码
|
||||
ExampleMatcher matcher = ExampleMatcher.matchingAll();
|
||||
|
||||
//创建实例
|
||||
Example<${classInfo.className}> example = Example.of(${classInfo.className?uncap_first}, matcher);
|
||||
//分页构造
|
||||
Pageable pageable = PageRequest.of(pageNumber,pageSize);
|
||||
|
||||
return ReturnT.success(${classInfo.className?uncap_first}Repository.findAll(example, pageable));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ReturnT.error(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.repository;</#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 org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Repository
|
||||
public interface ${classInfo.className}Repository extends JpaRepository<${classInfo.className},Integer> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import io.swagger.annotations.ApiModelProperty;</#if>
|
||||
*/
|
||||
@Entity
|
||||
<#if isLombok?exists && isLombok==true>@Data</#if>
|
||||
<#if isComment?exists && isComment==true>@Table(name="${classInfo.tableName}")</#if><#if isSwagger?exists && isSwagger==true>
|
||||
<#if isComment?exists && isComment==true>@Table(name="${classInfo.originTableName}")</#if><#if isSwagger?exists && isSwagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
public class ${classInfo.className} implements Serializable {
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ 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}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if>
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.repository;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>import ${packageName}.entity.${classInfo.className};
|
||||
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ${classInfo.className}Controller {
|
||||
* @date ${.now?string('yyyy/MM/dd')}
|
||||
**/
|
||||
@RequestMapping("/delete")
|
||||
public ReturnT<String> delete(int id){
|
||||
public Object delete(int id){
|
||||
return ${classInfo.className?uncap_first}Service.delete(id);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ${classInfo.className}Controller {
|
||||
* @date ${.now?string('yyyy/MM/dd')}
|
||||
**/
|
||||
@RequestMapping("/update")
|
||||
public ReturnT<String> update(${classInfo.className} ${classInfo.className?uncap_first}){
|
||||
public Object update(${classInfo.className} ${classInfo.className?uncap_first}){
|
||||
return ${classInfo.className?uncap_first}Service.update(${classInfo.className?uncap_first});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${packageName}.dao.${classInfo.className}Dao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="${packageName}.entity.${classInfo.className}Entity" >
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<result column="${fieldItem.columnName}" property="${fieldItem.fieldName}" />
|
||||
</#list>
|
||||
</#if>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="${packageName}.entity.${classInfo.className}Entity">
|
||||
INSERT INTO ${classInfo.tableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.columnName != "id" >
|
||||
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">
|
||||
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
||||
${r"</if>"}
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.columnName != "id" >
|
||||
<#--<#if fieldItem.columnName="addtime" || fieldItem.columnName="updatetime" >
|
||||
${r"<if test ='null != "}${fieldItem.fieldName}${r"'>"}
|
||||
NOW()<#if fieldItem_has_next>,</#if>
|
||||
${r"</if>"}
|
||||
<#else>-->
|
||||
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">
|
||||
${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>
|
||||
${r"</if>"}
|
||||
<#--</#if>-->
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<delete id="delete" >
|
||||
DELETE FROM ${classInfo.tableName}
|
||||
WHERE id = ${r"#{id}"}
|
||||
</delete>
|
||||
|
||||
<update id="update" parameterType="${packageName}.entity.${classInfo.className}Entity">
|
||||
UPDATE ${classInfo.tableName}
|
||||
<set>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.columnName != "id" && fieldItem.columnName != "AddTime" && fieldItem.columnName != "UpdateTime" >
|
||||
<if test="null != ${fieldItem.fieldName} and '' != ${fieldItem.fieldName}">${fieldItem.columnName} = ${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>${r"</if>"}
|
||||
</#if>
|
||||
</#list>
|
||||
</set>
|
||||
WHERE id = ${r"#{"}id${r"}"}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="load" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List" />
|
||||
FROM ${classInfo.tableName}
|
||||
WHERE id = ${r"#{id}"}
|
||||
</select>
|
||||
|
||||
<select id="pageList" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List" />
|
||||
FROM ${classInfo.tableName}
|
||||
LIMIT ${r"#{offset}"}, ${r"#{pageSize}"}
|
||||
</select>
|
||||
|
||||
<select id="pageListCount" resultType="java.lang.Integer">
|
||||
SELECT count(1)
|
||||
FROM ${classInfo.tableName}
|
||||
</select>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${packageName}.dao.${classInfo.className}Mapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="${packageName}.entity.${classInfo.className}" >
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<result column="${fieldItem.columnName}" property="${fieldItem.fieldName}" />
|
||||
</#list>
|
||||
</#if>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="${packageName}.entity.${classInfo.className}">
|
||||
INSERT INTO ${classInfo.originTableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.columnName != "id" >
|
||||
<if test="null != ${fieldItem.fieldName} <#if fieldItem.fieldClass ="String">and '' != ${fieldItem.fieldName}</#if>">
|
||||
${fieldItem.columnName}<#if fieldItem_has_next>,</#if>
|
||||
${r"</if>"}
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.columnName != "id" >
|
||||
<#--<#if fieldItem.columnName="addtime" || fieldItem.columnName="updatetime" >
|
||||
${r"<if test ='null != "}${fieldItem.fieldName}${r"'>"}
|
||||
NOW()<#if fieldItem_has_next>,</#if>
|
||||
${r"</if>"}
|
||||
<#else>-->
|
||||
<if test="null != ${fieldItem.fieldName} <#if fieldItem.fieldClass ="String">and '' != ${fieldItem.fieldName}</#if>">
|
||||
${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>
|
||||
${r"</if>"}
|
||||
<#--</#if>-->
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<delete id="delete" >
|
||||
DELETE FROM ${classInfo.originTableName}
|
||||
WHERE id = ${r"#{id}"}
|
||||
</delete>
|
||||
|
||||
<update id="update" parameterType="${packageName}.entity.${classInfo.className}">
|
||||
UPDATE ${classInfo.originTableName}
|
||||
<set>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<#if fieldItem.columnName != "id" && fieldItem.columnName != "AddTime" && fieldItem.columnName != "UpdateTime" >
|
||||
<if test="null != ${fieldItem.fieldName} <#if fieldItem.fieldClass ="String">and '' != ${fieldItem.fieldName}</#if>">${fieldItem.columnName} = ${r"#{"}${fieldItem.fieldName}${r"}"}<#if fieldItem_has_next>,</#if>${r"</if>"}
|
||||
</#if>
|
||||
</#list>
|
||||
</set>
|
||||
WHERE id = ${r"#{"}id${r"}"}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="load" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List" />
|
||||
FROM ${classInfo.originTableName}
|
||||
WHERE id = ${r"#{id}"}
|
||||
</select>
|
||||
|
||||
<select id="pageList" resultMap="BaseResultMap">
|
||||
SELECT <include refid="Base_Column_List" />
|
||||
FROM ${classInfo.originTableName}
|
||||
LIMIT ${r"#{offset}"}, ${r"#{pageSize}"}
|
||||
</select>
|
||||
|
||||
<select id="pageListCount" resultType="java.lang.Integer">
|
||||
SELECT count(1)
|
||||
FROM ${classInfo.originTableName}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -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">
|
||||
@@ -140,6 +140,7 @@
|
||||
vm.formData.options.returnUtilSuccess="${(value.returnUtilSuccess)!!}";
|
||||
vm.formData.options.returnUtilFailure="${(value.returnUtilFailure)!!}";
|
||||
vm.outputStr="${(value.outputStr)!!}";
|
||||
loadAllCookie()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
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(""));
|
||||
}
|
||||
}
|
||||
23
pom.xml
23
pom.xml
@@ -5,13 +5,13 @@
|
||||
|
||||
<groupId>com.softdev.system</groupId>
|
||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>2023</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.7.RELEASE</version>
|
||||
<version>2.6.3</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -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.60</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>
|
||||
@@ -78,7 +85,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
|
||||
<!-- freemarker -->
|
||||
@@ -98,13 +105,13 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
@@ -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