This commit is contained in:
2019-04-15 18:58:48 +08:00
parent 9a7953aa47
commit c3b3cec3cb
6 changed files with 139 additions and 6 deletions

View File

@@ -189,4 +189,36 @@ public class RunTest<T> {
System.out.println(metaTables.size());
}
TplKit tplKit = TplKit.use();
@Test
public void buildMethod() {
tplKit.addTpl("/tpl/_t.tpl");
buildMethod("table_link_list", "实体表包含link信息的列表");
}
private void buildMethod(String url, String comment) {
String[] arr = url.split("_");
String methodName = "";
for (int i = 0; i < arr.length; i++) {
if (i == 0) {
methodName = arr[i].toLowerCase();
} else {
methodName += toUpperCaseFirst(arr[i].toLowerCase());
}
}
Kv kv = Kv.of("url", url).set("comment", comment).set("methodName", methodName);
String tpl = tplKit.getTpl("service.method", kv, false);
System.out.println(tpl);
}
private String toUpperCaseFirst(String str){
return str.substring(0, 1).toUpperCase() + str.substring(1);
}
}