修改注释显示

This commit is contained in:
bunny 2025-06-30 23:42:44 +08:00
parent 54fe820d26
commit 25c078cd57
5 changed files with 29 additions and 26 deletions

View File

@ -1,6 +1,7 @@
package cn.bunny.core.template;
import cn.bunny.domain.dto.VmsArgumentDto;
import cn.bunny.domain.entity.TableMetaData;
import cn.bunny.utils.TypeConvertUtil;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@ -18,17 +19,17 @@ public class VmsArgumentDtoBaseVmsGeneratorTemplate extends AbstractVmsGenerator
private final VmsArgumentDto dto;
private final String path;
private final String tableName;
private final TableMetaData tableMetaData;
/**
* @param dto 类名称可以自定义格式为 xxx_xxx
* @param path 当前路径
* @param tableName 表名称
* @param tableMetaData 表名称
*/
public VmsArgumentDtoBaseVmsGeneratorTemplate(VmsArgumentDto dto, String path, String tableName) {
public VmsArgumentDtoBaseVmsGeneratorTemplate(VmsArgumentDto dto, String path, TableMetaData tableMetaData) {
this.dto = dto;
this.path = path;
this.tableName = tableName;
this.tableMetaData = tableMetaData;
}
/**
@ -38,6 +39,11 @@ public class VmsArgumentDtoBaseVmsGeneratorTemplate extends AbstractVmsGenerator
*/
@Override
void addContext(VelocityContext context) {
// 当前的表名
String tableName = tableMetaData.getTableName();
// 表的注释内容
String comment = tableMetaData.getComment();
// 当前日期
String date = new SimpleDateFormat(dto.getSimpleDateFormat()).format(new Date());
context.put("date", date);
@ -49,7 +55,7 @@ public class VmsArgumentDtoBaseVmsGeneratorTemplate extends AbstractVmsGenerator
context.put("requestMapping", dto.getRequestMapping());
// 表字段的注释内容
context.put("comment", dto.getComment());
context.put("comment", comment);
// 设置包名称
context.put("package", dto.getPackageName());

View File

@ -36,9 +36,6 @@ public class VmsArgumentDto {
@Schema(name = "tablePrefixes", description = "去除表前缀")
private String tablePrefixes;
@Schema(name = "comment", description = "注释内容")
private String comment;
@Schema(name = "path", description = "路径")
private List<String> path;

View File

@ -44,7 +44,7 @@ public class VmsCodeGeneratorService {
return dto.getPath().stream()
.map(path -> {
VmsArgumentDtoBaseVmsGeneratorTemplate generator = new VmsArgumentDtoBaseVmsGeneratorTemplate(dto, path, tableName);
VmsArgumentDtoBaseVmsGeneratorTemplate generator = new VmsArgumentDtoBaseVmsGeneratorTemplate(dto, path, tableMetaData);
StringWriter writer = generator.generatorCodeTemplate(tableMetaData, columnInfoList);
String processedPath = VmsUtil.handleVmFilename(path, tableMetaData.getTableName());

View File

@ -18,12 +18,12 @@ const MainForm = {
<form class="card-body row" @submit.prevent="handleSubmit" novalidate>
<!-- 基本信息输入区域 -->
<div class="col-md-4 mb-3 has-validation">
<label class="form-label fw-medium" for="authorName">作者名称</label>
<input class="form-control border-secondary" :class="{ 'is-invalid': errors.authorName }"
id="authorName" placeholder="输入作者名称" v-model="form.authorName" type="text"
@input="validateField('authorName')">
<label class="form-label fw-medium" for="author">作者名称</label>
<input class="form-control border-secondary" :class="{ 'is-invalid': errors.author }"
id="author" placeholder="输入作者名称" v-model="form.author" type="text"
@input="validateField('author')">
<div class="invalid-feedback">
{{ errors.authorName || '请输入作者名称' }}
{{ errors.author || '请输入作者名称' }}
</div>
</div>
<div class="col-md-4 mb-3 has-validation">
@ -62,13 +62,13 @@ const MainForm = {
{{ errors.tablePrefixes || '请输入去除开头前缀' }}
</div>
</div>
<div class="col-md-4 mb-3">
<label class="form-label fw-medium" for="comment">注释内容</label>
<input class="form-control border-secondary" id="comment" placeholder="注释内容" v-model="form.comment"
type="text" />
</div>
<!-- <div class="col-md-4 mb-3"> -->
<!-- <label class="form-label fw-medium" for="comment">注释内容</label> -->
<!-- <input class="form-control border-secondary" id="comment" placeholder="注释内容" v-model="form.comment" -->
<!-- type="text" /> -->
<!-- </div> -->
<div class="col-md-12" v-show="form.tableNames.length > 0">
<label class="form-label fw-medium" for="comment">已选择的要生成表({{form.tableNames.length}})</label>
<label class="form-label fw-medium" for="tableNames">已选择的要生成表({{form.tableNames.length}})</label>
<span class="badge rounded-pill text-bg-dark me-1" v-for="(item,index) in form.tableNames" :ket="index">{{item}}</span>
</div>
@ -166,7 +166,7 @@ const MainForm = {
webList: ref([]),
// 错误信息对象
errors: {
authorName: '',
author: '',
requestMapping: '',
packageName: '',
simpleDateFormat: '',
@ -217,7 +217,7 @@ const MainForm = {
let isValid = true;
// 验证文本字段
const textFields = ['authorName', 'requestMapping', 'packageName', 'simpleDateFormat', 'tablePrefixes'];
const textFields = ['author', 'requestMapping', 'packageName', 'simpleDateFormat', 'tablePrefixes'];
textFields.forEach(field => {
if (!this.validateField(field)) {
isValid = false;

View File

@ -116,7 +116,7 @@
// 提交的表单
form: ref({
// 作者名称
authorName: "Bunny",
author: "Bunny",
// requestMapping名称
requestMapping: "/api",
// 表名称
@ -128,7 +128,7 @@
// 去除开头前缀
tablePrefixes: "t_,sys_,qrtz_,log_",
// 生成代码路径
path: []
path: [],
}),
// 是否显示生成页面
generatorPageFlag: ref(false),