diff --git a/README.md b/README.md index b735792..f3ddbed 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ +![image](https://img.shields.io/badge/SpringBoot-%E2%98%85%E2%98%85%E2%98%85-green.svg) +![image](https://img.shields.io/badge/CodeGenerator-%E2%98%85%E2%98%85%E2%98%85-green.svg) SpringBootCodeGenerator ---- -SpringBoot代码生成器。用于生成mybatis和jpa相关代码,基于xxl-codegenerator。 \ No newline at end of file +SpringBoot代码生成器。用于生成mybatis和jpa相关代码,基于xxl-codegenerator。 +

+ + + + + + + + + +
访问路径 http://127.0.0.1:1234/generator
CSDN博客 http://blog.csdn.net/moshowgame
更新日期 更新内容
20180915新增Swagger-UI模板。修复一些命名和导入问题。JPA的Entity默认第一个字段为Id,如果不是请手工修改。
20180913修复字段没有描述以及类型为DATE型导致的问题。新增JPA的Controller模板。
20180831初始化项目。新增JPA系列Entity+Repository模板。
+ + \ No newline at end of file diff --git a/generator-web/src/main/java/com/softdev/system/generator/controller/IndexController.java b/generator-web/src/main/java/com/softdev/system/generator/controller/IndexController.java index 5daae1c..7a6075c 100644 --- a/generator-web/src/main/java/com/softdev/system/generator/controller/IndexController.java +++ b/generator-web/src/main/java/com/softdev/system/generator/controller/IndexController.java @@ -64,6 +64,7 @@ public class IndexController { result.put("model_code", freemarkerTool.processString("xxl-code-generator/model.ftl", params)); result.put("entity_code", freemarkerTool.processString("xxl-code-generator/entity.ftl", params)); + result.put("swaggerui_code", freemarkerTool.processString("xxl-code-generator/swaggerui.ftl", params)); result.put("repository_code", freemarkerTool.processString("xxl-code-generator/repository.ftl", params)); result.put("jpacontroller_code", freemarkerTool.processString("xxl-code-generator/jpacontroller.ftl", params)); @@ -76,7 +77,7 @@ public class IndexController { } } logger.info("生成代码行数:{}", lineNum); - + logger.info("生成代码数据:{}", result); return new ReturnT>(result); } catch (IOException | TemplateException e) { logger.error(e.getMessage(), e); diff --git a/generator-web/src/main/resources/static/js/index.js b/generator-web/src/main/resources/static/js/index.js index bf97e8f..b53d888 100644 --- a/generator-web/src/main/resources/static/js/index.js +++ b/generator-web/src/main/resources/static/js/index.js @@ -31,17 +31,9 @@ $(function () { var entity_ide; var repository_ide; var jpacontroller_ide; + var swaggerui_ide; function initCodeArea(){ - jpacontroller_ide = CodeMirror.fromTextArea(document.getElementById("jpacontroller_ide"), { - lineNumbers: true, - matchBrackets: true, - mode: "text/x-java", - lineWrapping:true, - readOnly:true, - foldGutter: true, - gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"] - }); - jpacontroller_ide.setSize('auto','auto'); + // controller_ide controller_ide = CodeMirror.fromTextArea(document.getElementById("controller_ide"), { @@ -136,6 +128,28 @@ $(function () { gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"] }); repository_ide.setSize('auto','auto'); + + jpacontroller_ide = CodeMirror.fromTextArea(document.getElementById("jpacontroller_ide"), { + lineNumbers: true, + matchBrackets: true, + mode: "text/x-java", + lineWrapping:true, + readOnly:true, + foldGutter: true, + gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"] + }); + jpacontroller_ide.setSize('auto','auto'); + + swaggerui_ide = CodeMirror.fromTextArea(document.getElementById("swaggerui_ide"), { + lineNumbers: true, + matchBrackets: true, + mode: "text/x-java", + lineWrapping:true, + readOnly:true, + foldGutter: true, + gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"] + }); + swaggerui_ide.setSize('auto','auto'); } initCodeArea(); @@ -187,6 +201,10 @@ $(function () { jpacontroller_ide.setValue(data.data.jpacontroller_code); jpacontroller_ide.setSize('auto','auto'); + + console.log(data.data.swaggerui_code); + swaggerui_ide.setValue(data.data.swaggerui_code); + swaggerui_ide.setSize('auto','auto'); } }); } else { diff --git a/generator-web/src/main/resources/templates/index.ftl b/generator-web/src/main/resources/templates/index.ftl index 8b656de..2bca01c 100644 --- a/generator-web/src/main/resources/templates/index.ftl +++ b/generator-web/src/main/resources/templates/index.ftl @@ -60,6 +60,7 @@ CREATE TABLE `userinfo` (
  • Entity
  • Repository
  • JpaController
  • +
  • Swagger-UI
  • @@ -76,7 +77,12 @@ CREATE TABLE `userinfo` (
    - Repository: + Controller: +
    +
    +
    +
    + Swagger-UI:
    diff --git a/generator-web/src/main/resources/templates/xxl-code-generator/entity.ftl b/generator-web/src/main/resources/templates/xxl-code-generator/entity.ftl index 21c8995..5ae7cb3 100644 --- a/generator-web/src/main/resources/templates/xxl-code-generator/entity.ftl +++ b/generator-web/src/main/resources/templates/xxl-code-generator/entity.ftl @@ -21,7 +21,8 @@ import java.util.List; @Table(name="${classInfo.tableName}") public class ${classInfo.className} implements Serializable { private static final long serialVersionUID = 1L; - + @Id + @GeneratedValue <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0> <#list classInfo.fieldList as fieldItem > /** diff --git a/generator-web/src/main/resources/templates/xxl-code-generator/jpacontroller.ftl b/generator-web/src/main/resources/templates/xxl-code-generator/jpacontroller.ftl index a5f9383..1eda657 100644 --- a/generator-web/src/main/resources/templates/xxl-code-generator/jpacontroller.ftl +++ b/generator-web/src/main/resources/templates/xxl-code-generator/jpacontroller.ftl @@ -55,11 +55,8 @@ public class ${classInfo.className}Controller { @RequestParam(required = false, defaultValue = "0") int pageNumber, @RequestParam(required = false, defaultValue = "10") int pageSize) { - //创建匹配器,即如何使用查询条件 - ExampleMatcher matcher = ExampleMatcher.matching() //构建对象 - //这里追加查询处理方式。例如xxx字段采用“包含”的方式查询 - //.withMatcher("xxx", GenericPropertyMatchers.contains()) - ; + //创建匹配器,需要查询条件请修改此处代码 + ExampleMatcher matcher = ExampleMatcher.matchingAll(); //创建实例 Example<${classInfo.className}> example = Example.of(${classInfo.className?uncap_first}, matcher); diff --git a/generator-web/src/main/resources/templates/xxl-code-generator/swaggerui.ftl b/generator-web/src/main/resources/templates/xxl-code-generator/swaggerui.ftl new file mode 100644 index 0000000..49ca1e5 --- /dev/null +++ b/generator-web/src/main/resources/templates/xxl-code-generator/swaggerui.ftl @@ -0,0 +1,9 @@ +@ApiOperation(value = "${classInfo.classComment}", notes = "${classInfo.classComment}") + @ApiImplicitParams({ + <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0> + <#list classInfo.fieldList as fieldItem > + @ApiImplicitParam(name = "${fieldItem.fieldName}", value = "${fieldItem.fieldComment}", required = false, dataType = "${fieldItem.fieldClass}"), + + + } + )