docs: 更新文档
46
README.md
|
@ -6,10 +6,48 @@
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|
## 内置字段
|
||||||
|
|
||||||

|
```java
|
||||||
|
// vm 不能直接写 `{` 需要转换下
|
||||||
|
context.put("leftBrace", "{");
|
||||||
|
|
||||||
|
// 当前的表名
|
||||||
|
context.put("tableName", tableMetaData.getTableName());
|
||||||
|
|
||||||
|
// 当前表的列信息
|
||||||
|
context.put("columnInfoList", columnInfoList);
|
||||||
|
|
||||||
|
// 数据库sql列
|
||||||
|
context.put("baseColumnList", String.join(",", list));
|
||||||
|
|
||||||
|
// 当前日期
|
||||||
|
String date = new SimpleDateFormat(dto.getSimpleDateFormat()).format(new Date());
|
||||||
|
context.put("date", date);
|
||||||
|
|
||||||
|
// 作者名字
|
||||||
|
context.put("author", dto.getAuthor());
|
||||||
|
|
||||||
|
// 每个 Controller 上的请求前缀
|
||||||
|
context.put("requestMapping", dto.getRequestMapping());
|
||||||
|
|
||||||
|
// 表字段的注释内容
|
||||||
|
context.put("comment", dto.getComment());
|
||||||
|
|
||||||
|
// 设置包名称
|
||||||
|
context.put("package", dto.getPackageName());
|
||||||
|
|
||||||
|
// 将类名称转成小驼峰
|
||||||
|
String toCamelCase = TypeConvertCore.convertToCamelCase(replaceTableName);
|
||||||
|
context.put("classLowercaseName", toCamelCase);
|
||||||
|
|
||||||
|
// 将类名称转成大驼峰
|
||||||
|
String convertToCamelCase = TypeConvertCore.convertToCamelCase(replaceTableName, true);
|
||||||
|
context.put("classUppercaseName", convertToCamelCase);
|
||||||
|
```
|
||||||
|
|
||||||
|

|
|
@ -21,7 +21,7 @@ public abstract class AbstractVmsGenerator {
|
||||||
/**
|
/**
|
||||||
* Velocity 生成模板
|
* Velocity 生成模板
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context VelocityContext
|
||||||
* @param writer StringWriter 写入
|
* @param writer StringWriter 写入
|
||||||
*/
|
*/
|
||||||
abstract void templateMerge(VelocityContext context, StringWriter writer);
|
abstract void templateMerge(VelocityContext context, StringWriter writer);
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class VmsArgumentDtoBaseVmsGenerator extends AbstractVmsGenerator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加生成内容
|
* 添加生成内容
|
||||||
|
*
|
||||||
|
* @param context VelocityContext
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void addContext(VelocityContext context) {
|
void addContext(VelocityContext context) {
|
||||||
|
@ -43,18 +45,16 @@ public class VmsArgumentDtoBaseVmsGenerator extends AbstractVmsGenerator {
|
||||||
// 每个 Controller 上的请求前缀
|
// 每个 Controller 上的请求前缀
|
||||||
context.put("requestMapping", dto.getRequestMapping());
|
context.put("requestMapping", dto.getRequestMapping());
|
||||||
|
|
||||||
// 类名称如果是小驼峰,需要 [手写] 为 [下划线] 之后由 [代码 -> 小驼峰/大驼峰]
|
|
||||||
String className = dto.getClassName();
|
|
||||||
|
|
||||||
// 去除表开头前缀
|
|
||||||
String tablePrefixes = dto.getTablePrefixes();
|
|
||||||
|
|
||||||
// 表字段的注释内容
|
// 表字段的注释内容
|
||||||
context.put("comment", dto.getComment());
|
context.put("comment", dto.getComment());
|
||||||
|
|
||||||
// 设置包名称
|
// 设置包名称
|
||||||
context.put("package", dto.getPackageName());
|
context.put("package", dto.getPackageName());
|
||||||
|
|
||||||
|
// 类名称如果是小驼峰,需要 [手写] 为 [下划线] 之后由 [代码 -> 小驼峰/大驼峰]
|
||||||
|
String className = dto.getClassName();
|
||||||
|
// 去除表开头前缀
|
||||||
|
String tablePrefixes = dto.getTablePrefixes();
|
||||||
// 将 表前缀 转成数组
|
// 将 表前缀 转成数组
|
||||||
String replaceTableName = "";
|
String replaceTableName = "";
|
||||||
for (String prefix : tablePrefixes.split("[,,]")) {
|
for (String prefix : tablePrefixes.split("[,,]")) {
|
||||||
|
@ -73,7 +73,8 @@ public class VmsArgumentDtoBaseVmsGenerator extends AbstractVmsGenerator {
|
||||||
/**
|
/**
|
||||||
* Velocity 生成模板
|
* Velocity 生成模板
|
||||||
*
|
*
|
||||||
* @param writer StringWriter 写入
|
* @param context VelocityContext
|
||||||
|
* @param writer StringWriter 写入
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void templateMerge(VelocityContext context, StringWriter writer) {
|
void templateMerge(VelocityContext context, StringWriter writer) {
|
||||||
|
|
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 246 KiB |