diff --git a/README.md b/README.md index f4f596d..fae6772 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ----|------|---- SpringBoot1.5(第一版) | Test类生成代码 | [https://github.com/wang926454/SpringBootGenerator/releases](https://github.com/wang926454/SpringBootGenerator/releases) SpringBoot2.1(第二版) | Test类生成代码 | [https://github.com/wang926454/SpringBootGenerator/releases](https://github.com/wang926454/SpringBootGenerator/releases) -SpringBoot1.5(第三版) | 可视化界面生成代码 | 当前 +SpringBoot1.5(第三版) | 可视化界面或Test类两种 | 当前 #### 项目介绍 @@ -29,9 +29,9 @@ SpringBoot + Mybatis + PageHelper + 通用Mapper + Thymeleaf(Amaze UI(布局) + #### 安装教程 -1. 配置resource下config/generator.properties数据库信息 +1. 配置resource下config/generator.properties数据库信息,Test类在src\test\java\com\example\generator\GeneratorCode 2. 模板提供两套示例LayUI和RESTful,自行添加模板路径src\test\resources\template\two -3. 运行项目src\main\java\com\example\Application.java即可,访问[http://localhost:8080](http://localhost:8080),可以在线设置生成代码的配置 +3. 可视化界面操作运行项目src\main\java\com\example\Application.java即可,访问[http://localhost:8080](http://localhost:8080),可以在线设置生成代码的配置 #### 使用说明 diff --git a/src/main/resources/config/generator.properties b/src/main/resources/config/generator.properties index be2a5c9..89a5cef 100644 --- a/src/main/resources/config/generator.properties +++ b/src/main/resources/config/generator.properties @@ -41,6 +41,8 @@ template=/src/main/resources/template/two/RESTful # ҪƳıǰ׺ʹöŽзָǰ׺ʾֵ: t_,table_(пո) tableRemovePrefixes= +# authorԣע +author=Generator # basepackageԣ· basepackage=com.example # commonspackageԣ· diff --git a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/controller/${className}Controller.java b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/controller/${className}Controller.java index b8ae9ab..392fa9d 100644 --- a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/controller/${className}Controller.java +++ b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/controller/${className}Controller.java @@ -27,7 +27,7 @@ /** * ${className}Controller - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Controller @@ -39,7 +39,7 @@ public class ${className}Controller { /** * 主页面 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @RequestMapping @@ -49,7 +49,7 @@ public String index(HttpServletRequest request) { /** * 列表 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @ResponseBody @@ -66,7 +66,7 @@ public Map list(@RequestBody ${className}Dto ${classNameLower}Dt /** * 预新增 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @ResponseBody @@ -80,7 +80,7 @@ public Map prepareInsert(@RequestBody ${className}Dto ${classNam /** * 新增 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @ResponseBody @@ -95,7 +95,7 @@ public Map insert(@RequestBody ${className}Dto ${classNameLower} /** * 预修改 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @ResponseBody @@ -109,7 +109,7 @@ public Map prepareUpdate(@RequestBody ${className}Dto ${classNam /** * 修改 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @ResponseBody @@ -124,7 +124,7 @@ public Map update(@RequestBody ${className}Dto ${classNameLower} /** * 删除 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @ResponseBody diff --git a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dao/${className}Dao.java b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dao/${className}Dao.java index a469bb6..f3476c0 100644 --- a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dao/${className}Dao.java +++ b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dao/${className}Dao.java @@ -12,7 +12,7 @@ /** * ${className}Dao - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Repository @@ -22,7 +22,7 @@ public interface ${className}Dao extends BaseDao<${className}Dto> { * 列表 * @param ${classNameLower}Dto * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto); diff --git a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/custom/${className}Dto.java b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/custom/${className}Dto.java index 0a53390..90997de 100644 --- a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/custom/${className}Dto.java +++ b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/custom/${className}Dto.java @@ -10,7 +10,7 @@ /** * ${className}Dto - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Table(name = "${table.sqlName}") diff --git a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/domain/${className}DtoBase.java b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/domain/${className}DtoBase.java index dc73632..e70746a 100644 --- a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/domain/${className}DtoBase.java +++ b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/dto/domain/${className}DtoBase.java @@ -22,7 +22,7 @@ /** * ${className}DtoBase - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public class ${className}DtoBase extends BaseDto implements Serializable { diff --git a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/${className}Service.java b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/${className}Service.java index e1c38cd..770b2dc 100644 --- a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/${className}Service.java +++ b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/${className}Service.java @@ -10,7 +10,7 @@ /** * ${className}Service - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public interface ${className}Service extends IBaseService<${className}Dto> { @@ -19,7 +19,7 @@ public interface ${className}Service extends IBaseService<${className}Dto> { * 列表 * @param ${classNameLower}Dto * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public PageInfo<${className}Dto> findPageInfo(int page, int rows, ${className}Dto ${classNameLower}Dto, String orderBy); diff --git a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java index ecfa832..30731b4 100644 --- a/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java +++ b/src/main/resources/template/two/LayUI/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java @@ -19,7 +19,7 @@ /** * ${className}ServiceImpl - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Service("${classNameLower}Service") diff --git a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/controller/${className}Controller.java b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/controller/${className}Controller.java index f78b395..7197168 100644 --- a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/controller/${className}Controller.java +++ b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/controller/${className}Controller.java @@ -23,7 +23,7 @@ /** * ${className}Controller - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @RestController @@ -39,7 +39,7 @@ public class ${className}Controller { /** * 列表 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @GetMapping @@ -62,7 +62,7 @@ public ResponseBean list(@RequestParam(defaultValue = "1") Integer page, @Reques /** * 查询 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @GetMapping("/{id}") @@ -76,7 +76,7 @@ public ResponseBean findById(@PathVariable("id") Integer id) { /** * 新增 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @PostMapping @@ -91,7 +91,7 @@ public ResponseBean add(@RequestBody ${className}Dto ${classNameLower}Dto) { /** * 更新 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @PutMapping @@ -106,7 +106,7 @@ public ResponseBean update(@RequestBody ${className}Dto ${classNameLower}Dto) { /** * 删除 - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @DeleteMapping("/{id}") diff --git a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dao/${className}Dao.java b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dao/${className}Dao.java index 3914cab..8dfcc38 100644 --- a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dao/${className}Dao.java +++ b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dao/${className}Dao.java @@ -11,7 +11,7 @@ /** * ${className}Dao - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Repository @@ -21,7 +21,7 @@ public interface ${className}Dao extends Mapper<${className}Dto> { * 列表 * @param ${classNameLower}Dto * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto); diff --git a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/custom/${className}Dto.java b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/custom/${className}Dto.java index 0a53390..90997de 100644 --- a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/custom/${className}Dto.java +++ b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/custom/${className}Dto.java @@ -10,7 +10,7 @@ /** * ${className}Dto - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Table(name = "${table.sqlName}") diff --git a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/domain/${className}DtoBase.java b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/domain/${className}DtoBase.java index aa2486f..e24583e 100644 --- a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/domain/${className}DtoBase.java +++ b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/dto/domain/${className}DtoBase.java @@ -20,7 +20,7 @@ /** * ${className}DtoBase - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public class ${className}DtoBase implements Serializable { diff --git a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/I${className}Service.java b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/I${className}Service.java index d302dc9..0f4619f 100644 --- a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/I${className}Service.java +++ b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/I${className}Service.java @@ -10,7 +10,7 @@ /** * I${className}Service - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public interface I${className}Service extends IBaseService<${className}Dto> { @@ -19,7 +19,7 @@ public interface I${className}Service extends IBaseService<${className}Dto> { * 列表 * @param ${classNameLower}Dto * @return java.util.List<${basepackage}.dto.custom.${className}Dto;> - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ public List<${className}Dto> findPageInfo(${className}Dto ${classNameLower}Dto); diff --git a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java index 97ea84c..2a3b91e 100644 --- a/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java +++ b/src/main/resources/template/two/RESTful/java/${basepackage_dir}/service/impl/${className}ServiceImpl.java @@ -15,7 +15,7 @@ /** * ${className}ServiceImpl - * @author Generator + * @author ${author} * @date ${now?string('yyyy-MM-dd HH:mm:ss')} */ @Service("${classNameLower}Service") diff --git a/src/main/resources/templates/config.html b/src/main/resources/templates/config.html index 30bbef4..e7455ee 100644 --- a/src/main/resources/templates/config.html +++ b/src/main/resources/templates/config.html @@ -42,6 +42,10 @@
配置
+ + + + @@ -91,30 +95,36 @@
说明
生成代码需要移除的表名前缀,例如t_user变User类则配置t_,使用逗号分隔同时配置多个前缀,示例: table_,t_(不能有空格)
+ +
模板代码的author属性(注释的作者名称),示例: Wang926454
+
+
模板代码的basepackage属性,示例: com.example
- +
模板代码的commonspackage属性,示例: com.example
- +
模板代码的namespace属性,示例: view
- +
模板代码的modulepackage属性,示例: generator
- + @@ -153,6 +163,8 @@
说明
template: '', // 生成代码需要移除的表名前缀 tableRemovePrefixes: '', + // 模板代码的author属性 + author: '', // 模板代码的basepackage属性 basepackage: '', // 模板代码的commonspackage属性 @@ -174,6 +186,9 @@
说明
tableRemovePrefixes: [ { required: true, message: '请输入tableRemovePrefixes', trigger: 'blur' } ], + author: [ + { required: true, message: '请输入author', trigger: 'blur' } + ], basepackage: [ { required: true, message: '请输入basepackage', trigger: 'blur' } ], @@ -225,7 +240,7 @@
说明
this.$notify({ dangerouslyUseHTMLString: true, title: '请等待', - message: '配置更新会导致应用热重启' + message: '配置更新会导致应用热重启' }); this.generator = data.data; setTimeout(() => { @@ -236,11 +251,6 @@
说明
}); }, 3033); } else { - this.$notify({ - dangerouslyUseHTMLString: true, - title: '提示', - message: data.msg - }); this.$message.error(data.msg); this.submitLoading = false; } diff --git a/src/main/resources/templates/table.html b/src/main/resources/templates/table.html index 76e4465..f069fea 100644 --- a/src/main/resources/templates/table.html +++ b/src/main/resources/templates/table.html @@ -180,6 +180,13 @@ } if (this.isLocalhost) { + } else { + this.$notify({ + dangerouslyUseHTMLString: true, + title: '当前环境判断为非本地运行环境', + message: '请谨慎使用生成代码到路径功能', + duration: 0 + }); } }, methods: { @@ -275,7 +282,7 @@ this.$notify({ dangerouslyUseHTMLString: true, title: '注意', - message: '输出路径为部署该应用的系统的路径' + message: '输出路径为部署该应用的系统的路径' }); } // 加载显示 @@ -300,7 +307,7 @@ this.$notify({ dangerouslyUseHTMLString: true, title: '注意', - message: '输出路径为部署该应用的系统的路径' + message: '输出路径为部署该应用的系统的路径' }); } // 加载显示 @@ -373,7 +380,7 @@ this.$notify({ title: '开始下载', dangerouslyUseHTMLString: true, - message: '压缩文件成功' + message: '压缩文件成功' }); }, 1111); } diff --git a/src/test/java/com/example/generator/GeneratorCode.java b/src/test/java/com/example/generator/GeneratorCode.java index eb10b25..be397a7 100644 --- a/src/test/java/com/example/generator/GeneratorCode.java +++ b/src/test/java/com/example/generator/GeneratorCode.java @@ -35,7 +35,7 @@ public class GeneratorCode extends BaseTest { /** * 有三点需要引起特别的注意 - * (1)数据库连接必须配置 + * (1)配置resource下config/generator.properties数据库信息 * (2)表无主键,无法生成 * (3)外键关联的表无读权限,无法生成 */