提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.gen.core.generator.restful.controller; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.gen.core.generator.base.AbstractCustomGenerator; |
|
4 |
import org.beetl.core.Template; |
|
5 |
|
|
6 |
import java.io.File; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
/** |
|
10 |
* 带restful接口控制器生成器 |
|
11 |
* |
|
12 |
* @author fengshuonan |
|
13 |
* @date 2018-12-13-2:20 PM |
|
14 |
*/ |
|
15 |
public class RestfulControllerGenerator extends AbstractCustomGenerator { |
|
16 |
|
|
17 |
public RestfulControllerGenerator(Map<String, Object> tableContext) { |
|
18 |
super(tableContext); |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public void bindingOthers(Template template) { |
|
23 |
template.binding("controllerPackage", contextParam.getProPackage() + ".controller"); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public String getTemplateResourcePath() { |
|
28 |
if (contextParam.getSwagger()) { |
|
29 |
return "/feignTemplates/RestfulControllerSwagger.btl"; |
|
30 |
} else { |
|
31 |
return "/feignTemplates/RestfulController.btl"; |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public String getGenerateFileTempPath() { |
|
37 |
String proPackage = this.contextParam.getProPackage(); |
|
38 |
String proPath = proPackage.replaceAll("\\.", "/"); |
|
39 |
File file = new File(contextParam.getOutputPath() + "/" + proPath + "/controller/" + tableContext.get("entity") + "Controller.java"); |
|
40 |
return file.getAbsolutePath(); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public String getGenerateFileDirectPath() { |
|
45 |
return this.getGenerateFileTempPath(); |
|
46 |
} |
|
47 |
} |