From 45d380ca5d31bb7e5fe894d33552147ebf43e150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moshow=E9=83=91=E9=94=B4?= Date: Sat, 7 Aug 2021 19:40:21 +0800 Subject: [PATCH] =?UTF-8?q?|2021.08.07|=E6=96=B0=E5=A2=9E=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E6=A8=A1=E6=9D=BF=E4=BF=9D=E6=8C=81=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E9=87=8D=E6=96=B0=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=8E=E4=BE=9D=E7=84=B6=E4=BC=9A=E4=BF=9D=E6=8C=81=E5=9C=A8?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E9=80=89=E6=8B=A9=E6=A8=A1=E6=9D=BF=E3=80=82?= =?UTF-8?q?
=E6=96=B0=E5=A2=9Erenren-fast=E6=A8=A1=E6=9D=BF=E3=80=82|?= =?UTF-8?q?=20|2021.08.05|=E8=A7=A3=E5=86=B3=20update=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF=EF=BC=9B=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AF=AD=E5=8F=A5=E9=81=BF=E5=85=8DsonarLint?= =?UTF-8?q?=E5=91=8A=E8=AD=A6(=E6=84=9F=E8=B0=A2@Henry586=E7=9A=84PR);
?= =?UTF-8?q?add=20swagger-yml.ftl(=E6=84=9F=E8=B0=A2@fuuqiu=E7=9A=84PR);=E6=94=AF=E6=8C=81common-mapper&=E4=BF=AE=E5=A4=8Dentity?= =?UTF-8?q?=E5=92=8Cplusentity=E7=9A=84swagger=E5=BC=95=E5=8C=85=E9=94=99?= =?UTF-8?q?=E8=AF=AF(=E6=84=9F=E8=B0=A2@chentianming11=E7=9A=84PR)|?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +- .../src/main/resources/application-bejson.yml | 2 +- .../src/main/resources/application-dev.yml | 2 +- .../main/resources/application-devtools.yml | 2 +- .../src/main/resources/statics/js/main.js | 16 +- .../src/main/resources/template.json | 64 +++++-- .../code-generator/renren-fast/menu-sql.ftl | 17 ++ .../renren-fast/rr-controller.ftl | 89 ++++++++++ .../code-generator/renren-fast/rr-dao.ftl | 15 ++ .../code-generator/renren-fast/rr-daoxml.ftl | 15 ++ .../code-generator/renren-fast/rr-entity.ftl | 0 .../code-generator/renren-fast/rr-service.ftl | 28 +++ .../code-generator/renren-fast/vue-edit.ftl | 101 +++++++++++ .../code-generator/renren-fast/vue-list.ftl | 162 ++++++++++++++++++ 14 files changed, 496 insertions(+), 23 deletions(-) create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/menu-sql.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/rr-controller.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/rr-dao.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/rr-daoxml.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/rr-entity.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/rr-service.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/vue-edit.ftl create mode 100644 generator-web/src/main/resources/templates/code-generator/renren-fast/vue-list.ftl diff --git a/README.md b/README.md index c09d2f0..b73599a 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ >generate to many popular templates by ddl-sql/insert-sql/simple json
> 可通过`建表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
-> 感谢大家的使用和反馈,每天六百的PV和获得超过七百多的星星是我前进和继续做下去的动力。 +>thanks for your using and feedback,I'm inspired by the 600PV every day and github more than 900 stars
+> 感谢大家的使用和反馈,每天六百的PV和获得超过九百多的星星是我前进和继续做下去的动力。 > >hope everyone can keep good balance on work and life , stay health and safety , be smooth on work as well
> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利! @@ -60,6 +60,8 @@ Thanks for `JetBrains` providing us the `Licenses for Open Source Development` # Update Logs |更新日期|更新内容| |:----|:----| +|2021.08.07|新增当前模板保持功能,重新生成代码后依然会保持在当前选择模板。
新增renren-fast模板。| +|2021.08.05|解决 update 方法语法错误;调整部分语句避免sonarLint告警(感谢@Henry586的PR);
add swagger-yml.ftl(感谢@fuuqiu的PR);
支持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掉前后空格输出。
完善ReadMe文档。
优化云CDN引入部分。
优化returnUtil部分。
表明前缀选项(感谢@wwlg的建议)。
是否带字段注释设置(感谢@fengpojian的建议)。
优化Mybatis的''!=判断(感谢@zhongsb的建议)。
Mybatis-Plus增加Service层(感谢@yf466532479的建议)。 | diff --git a/generator-web/src/main/resources/application-bejson.yml b/generator-web/src/main/resources/application-bejson.yml index c308484..40da097 100644 --- a/generator-web/src/main/resources/application-bejson.yml +++ b/generator-web/src/main/resources/application-bejson.yml @@ -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在线代码生成 diff --git a/generator-web/src/main/resources/application-dev.yml b/generator-web/src/main/resources/application-dev.yml index b6a96cf..42869ce 100644 --- a/generator-web/src/main/resources/application-dev.yml +++ b/generator-web/src/main/resources/application-dev.yml @@ -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代码生成平台 diff --git a/generator-web/src/main/resources/application-devtools.yml b/generator-web/src/main/resources/application-devtools.yml index 4c6ee4a..6b2a9d3 100644 --- a/generator-web/src/main/resources/application-devtools.yml +++ b/generator-web/src/main/resources/application-devtools.yml @@ -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在线代码生成 diff --git a/generator-web/src/main/resources/statics/js/main.js b/generator-web/src/main/resources/statics/js/main.js index bd0d6af..aab5880 100644 --- a/generator-web/src/main/resources/statics/js/main.js +++ b/generator-web/src/main/resources/statics/js/main.js @@ -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'); @@ -122,7 +126,7 @@ const vm = new Vue({ //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); diff --git a/generator-web/src/main/resources/template.json b/generator-web/src/main/resources/template.json index 7150843..6105e07 100644 --- a/generator-web/src/main/resources/template.json +++ b/generator-web/src/main/resources/template.json @@ -177,17 +177,57 @@ }, { - "group": "common-mapper", - "templates": [{ - "id": "74", - "name": "tkentity", - "description": "tkentity" + "group": "common-mapper", + "templates": [{ + "id": "81", + "name": "tkentity", + "description": "tkentity" + }, + { + "id": "82", + "name": "tkmapper", + "description": "tkmapper" + } + ] }, - { - "id": "75", - "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" + } + ] + } ] \ No newline at end of file diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/menu-sql.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/menu-sql.ftl new file mode 100644 index 0000000..2b3193a --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/menu-sql.ftl @@ -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'; + diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-controller.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-controller.ftl new file mode 100644 index 0000000..31a1c39 --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-controller.ftl @@ -0,0 +1,89 @@ +<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.controller; +<#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; + + + +/** +* @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 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(); +} + +} diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-dao.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-dao.ftl new file mode 100644 index 0000000..15f7e96 --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-dao.ftl @@ -0,0 +1,15 @@ +<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper; +<#if isAutoImport?exists && isAutoImport==true> +import ${packageName}.entity.${classInfo.className}Entity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* @description ${classInfo.classComment}Mapper +* @author ${authorName} +* @date ${.now?string('yyyy-MM-dd')} +*/ +@Mapper +public interface ${classInfo.className}Dao extends BaseMapper<${classInfo.className}Entity> { + +} \ No newline at end of file diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-daoxml.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-daoxml.ftl new file mode 100644 index 0000000..c465603 --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-daoxml.ftl @@ -0,0 +1,15 @@ + + + + + + + + <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0> + <#list classInfo.fieldList as fieldItem > + + + + + + \ No newline at end of file diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-entity.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-entity.ftl new file mode 100644 index 0000000..e69de29 diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-service.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-service.ftl new file mode 100644 index 0000000..719246d --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/rr-service.ftl @@ -0,0 +1,28 @@ +<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.service; +<#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; + + +@Service("${classInfo.className?uncap_first}Service") +public class ${classInfo.className}Service extends ServiceImpl<${classInfo.className}Dao, ${classInfo.className}Entity> { + + @Override + public PageUtils queryPage(Map params) { + IPage<${classInfo.className}Entity> page = this.page( + new Query<${classInfo.className}Entity>().getPage(params), + new QueryWrapper<${classInfo.className}Entity>() + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/vue-edit.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/vue-edit.ftl new file mode 100644 index 0000000..6f5835b --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/vue-edit.ftl @@ -0,0 +1,101 @@ + + + diff --git a/generator-web/src/main/resources/templates/code-generator/renren-fast/vue-list.ftl b/generator-web/src/main/resources/templates/code-generator/renren-fast/vue-list.ftl new file mode 100644 index 0000000..969d7d8 --- /dev/null +++ b/generator-web/src/main/resources/templates/code-generator/renren-fast/vue-list.ftl @@ -0,0 +1,162 @@ + + +