Skip to content

Commit 11c42db

Browse files
🚔 1.4.0 用户角色权限部门
1 parent c6ff840 commit 11c42db

File tree

2 files changed

+135
-47
lines changed

2 files changed

+135
-47
lines changed

README-zh.md

Lines changed: 69 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,33 +146,78 @@ INSERT INTO spring_boot_plus.sys_user (id, username, nickname, password, salt, r
146146
```java
147147
/**
148148
* spring-boot-plus代码生成器入口类
149+
*
149150
* @author geekidea
150-
* @date 2018-11-08
151-
*/
152-
public class CodeGenerator {
153-
private static final String USER_NAME = "root";
154-
private static final String PASSWORD = "root";
155-
private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
156-
private static final String DRIVER_URL = "jdbc:mysql://localhost:3306/spring_boot_plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
157-
// CODE...
158-
// ############################ 配置部分 start ############################
159-
// 模块名称
160-
private static final String MODULE_NAME = "system";
161-
// 作者
162-
private static final String AUTHOR = "geekidea";
163-
// 生成的表名称
164-
private static final String TABLE_NAME = "sys_user";
165-
// 主键数据库列名称
166-
private static final String PK_ID_COLUMN_NAME = "id";
167-
// 代码生成策略 true:All/false:SIMPLE
168-
private static final boolean GENERATOR_STRATEGY = true;
169-
// 分页列表查询是否排序 true:有排序参数/false:无
170-
private static final boolean PAGE_LIST_ORDER = false;
171-
// ############################ 配置部分 end ############################
172-
151+
* @date 2019-10-22
152+
**/
153+
public class SpringBootPlusGenerator {
154+
173155
public static void main(String[] args) {
174-
// Run...
156+
CodeGenerator codeGenerator = new CodeGenerator();
157+
// 公共配置
158+
// 数据库配置
159+
codeGenerator
160+
.setUserName("root")
161+
.setPassword("root")
162+
.setDriverName("com.mysql.jdbc.Driver")
163+
.setDriverUrl("jdbc:mysql://localhost:3306/spring_boot_plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
164+
165+
// 包信息
166+
codeGenerator
167+
.setProjectPackagePath("io/geekidea/springbootplus")
168+
.setParentPackage("io.geekidea.springbootplus");
169+
170+
// 组件作者等配置
171+
codeGenerator
172+
.setModuleName("system")
173+
.setAuthor("geekidea")
174+
.setPkIdColumnName("id");
175+
176+
// 生成策略
177+
codeGenerator
178+
.setGeneratorStrategy(CodeGenerator.GeneratorStrategy.ALL)
179+
.setPageListOrder(true)
180+
.setParamValidation(true);
181+
182+
// 生成实体映射相关代码,可用于数据库字段更新
183+
// 当数据库字段更新时,可自定义自动生成哪些那文件
184+
codeGenerator
185+
.setGeneratorEntity(true)
186+
.setGeneratorQueryParam(true)
187+
.setGeneratorQueryVo(true);
188+
189+
// 生成业务相关代码
190+
codeGenerator
191+
.setGeneratorController(true)
192+
.setGeneratorService(true)
193+
.setGeneratorServiceImpl(true)
194+
.setGeneratorMapper(true)
195+
.setGeneratorMapperXml(true);
196+
197+
// 是否覆盖已有文件
198+
codeGenerator.setFileOverride(true);
199+
200+
// 初始化公共变量
201+
codeGenerator.init();
202+
203+
// 需要生成的表数组
204+
// xxx,yyy,zzz为需要生成代码的表名称
205+
String[] tables = {
206+
"xxx",
207+
"yyy",
208+
"zzz",
209+
};
210+
211+
// 循环生成
212+
for (String table : tables) {
213+
// 设置需要生成的表名称
214+
codeGenerator.setTableName(table);
215+
// 生成代码
216+
codeGenerator.generator();
217+
}
218+
175219
}
220+
176221
}
177222
```
178223

README.md

Lines changed: 66 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -149,33 +149,76 @@ INSERT INTO spring_boot_plus.sys_user (id, username, nickname, password, salt, r
149149
```java
150150
/**
151151
* spring-boot-plus Code Generator
152+
*
152153
* @author geekidea
153-
* @date 2018-11-08
154-
*/
155-
public class CodeGenerator {
156-
private static final String USER_NAME = "root";
157-
private static final String PASSWORD = "root";
158-
private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
159-
private static final String DRIVER_URL = "jdbc:mysql://localhost:3306/spring_boot_plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
160-
// CODE...
161-
// ############################ Config start ############################
162-
// Module name
163-
private static final String MODULE_NAME = "system";
164-
// Author
165-
private static final String AUTHOR = "geekidea";
166-
// Table name
167-
private static final String TABLE_NAME = "sys_user";
168-
// Primary key id
169-
private static final String PK_ID_COLUMN_NAME = "id";
170-
// Generator strategy. true:All / false:SIMPLE
171-
private static final boolean GENERATOR_STRATEGY = true;
172-
// Pagination list query Whether to sort. true:sort/false:non
173-
private static final boolean PAGE_LIST_ORDER = false;
174-
// ############################ Config end ############################
154+
* @date 2019-10-22
155+
**/
156+
public class SpringBootPlusGenerator {
175157

176158
public static void main(String[] args) {
177-
// Run...
159+
CodeGenerator codeGenerator = new CodeGenerator();
160+
// Common configuration
161+
// Database configuration
162+
codeGenerator
163+
.setUserName("root")
164+
.setPassword("root")
165+
.setDriverName("com.mysql.jdbc.Driver")
166+
.setDriverUrl("jdbc:mysql://localhost:3306/spring_boot_plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false");
167+
168+
// Configuration package information
169+
codeGenerator
170+
.setProjectPackagePath("io/geekidea/springbootplus")
171+
.setParentPackage("io.geekidea.springbootplus");
172+
173+
// Configuration of component author, etc.
174+
codeGenerator
175+
.setModuleName("system")
176+
.setAuthor("geekidea")
177+
.setPkIdColumnName("id");
178+
179+
// Generation strategy
180+
codeGenerator
181+
.setGeneratorStrategy(CodeGenerator.GeneratorStrategy.ALL)
182+
.setPageListOrder(true)
183+
.setParamValidation(true);
184+
185+
// Customize which files are generated automatically
186+
codeGenerator
187+
.setGeneratorEntity(true)
188+
.setGeneratorQueryParam(true)
189+
.setGeneratorQueryVo(true);
190+
191+
// Generate business related codes
192+
codeGenerator
193+
.setGeneratorController(true)
194+
.setGeneratorService(true)
195+
.setGeneratorServiceImpl(true)
196+
.setGeneratorMapper(true)
197+
.setGeneratorMapperXml(true);
198+
199+
// Overwrite existing file or not
200+
codeGenerator.setFileOverride(true);
201+
202+
// Initialize common variables
203+
codeGenerator.init();
204+
205+
// Table array to be generated
206+
String[] tables = {
207+
"xxx",
208+
"yyy",
209+
"zzz",
210+
};
211+
212+
// Cycle generation
213+
for (String table : tables) {
214+
// Set the name of the table to be generated
215+
codeGenerator.setTableName(table);
216+
// Generate code
217+
codeGenerator.generator();
218+
}
219+
178220
}
221+
179222
}
180223
```
181224

0 commit comments

Comments
 (0)