mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-05-08 14:26:18 +08:00
Compare commits
30 Commits
2021.01.18
...
2022.02.09
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e968a3bfe1 | ||
|
|
cffaac2508 | ||
|
|
69a0dede9b | ||
|
|
732dd246cb | ||
|
|
d3820a2552 | ||
|
|
7e93e91478 | ||
|
|
aa38125294 | ||
|
|
adab6d7809 | ||
|
|
dac7d20eb8 | ||
|
|
482e004978 | ||
|
|
94a424ac11 | ||
|
|
f6844ee7c5 | ||
|
|
a1fc04af8c | ||
|
|
efef2aefc4 | ||
|
|
f88a8c2940 | ||
|
|
1144a2137e | ||
|
|
1c6efb400b | ||
|
|
371ff03a5f | ||
|
|
ec949f97e0 | ||
|
|
78975fc86d | ||
|
|
b387240235 | ||
|
|
ab705bfa2f | ||
|
|
45d380ca5d | ||
|
|
6aa41d565f | ||
|
|
d88303a25f | ||
|
|
875f21bc54 | ||
|
|
18d79cf314 | ||
|
|
2ed87847a1 | ||
|
|
ccf62a24b7 | ||
|
|
3007dbac2e |
123
README.md
123
README.md
@@ -20,10 +20,10 @@
|
||||
> #支持`MySQL`、Oracle、PgSQL三大主流数据库
|
||||
>
|
||||
>generate to many popular templates by ddl-sql/insert-sql/simple json<br>
|
||||
> 可通过`建表SQL语句`或`INSERT语句`或者`简单JSON`生成`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL`相关模板代码.
|
||||
> 可通过`建表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 700 stars <br>
|
||||
> 感谢大家的使用和反馈,每天六百的PV和获得超过七百多的星星是我前进和继续做下去的动力。
|
||||
>thanks for your using and feedback,I'm inspired by the 600PV every day and github more than 900 stars <br>
|
||||
> 感谢大家的使用和反馈,每天六百的PV和获得超过九百多的星星是我前进和继续做下去的动力。
|
||||
>
|
||||
>hope everyone can keep good balance on work and life , stay health and safety , be smooth on work as well<br>
|
||||
> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利!
|
||||
@@ -48,64 +48,71 @@
|
||||
|
||||
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|
|
||||
| 访问地址 | 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 |
|
||||
|
||||
|
||||
# Update Logs
|
||||
|更新日期|更新内容|
|
||||
|:----|:----|
|
||||
|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模板.|
|
||||
| 更新日期 | 更新内容 |
|
||||
|:------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 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
|
||||
|名称|说明|
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
public class ClassInfo {
|
||||
|
||||
private String tableName;
|
||||
private String originTableName;
|
||||
private String className;
|
||||
private String classComment;
|
||||
private List<FieldInfo> fieldList;
|
||||
|
||||
@@ -13,6 +13,7 @@ public class FieldInfo {
|
||||
private String columnName;
|
||||
private String fieldName;
|
||||
private String fieldClass;
|
||||
private String swaggerClass;
|
||||
private String fieldComment;
|
||||
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class TableParseUtil {
|
||||
//优化对likeu.members这种命名的支持
|
||||
tableName = tableName.substring(tableName.indexOf(".") + 1);
|
||||
}
|
||||
|
||||
String originTableName = tableName;
|
||||
//ignore prefix
|
||||
if(tableName!=null && StringUtils.isNotNull(MapUtil.getString(paramInfo.getOptions(),"ignorePrefix"))){
|
||||
tableName = tableName.replaceAll(MapUtil.getString(paramInfo.getOptions(),"ignorePrefix"),"");
|
||||
@@ -173,7 +173,13 @@ 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(" "));
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
System.out.println("err happened: " + columnLine);
|
||||
throw e;
|
||||
}
|
||||
|
||||
// field Name
|
||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||
String fieldName = null;
|
||||
@@ -189,9 +195,24 @@ public class TableParseUtil {
|
||||
} else {
|
||||
fieldName = columnName;
|
||||
}
|
||||
|
||||
// field class
|
||||
columnLine = columnLine.substring(columnLine.indexOf("`") + 1).trim();
|
||||
|
||||
//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";
|
||||
}
|
||||
// field class
|
||||
// int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
String fieldClass = Object.class.getSimpleName();
|
||||
//2018-9-16 zhengk 补充char/clob/blob/json等类型,如果类型未知,默认为String
|
||||
@@ -287,9 +308,11 @@ public class TableParseUtil {
|
||||
}
|
||||
|
||||
FieldInfo fieldInfo = new FieldInfo();
|
||||
//
|
||||
fieldInfo.setColumnName(columnName);
|
||||
fieldInfo.setFieldName(fieldName);
|
||||
fieldInfo.setFieldClass(fieldClass);
|
||||
fieldInfo.setSwaggerClass(swaggerClass);
|
||||
fieldInfo.setFieldComment(fieldComment);
|
||||
|
||||
fieldList.add(fieldInfo);
|
||||
@@ -306,6 +329,7 @@ public class TableParseUtil {
|
||||
codeJavaInfo.setClassName(className);
|
||||
codeJavaInfo.setClassComment(classComment);
|
||||
codeJavaInfo.setFieldList(fieldList);
|
||||
codeJavaInfo.setOriginTableName(originTableName);
|
||||
|
||||
return codeJavaInfo;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ spring:
|
||||
#mvc:
|
||||
# static-path-pattern: /statics/**
|
||||
OEM:
|
||||
version: 3.1
|
||||
version: 3.2
|
||||
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.1
|
||||
version: 3.2
|
||||
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.1
|
||||
version: 3.2
|
||||
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;
|
||||
}
|
||||
@@ -61,6 +61,7 @@ const vm = new Vue({
|
||||
},
|
||||
templates:[{}],
|
||||
historicalData:[],
|
||||
currentSelect:'plusentity',
|
||||
outputStr: "${(value.outputStr)!!}",
|
||||
outputJson: {}
|
||||
},
|
||||
@@ -69,10 +70,13 @@ const vm = new Vue({
|
||||
setOutputModel: function (event) {
|
||||
const targetModel = event.target.innerText.trim();
|
||||
console.log(targetModel);
|
||||
vm.outputStr=vm.outputJson[targetModel];
|
||||
$.outputArea.setValue(vm.outputStr.trim());
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setSize('auto', 'auto');
|
||||
vm.currentSelect = targetModel ;
|
||||
if(vm.outputStr.length>30){
|
||||
vm.outputStr=vm.outputJson[targetModel];
|
||||
$.outputArea.setValue(vm.outputStr.trim());
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setSize('auto', 'auto');
|
||||
}
|
||||
},
|
||||
//switch HistoricalData
|
||||
switchHistoricalData: function (event) {
|
||||
@@ -86,7 +90,7 @@ const vm = new Vue({
|
||||
}else{
|
||||
alert("浏览器不支持sessionStorage");
|
||||
}
|
||||
vm.outputStr=vm.outputJson["plusentity"].trim();
|
||||
vm.outputStr=vm.outputJson[vm.currentSelect].trim();
|
||||
$.outputArea.setValue(vm.outputStr);
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setSize('auto', 'auto');
|
||||
@@ -119,10 +123,11 @@ const vm = new Vue({
|
||||
error("生成失败");
|
||||
return;
|
||||
}
|
||||
setAllCookie();
|
||||
//console.log(res.outputJson);
|
||||
vm.outputJson=res.outputJson;
|
||||
// console.log(vm.outputJson["bootstrap-ui"]);
|
||||
vm.outputStr=vm.outputJson["plusentity"].trim();
|
||||
vm.outputStr=vm.outputJson[vm.currentSelect].trim();
|
||||
//console.log(vm.outputJson["bootstrap-ui"]);
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setValue(vm.outputStr);
|
||||
@@ -150,3 +155,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"];
|
||||
}
|
||||
|
||||
@@ -167,7 +167,87 @@
|
||||
"id": "73",
|
||||
"name": "sql",
|
||||
"description": "sql"
|
||||
},
|
||||
{
|
||||
"id": "74",
|
||||
"name": "swagger-yml",
|
||||
"description": "swagger-yml"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "common-mapper",
|
||||
"templates": [{
|
||||
"id": "81",
|
||||
"name": "tkentity",
|
||||
"description": "tkentity"
|
||||
},
|
||||
{
|
||||
"id": "82",
|
||||
"name": "tkmapper",
|
||||
"description": "tkmapper"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"group": "renren-fast",
|
||||
"templates": [{
|
||||
"id": "91",
|
||||
"name": "menu-sql",
|
||||
"description": "menu-sql"
|
||||
},
|
||||
{
|
||||
"id": "92",
|
||||
"name": "vue-list",
|
||||
"description": "vue-list"
|
||||
},
|
||||
{
|
||||
"id": "93",
|
||||
"name": "vue-edit",
|
||||
"description": "vue-edit"
|
||||
},
|
||||
{
|
||||
"id": "94",
|
||||
"name": "rr-controller",
|
||||
"description": "rr-controller"
|
||||
},
|
||||
{
|
||||
"id": "95",
|
||||
"name": "rr-dao",
|
||||
"description": "rr-dao"
|
||||
},
|
||||
{
|
||||
"id": "96",
|
||||
"name": "rr-daoxml",
|
||||
"description": "rr-daoxml"
|
||||
},
|
||||
{
|
||||
"id": "97",
|
||||
"name": "rr-service",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<#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.*;
|
||||
<#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>@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
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
<#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,16 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
import tk.mybatis.mapper.common.Mapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import ${packageName}.entity.${classInfo.className};
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}Mapper
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${classInfo.className}Mapper extends Mapper<${classInfo.className}> {
|
||||
|
||||
|
||||
}
|
||||
@@ -19,31 +19,30 @@ 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>
|
||||
<#list classInfo.fieldList as fieldItem ><#if fieldItem_index = 0 >${classInfo.className?uncap_first}.get${fieldItem.fieldName?cap_first}()</#if></#list>
|
||||
</#if>;
|
||||
</#if>);
|
||||
}
|
||||
|
||||
@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));
|
||||
if(list!=null && list.size()>0){
|
||||
${classInfo.className} ${classInfo.className?uncap_first} = list.get(0);
|
||||
return ${classInfo.className?uncap_first};
|
||||
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{
|
||||
return null;
|
||||
}
|
||||
@@ -51,11 +50,11 @@ 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));
|
||||
if(list!=null && list.size()>0){
|
||||
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{
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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> {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -10,8 +10,9 @@ 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;
|
||||
import io.swagger.annotations.ApiModelProperty;</#if>
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
@@ -20,7 +21,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
@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>
|
||||
|
||||
@@ -7,6 +7,9 @@ import java.util.List;
|
||||
import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
<#if isSwagger?exists && isSwagger==true>
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;</#if>
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}
|
||||
|
||||
@@ -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 "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 "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 "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,17 @@
|
||||
-- 菜单SQL
|
||||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||
VALUES ('1', '${classInfo.classComment}', 'generator/${classInfo.className?uncap_first}', NULL, '1', 'config', '6');
|
||||
|
||||
-- 按钮父菜单ID
|
||||
set @parentId = @@identity;
|
||||
|
||||
-- 菜单对应按钮SQL
|
||||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||
SELECT @parentId, '查看', null, 'generator:${classInfo.className?uncap_first}:list,generator:${classInfo.className?uncap_first}:info', '2', null, '6';
|
||||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||
SELECT @parentId, '新增', null, 'generator:${classInfo.className?uncap_first}:save', '2', null, '6';
|
||||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||
SELECT @parentId, '修改', null, 'generator:${classInfo.className?uncap_first}:update', '2', null, '6';
|
||||
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||
SELECT @parentId, '删除', null, 'generator:${classInfo.className?uncap_first}:delete', '2', null, '6';
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import ${packageName}.entity.${classInfo.className}Entity;
|
||||
import ${packageName}.service.${classInfo.className}Service;
|
||||
import ${packageName}.common.utils.PageUtils;
|
||||
import ${packageName}.common.utils.R;
|
||||
</#if>
|
||||
|
||||
|
||||
/**
|
||||
* @description ${classInfo.classComment}控制器
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("generator/${classInfo.className?uncap_first}")
|
||||
public class ${classInfo.className}Controller {
|
||||
|
||||
@Autowired
|
||||
private ${classInfo.className}Service ${classInfo.className?uncap_first}Service;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = ${classInfo.className?uncap_first}Service.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{${classInfo.className?uncap_first}Id}")
|
||||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:info")
|
||||
public R info(@PathVariable("${classInfo.className?uncap_first}Id") int ${classInfo.className?uncap_first}Id){
|
||||
${classInfo.className}Entity ${classInfo.className?uncap_first} = ${classInfo.className?uncap_first}Service.getById(${classInfo.className?uncap_first}Id);
|
||||
|
||||
return R.ok().put("${classInfo.className?uncap_first}", ${classInfo.className?uncap_first});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:save")
|
||||
public R save(@RequestBody ${classInfo.className}Entity ${classInfo.className?uncap_first}){
|
||||
${classInfo.className?uncap_first}Service.save(${classInfo.className?uncap_first});
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:update")
|
||||
public R update(@RequestBody ${classInfo.className}Entity ${classInfo.className?uncap_first}){
|
||||
${classInfo.className?uncap_first}Service.updateById(${classInfo.className?uncap_first});
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@RequiresPermissions("generator:${classInfo.className?uncap_first}:delete")
|
||||
public R delete(@RequestBody int[] ${classInfo.className?uncap_first}Ids){
|
||||
${classInfo.className?uncap_first}Service.removeByIds(Arrays.asList(${classInfo.className?uncap_first}Ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
import ${packageName}.entity.${classInfo.className}Entity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
</#if>
|
||||
/**
|
||||
* @description ${classInfo.classComment}Mapper
|
||||
* @author ${authorName}
|
||||
* @date ${.now?string('yyyy-MM-dd')}
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${classInfo.className}Dao extends BaseMapper<${classInfo.className}Entity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?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 type="${packageName}.entity.${classInfo.className}Entity" id="${classInfo.className}Map">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<result property="${fieldItem.fieldName}" column="${fieldItem.fieldName}"/>
|
||||
</#list>
|
||||
</#if>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.service;</#if>
|
||||
<#if isAutoImport?exists && isAutoImport==true>
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import ${packageName}.common.utils.PageUtils;
|
||||
import ${packageName}.common.utils.Query;
|
||||
|
||||
import ${packageName}.dao.${classInfo.className}Dao;
|
||||
import ${packageName}.entity.${classInfo.className}Entity;
|
||||
</#if>
|
||||
|
||||
@Service("${classInfo.className?uncap_first}Service")
|
||||
public class ${classInfo.className}Service extends ServiceImpl<${classInfo.className}Dao, ${classInfo.className}Entity> {
|
||||
|
||||
@Override
|
||||
public PageUtils queryPage(Map<String, Object> params) {
|
||||
IPage<${classInfo.className}Entity> page = this.page(
|
||||
new Query<${classInfo.className}Entity>().getPage(params),
|
||||
new QueryWrapper<${classInfo.className}Entity>()
|
||||
);
|
||||
|
||||
return new PageUtils(page);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.${classInfo.className?uncap_first}Id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<el-form-item label="${fieldItem.fieldComment}" prop="${fieldItem.fieldName}">
|
||||
<el-input v-model="dataForm.${fieldItem.fieldName}" placeholder="${fieldItem.fieldComment}"></el-input>
|
||||
</el-form-item>
|
||||
</#list>
|
||||
</#if>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
visible: false,
|
||||
dataForm: {
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
${fieldItem.fieldName}: ''<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
},
|
||||
dataRule: {
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
${fieldItem.fieldName}: [{ required: true, message: '${fieldItem.fieldComment}不能为空', trigger: 'blur' }]<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init (id) {
|
||||
this.dataForm.${classInfo.className?uncap_first}Id = id || 0
|
||||
this.visible = true
|
||||
this.¥nextTick(() => {
|
||||
this.¥refs['dataForm'].resetFields()
|
||||
// <!-- 请把 ${classInfo.className?uncap_first}Id 替换成正确的ID -->
|
||||
if (this.dataForm.${classInfo.className?uncap_first}Id) {
|
||||
this.¥http({
|
||||
url: this.¥http.adornUrl(`/generator/${classInfo.className?uncap_first}/info/¥{this.dataForm.${classInfo.className?uncap_first}Id}`),
|
||||
method: 'get',
|
||||
params: this.¥http.adornParams()
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
this.dataForm.${fieldItem.fieldName} = data.${classInfo.className?uncap_first}.${fieldItem.fieldName}
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit () {
|
||||
this.¥refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.¥http({
|
||||
url: this.¥http.adornUrl(`/generator/${classInfo.className?uncap_first}/¥{this.dataForm.${classInfo.className?uncap_first}Id? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.¥http.adornData({
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
'${fieldItem.fieldName}': '${fieldItem.fieldName}' || undefined<#if fieldItem_has_next>,</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.¥message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.¥emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.¥message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button v-if="isAuth('generator:${classInfo.className?uncap_first}:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="isAuth('generator:${classInfo.className?uncap_first}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
<el-table-column
|
||||
prop="${fieldItem.fieldName}"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="${fieldItem.fieldComment}">
|
||||
</el-table-column>
|
||||
</#list>
|
||||
</#if>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="150"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<!-- 请把 ${classInfo.className?uncap_first}Id 替换成正确的ID -->
|
||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.${classInfo.className?uncap_first}Id)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.${classInfo.className?uncap_first}Id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './${classInfo.className?uncap_first}-add-or-update'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated () {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList () {
|
||||
this.dataListLoading = true
|
||||
this.¥http({
|
||||
url: this.¥http.adornUrl('/generator/${classInfo.className?uncap_first}/list'),
|
||||
method: 'get',
|
||||
params: this.¥http.adornParams({
|
||||
'page': this.pageIndex,
|
||||
'limit': this.pageSize,
|
||||
'key': this.dataForm.key
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list
|
||||
this.totalPage = data.page.totalCount
|
||||
} else {
|
||||
this.dataList = []
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle (val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle (val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle (val) {
|
||||
this.dataListSelections = val
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle (id) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.¥nextTick(() => {
|
||||
this.¥refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle (id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.${classInfo.className?uncap_first}Id
|
||||
})
|
||||
this.¥confirm(`确定对[id=¥{ids.join(',')}]进行[¥{id ? '删除' : '批量删除'}]操作?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.¥http({
|
||||
url: this.¥http.adornUrl('/generator/${classInfo.className?uncap_first}/delete'),
|
||||
method: 'post',
|
||||
data: this.¥http.adornData(ids, false)
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.¥message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.¥message.error(data.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
${classInfo.className}:
|
||||
type: "object"
|
||||
properties:
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
${fieldItem.fieldName}:
|
||||
type: ${fieldItem.swaggerClass}
|
||||
description: <#if isComment?exists && isComment==true>"${fieldItem.fieldComment}"</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
vm.formData.options.returnUtilSuccess="${(value.returnUtilSuccess)!!}";
|
||||
vm.formData.options.returnUtilFailure="${(value.returnUtilFailure)!!}";
|
||||
vm.outputStr="${(value.outputStr)!!}";
|
||||
loadAllCookie()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
10
pom.xml
10
pom.xml
@@ -11,7 +11,7 @@
|
||||
<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>
|
||||
@@ -49,7 +49,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.60</version>
|
||||
<version>1.2.79</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 支持 @ConfigurationProperties 注解 -->
|
||||
@@ -78,7 +78,7 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<version>1.18.22</version>
|
||||
</dependency>
|
||||
|
||||
<!-- freemarker -->
|
||||
@@ -98,13 +98,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>
|
||||
|
||||
Reference in New Issue
Block a user