From c2ad991110bb409360b7fa932527dfa148efc3c0 Mon Sep 17 00:00:00 2001
From: D <3066417822@qq.com>
Date: Sun, 14 Jan 2024 01:52:09 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=96=E9=94=AE=E6=A8=A1=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
doc/代码生成.drawio | 87 +++++++
doc/登录+JWT逻辑.drawio | 82 +++----
.../com/ruoyi/generator/domain/GenTable.java | 21 +-
.../generator/domain/GenTableColumn.java | 59 ++++-
.../service/GenTableServiceImpl.java | 217 +++++++-----------
.../ruoyi/generator/util/VelocityUtils.java | 11 +-
.../mapper/generator/GenTableColumnMapper.xml | 22 +-
.../mapper/generator/GenTableMapper.xml | 19 +-
.../src/main/resources/vm/java/domain.java.vm | 32 +++
.../src/main/resources/vm/vue/v2/index.vue.vm | 28 +--
.../src/main/resources/vm/vue/v3/index.vue.vm | 71 +++++-
.../src/main/resources/vm/xml/mapper.xml.vm | 21 +-
12 files changed, 448 insertions(+), 222 deletions(-)
create mode 100644 doc/代码生成.drawio
diff --git a/doc/代码生成.drawio b/doc/代码生成.drawio
new file mode 100644
index 0000000..9ede539
--- /dev/null
+++ b/doc/代码生成.drawio
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/登录+JWT逻辑.drawio b/doc/登录+JWT逻辑.drawio
index d2bf464..142315f 100644
--- a/doc/登录+JWT逻辑.drawio
+++ b/doc/登录+JWT逻辑.drawio
@@ -1,137 +1,137 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
index f6bfa81..f13c715 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
@@ -1,12 +1,15 @@
package com.ruoyi.generator.domain;
import java.util.List;
-import jakarta.validation.Valid;
-import jakarta.validation.constraints.NotBlank;
+
import org.apache.commons.lang3.ArrayUtils;
-import com.ruoyi.generator.constant.GenConstants;
+
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.generator.constant.GenConstants;
+
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
/**
* 业务表 gen_table
@@ -97,6 +100,18 @@ public class GenTable extends BaseEntity {
/** 上级菜单名称字段 */
private String parentMenuName;
+
+ /** 是否含有关联字段 */
+ private String haveSubColumn;
+
+ public String getHaveSubColumn() {
+ return haveSubColumn;
+ }
+
+ public void setHaveSubColumn(String haveSubColumn) {
+ this.haveSubColumn = haveSubColumn;
+ }
+
public Long getTableId() {
return tableId;
}
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
index 3dc6d62..c9c9e0f 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
@@ -1,9 +1,10 @@
package com.ruoyi.generator.domain;
-import jakarta.validation.constraints.NotBlank;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils;
+import jakarta.validation.constraints.NotBlank;
+
/**
* 代码生成业务字段表 gen_table_column
*
@@ -68,6 +69,62 @@ public class GenTableColumn extends BaseEntity
/** 排序 */
private Integer sort;
+ /** 关联表名称 */
+ private String subColumnTableName;
+
+ /** 关联字段名称 */
+ private String subColumnFkName;
+
+ /** 映射字段名称 */
+ private String subColumnName;
+
+
+ /** 映射字段Java字段名 */
+ private String subColumnJavaField;
+
+ /** 映射字段Java类型 */
+ private String subColumnJavaType;
+
+ public String getSubColumnJavaField() {
+ return subColumnJavaField;
+ }
+
+ public void setSubColumnJavaField(String subColumnJavaField) {
+ this.subColumnJavaField = subColumnJavaField;
+ }
+
+ public String getSubColumnJavaType() {
+ return subColumnJavaType;
+ }
+
+ public void setSubColumnJavaType(String subColumnJavaType) {
+ this.subColumnJavaType = subColumnJavaType;
+ }
+
+ public String getSubColumnTableName() {
+ return subColumnTableName;
+ }
+
+ public void setSubColumnTableName(String subColumnTableName) {
+ this.subColumnTableName = subColumnTableName;
+ }
+
+ public String getSubColumnFkName() {
+ return subColumnFkName;
+ }
+
+ public void setSubColumnFkName(String subColumnFkName) {
+ this.subColumnFkName = subColumnFkName;
+ }
+
+ public String getSubColumnName() {
+ return subColumnName;
+ }
+
+ public void setSubColumnName(String subColumnName) {
+ this.subColumnName = subColumnName;
+ }
+
public void setColumnId(Long columnId)
{
this.columnId = columnId;
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
index eeb8125..3b9de65 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
@@ -11,6 +11,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
@@ -21,14 +22,15 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.Constants;
-import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.common.core.text.CharsetKit;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper;
@@ -43,8 +45,7 @@ import com.ruoyi.generator.util.VelocityUtils;
* @author ruoyi
*/
@Service
-public class GenTableServiceImpl implements IGenTableService
-{
+public class GenTableServiceImpl implements IGenTableService {
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
@Autowired
@@ -60,8 +61,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 业务信息
*/
@Override
- public GenTable selectGenTableById(Long id)
- {
+ public GenTable selectGenTableById(Long id) {
GenTable genTable = genTableMapper.selectGenTableById(id);
setTableFromOptions(genTable);
return genTable;
@@ -74,8 +74,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 业务集合
*/
@Override
- public List selectGenTableList(GenTable genTable)
- {
+ public List selectGenTableList(GenTable genTable) {
return genTableMapper.selectGenTableList(genTable);
}
@@ -86,8 +85,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据库表集合
*/
@Override
- public List selectDbTableList(GenTable genTable)
- {
+ public List selectDbTableList(GenTable genTable) {
return genTableMapper.selectDbTableList(genTable);
}
@@ -98,8 +96,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据库表集合
*/
@Override
- public List selectDbTableListByNames(String[] tableNames)
- {
+ public List selectDbTableListByNames(String[] tableNames) {
return genTableMapper.selectDbTableListByNames(tableNames);
}
@@ -109,8 +106,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 表信息集合
*/
@Override
- public List selectGenTableAll()
- {
+ public List selectGenTableAll() {
return genTableMapper.selectGenTableAll();
}
@@ -122,15 +118,12 @@ public class GenTableServiceImpl implements IGenTableService
*/
@Override
@Transactional
- public void updateGenTable(GenTable genTable)
- {
+ public void updateGenTable(GenTable genTable) {
String options = JSON.toJSONString(genTable.getParams());
genTable.setOptions(options);
int row = genTableMapper.updateGenTable(genTable);
- if (row > 0)
- {
- for (GenTableColumn cenTableColumn : genTable.getColumns())
- {
+ if (row > 0) {
+ for (GenTableColumn cenTableColumn : genTable.getColumns()) {
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
}
}
@@ -144,8 +137,7 @@ public class GenTableServiceImpl implements IGenTableService
*/
@Override
@Transactional
- public void deleteGenTableByIds(Long[] tableIds)
- {
+ public void deleteGenTableByIds(Long[] tableIds) {
genTableMapper.deleteGenTableByIds(tableIds);
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
}
@@ -157,30 +149,23 @@ public class GenTableServiceImpl implements IGenTableService
*/
@Override
@Transactional
- public void importGenTable(List tableList)
- {
+ public void importGenTable(List tableList) {
String operName = SecurityUtils.getUsername();
- try
- {
- for (GenTable table : tableList)
- {
+ try {
+ for (GenTable table : tableList) {
String tableName = table.getTableName();
GenUtils.initTable(table, operName);
int row = genTableMapper.insertGenTable(table);
- if (row > 0)
- {
+ if (row > 0) {
// 保存列信息
List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
- for (GenTableColumn column : genTableColumns)
- {
+ for (GenTableColumn column : genTableColumns) {
GenUtils.initColumnField(column, table);
genTableColumnMapper.insertGenTableColumn(column);
}
}
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new ServiceException("导入失败:" + e.getMessage());
}
}
@@ -192,8 +177,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 预览数据列表
*/
@Override
- public Map previewCode(Long tableId)
- {
+ public Map previewCode(Long tableId) {
Map dataMap = new LinkedHashMap<>();
// 查询表信息
GenTable table = genTableMapper.selectGenTableById(tableId);
@@ -207,8 +191,7 @@ public class GenTableServiceImpl implements IGenTableService
// 获取模板列表
List templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
- for (String template : templates)
- {
+ for (String template : templates) {
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
@@ -225,8 +208,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据
*/
@Override
- public byte[] downloadCode(String tableName)
- {
+ public byte[] downloadCode(String tableName) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
generatorCode(tableName, zip);
@@ -240,8 +222,7 @@ public class GenTableServiceImpl implements IGenTableService
* @param tableName 表名称
*/
@Override
- public void generatorCode(String tableName)
- {
+ public void generatorCode(String tableName) {
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
@@ -255,23 +236,16 @@ public class GenTableServiceImpl implements IGenTableService
// 获取模板列表
List templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
- for (String template : templates)
- {
- if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
- {
- // 渲染模板
- StringWriter sw = new StringWriter();
- Template tpl = Velocity.getTemplate(template, Constants.UTF8);
- tpl.merge(context, sw);
- try
- {
- String path = getGenPath(table, template);
- FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
- }
- catch (IOException e)
- {
- throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
- }
+ for (String template : templates) {
+ // 渲染模板
+ StringWriter sw = new StringWriter();
+ Template tpl = Velocity.getTemplate(template, Constants.UTF8);
+ tpl.merge(context, sw);
+ try {
+ String path = getGenPath(table, template);
+ FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
+ } catch (IOException e) {
+ throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
}
}
}
@@ -283,50 +257,45 @@ public class GenTableServiceImpl implements IGenTableService
*/
@Override
@Transactional
- public void synchDb(String tableName)
- {
+ public void synchDb(String tableName) {
GenTable table = genTableMapper.selectGenTableByName(tableName);
List tableColumns = table.getColumns();
- Map tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
+ Map tableColumnMap = tableColumns.stream()
+ .collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
- if (StringUtils.isEmpty(dbTableColumns))
- {
+ if (StringUtils.isEmpty(dbTableColumns)) {
throw new ServiceException("同步数据失败,原表结构不存在");
}
- List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
+ List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName)
+ .collect(Collectors.toList());
dbTableColumns.forEach(column -> {
GenUtils.initColumnField(column, table);
- if (tableColumnMap.containsKey(column.getColumnName()))
- {
+ if (tableColumnMap.containsKey(column.getColumnName())) {
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
column.setColumnId(prevColumn.getColumnId());
- if (column.isList())
- {
+ if (column.isList()) {
// 如果是列表,继续保留查询方式/字典类型选项
column.setDictType(prevColumn.getDictType());
column.setQueryType(prevColumn.getQueryType());
}
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
&& (column.isInsert() || column.isEdit())
- && ((column.isUsableColumn()) || (!column.isSuperColumn())))
- {
+ && ((column.isUsableColumn()) || (!column.isSuperColumn()))) {
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType());
}
genTableColumnMapper.updateGenTableColumn(column);
- }
- else
- {
+ } else {
genTableColumnMapper.insertGenTableColumn(column);
}
});
- List delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
- if (StringUtils.isNotEmpty(delColumns))
- {
+ List delColumns = tableColumns.stream()
+ .filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
+ if (StringUtils.isNotEmpty(delColumns)) {
genTableColumnMapper.deleteGenTableColumns(delColumns);
}
}
@@ -338,12 +307,10 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据
*/
@Override
- public byte[] downloadCode(String[] tableNames)
- {
+ public byte[] downloadCode(String[] tableNames) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
- for (String tableName : tableNames)
- {
+ for (String tableName : tableNames) {
generatorCode(tableName, zip);
}
IOUtils.closeQuietly(zip);
@@ -353,8 +320,7 @@ public class GenTableServiceImpl implements IGenTableService
/**
* 查询表信息并生成代码
*/
- private void generatorCode(String tableName, ZipOutputStream zip)
- {
+ private void generatorCode(String tableName, ZipOutputStream zip) {
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
@@ -368,23 +334,19 @@ public class GenTableServiceImpl implements IGenTableService
// 获取模板列表
List templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
- for (String template : templates)
- {
+ for (String template : templates) {
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw);
- try
- {
+ try {
// 添加到zip
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
IOUtils.write(sw.toString(), zip, Constants.UTF8);
IOUtils.closeQuietly(sw);
zip.flush();
zip.closeEntry();
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
log.error("渲染模板失败,表名:" + table.getTableName(), e);
}
}
@@ -396,32 +358,20 @@ public class GenTableServiceImpl implements IGenTableService
* @param genTable 业务信息
*/
@Override
- public void validateEdit(GenTable genTable)
- {
- if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
- {
+ public void validateEdit(GenTable genTable) {
+ if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
String options = JSON.toJSONString(genTable.getParams());
JSONObject paramsObj = JSON.parseObject(options);
- if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
- {
+ if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
throw new ServiceException("树编码字段不能为空");
- }
- else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
- {
+ } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
throw new ServiceException("树父编码字段不能为空");
- }
- else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
- {
+ } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
throw new ServiceException("树名称字段不能为空");
- }
- else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
- {
- if (StringUtils.isEmpty(genTable.getSubTableName()))
- {
+ } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
+ if (StringUtils.isEmpty(genTable.getSubTableName())) {
throw new ServiceException("关联子表的表名不能为空");
- }
- else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
- {
+ } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
throw new ServiceException("子表关联的外键名不能为空");
}
}
@@ -433,32 +383,24 @@ public class GenTableServiceImpl implements IGenTableService
*
* @param table 业务表信息
*/
- public void setPkColumn(GenTable table)
- {
- for (GenTableColumn column : table.getColumns())
- {
- if (column.isPk())
- {
+ public void setPkColumn(GenTable table) {
+ for (GenTableColumn column : table.getColumns()) {
+ if (column.isPk()) {
table.setPkColumn(column);
break;
}
}
- if (StringUtils.isNull(table.getPkColumn()))
- {
+ if (StringUtils.isNull(table.getPkColumn())) {
table.setPkColumn(table.getColumns().get(0));
}
- if (GenConstants.TPL_SUB.equals(table.getTplCategory()))
- {
- for (GenTableColumn column : table.getSubTable().getColumns())
- {
- if (column.isPk())
- {
+ if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
+ for (GenTableColumn column : table.getSubTable().getColumns()) {
+ if (column.isPk()) {
table.getSubTable().setPkColumn(column);
break;
}
}
- if (StringUtils.isNull(table.getSubTable().getPkColumn()))
- {
+ if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
}
}
@@ -469,11 +411,9 @@ public class GenTableServiceImpl implements IGenTableService
*
* @param table 业务表信息
*/
- public void setSubTable(GenTable table)
- {
+ public void setSubTable(GenTable table) {
String subTableName = table.getSubTableName();
- if (StringUtils.isNotEmpty(subTableName))
- {
+ if (StringUtils.isNotEmpty(subTableName)) {
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
}
}
@@ -483,11 +423,9 @@ public class GenTableServiceImpl implements IGenTableService
*
* @param genTable 设置后的生成对象
*/
- public void setTableFromOptions(GenTable genTable)
- {
+ public void setTableFromOptions(GenTable genTable) {
JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
- if (StringUtils.isNotNull(paramsObj))
- {
+ if (StringUtils.isNotNull(paramsObj)) {
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
@@ -505,16 +443,15 @@ public class GenTableServiceImpl implements IGenTableService
/**
* 获取代码生成地址
*
- * @param table 业务表信息
+ * @param table 业务表信息
* @param template 模板文件路径
* @return 生成地址
*/
- public static String getGenPath(GenTable table, String template)
- {
+ public static String getGenPath(GenTable table, String template) {
String genPath = table.getGenPath();
- if (StringUtils.equals(genPath, "/"))
- {
- return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
+ if (StringUtils.equals(genPath, "/")) {
+ return System.getProperty("user.dir") + File.separator + "src" + File.separator
+ + VelocityUtils.getFileName(template, table);
}
return genPath + File.separator + VelocityUtils.getFileName(template, table);
}
diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
index 45c0a4d..fd58655 100644
--- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
+++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
@@ -4,12 +4,14 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import org.apache.velocity.VelocityContext;
+
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
-import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn;
@@ -142,9 +144,6 @@ public class VelocityUtils
templates.add("vm/xml/mapper.xml.vm");
templates.add("vm/sql/sql.vm");
templates.add("vm/js/api.js.vm");
- templates.add("vm/uniapp/edit.vue.vm");
- templates.add("vm/uniapp/list.vue.vm");
- templates.add("vm/uniapp/show.vue.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory))
{
templates.add(useWebType + "/index.vue.vm");
@@ -158,6 +157,10 @@ public class VelocityUtils
templates.add(useWebType + "/index.vue.vm");
templates.add("vm/java/sub-domain.java.vm");
}
+
+ templates.add("vm/uniapp/edit.vue.vm");
+ templates.add("vm/uniapp/list.vue.vm");
+ templates.add("vm/uniapp/show.vue.vm");
return templates;
}
diff --git a/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
index 48153cd..0edf43e 100644
--- a/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
+++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
@@ -23,6 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
+
+
@@ -30,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
+ select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort,sub_column_table_name,sub_column_fk_name,sub_column_name,sub_column_java_type,sub_column_java_field, create_by, create_time, update_by, update_time from gen_table_column