-
Notifications
You must be signed in to change notification settings - Fork 344
Expand file tree
/
Copy pathExtraCodeGenerateUtils.java
More file actions
59 lines (54 loc) · 1.67 KB
/
ExtraCodeGenerateUtils.java
File metadata and controls
59 lines (54 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.sjhy.plugin.tool;
import com.sjhy.plugin.dto.GenerateOptions;
import com.sjhy.plugin.entity.TableInfo;
import com.sjhy.plugin.entity.Template;
import com.sjhy.plugin.service.impl.CodeGenerateServiceImpl;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
/**
* 额外的代码生成工具
*
* @author makejava
* @version 1.0.0
* @since 2018/11/01 10:11
*/
public class ExtraCodeGenerateUtils {
/**
* 代码生成服务
*/
private CodeGenerateServiceImpl codeGenerateService;
/**
* 表信息对象
*/
private TableInfo tableInfo;
/**
* 生成配置
*/
private GenerateOptions generateOptions;
public ExtraCodeGenerateUtils(CodeGenerateServiceImpl codeGenerateService, TableInfo tableInfo, GenerateOptions generateOptions) {
this.codeGenerateService = codeGenerateService;
this.tableInfo = tableInfo;
this.generateOptions = generateOptions;
}
/**
* 生成代码
*
* @param templateName 模板名称
* @param param 附加参数
*/
public void run(String templateName, Map<String, Object> param) {
// 获取到模板
Template currTemplate = null;
for (Template template : CurrGroupUtils.getCurrTemplateGroup().getElementList()) {
if (Objects.equals(template.getName(), templateName)) {
currTemplate = template;
}
}
if (currTemplate == null) {
return;
}
// 生成代码
codeGenerateService.generate(Collections.singletonList(currTemplate), Collections.singletonList(this.tableInfo), null, this.generateOptions, param);
}
}