Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
6e7d7aba
提交
6e7d7aba
authored
7月 24, 2020
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
代码生成支持自定义路径
上级
388e36ed
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
202 行增加
和
26 行删除
+202
-26
FileUtils.java
.../src/main/java/com/ruoyi/common/utils/file/FileUtils.java
+1
-1
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+0
-2
GenController.java
...in/java/com/ruoyi/generator/controller/GenController.java
+19
-6
GenTable.java
...or/src/main/java/com/ruoyi/generator/domain/GenTable.java
+26
-0
GenTableServiceImpl.java
...java/com/ruoyi/generator/service/GenTableServiceImpl.java
+67
-4
IGenTableService.java
...in/java/com/ruoyi/generator/service/IGenTableService.java
+12
-4
GenTableMapper.xml
...or/src/main/resources/mapper/generator/GenTableMapper.xml
+11
-3
gen.js
ruoyi-ui/src/api/tool/gen.js
+10
-0
genInfoForm.vue
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
+46
-4
index.vue
ruoyi-ui/src/views/tool/gen/index.vue
+8
-2
ry_20200724.sql
sql/ry_20200724.sql
+2
-0
没有找到文件。
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
浏览文件 @
6e7d7aba
...
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletRequest;
*
*
* @author ruoyi
* @author ruoyi
*/
*/
public
class
FileUtils
public
class
FileUtils
extends
org
.
apache
.
commons
.
io
.
FileUtils
{
{
public
static
String
FILENAME_PATTERN
=
"[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"
;
public
static
String
FILENAME_PATTERN
=
"[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+"
;
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
浏览文件 @
6e7d7aba
...
@@ -17,7 +17,6 @@ import java.util.List;
...
@@ -17,7 +17,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
...
@@ -41,7 +40,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
...
@@ -41,7 +40,6 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import
org.apache.poi.xssf.usermodel.XSSFDataValidation
;
import
org.apache.poi.xssf.usermodel.XSSFDataValidation
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.annotation.Excel.ColumnType
;
import
com.ruoyi.common.annotation.Excel.ColumnType
;
import
com.ruoyi.common.annotation.Excel.Type
;
import
com.ruoyi.common.annotation.Excel.Type
;
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
浏览文件 @
6e7d7aba
...
@@ -148,17 +148,29 @@ public class GenController extends BaseController
...
@@ -148,17 +148,29 @@ public class GenController extends BaseController
}
}
/**
/**
* 生成代码
* 生成代码
(下载方式)
*/
*/
@PreAuthorize
(
"@ss.hasPermi('tool:gen:code')"
)
@PreAuthorize
(
"@ss.hasPermi('tool:gen:code')"
)
@Log
(
title
=
"代码生成"
,
businessType
=
BusinessType
.
GENCODE
)
@Log
(
title
=
"代码生成"
,
businessType
=
BusinessType
.
GENCODE
)
@GetMapping
(
"/
genCode
/{tableName}"
)
@GetMapping
(
"/
download
/{tableName}"
)
public
void
genCode
(
HttpServletResponse
response
,
@PathVariable
(
"tableName"
)
String
tableName
)
throws
IOException
public
void
download
(
HttpServletResponse
response
,
@PathVariable
(
"tableName"
)
String
tableName
)
throws
IOException
{
{
byte
[]
data
=
genTableService
.
generator
Code
(
tableName
);
byte
[]
data
=
genTableService
.
download
Code
(
tableName
);
genCode
(
response
,
data
);
genCode
(
response
,
data
);
}
}
/**
* 生成代码(自定义路径)
*/
@PreAuthorize
(
"@ss.hasPermi('tool:gen:code')"
)
@Log
(
title
=
"代码生成"
,
businessType
=
BusinessType
.
GENCODE
)
@GetMapping
(
"/genCode/{tableName}"
)
public
AjaxResult
genCode
(
HttpServletResponse
response
,
@PathVariable
(
"tableName"
)
String
tableName
)
{
genTableService
.
generatorCode
(
tableName
);
return
AjaxResult
.
success
();
}
/**
/**
* 批量生成代码
* 批量生成代码
*/
*/
...
@@ -168,7 +180,7 @@ public class GenController extends BaseController
...
@@ -168,7 +180,7 @@ public class GenController extends BaseController
public
void
batchGenCode
(
HttpServletResponse
response
,
String
tables
)
throws
IOException
public
void
batchGenCode
(
HttpServletResponse
response
,
String
tables
)
throws
IOException
{
{
String
[]
tableNames
=
Convert
.
toStrArray
(
tables
);
String
[]
tableNames
=
Convert
.
toStrArray
(
tables
);
byte
[]
data
=
genTableService
.
generator
Code
(
tableNames
);
byte
[]
data
=
genTableService
.
download
Code
(
tableNames
);
genCode
(
response
,
data
);
genCode
(
response
,
data
);
}
}
...
@@ -185,4 +197,4 @@ public class GenController extends BaseController
...
@@ -185,4 +197,4 @@ public class GenController extends BaseController
response
.
setContentType
(
"application/octet-stream; charset=UTF-8"
);
response
.
setContentType
(
"application/octet-stream; charset=UTF-8"
);
IOUtils
.
write
(
data
,
response
.
getOutputStream
());
IOUtils
.
write
(
data
,
response
.
getOutputStream
());
}
}
}
}
\ No newline at end of file
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
浏览文件 @
6e7d7aba
...
@@ -55,6 +55,12 @@ public class GenTable extends BaseEntity
...
@@ -55,6 +55,12 @@ public class GenTable extends BaseEntity
@NotBlank
(
message
=
"作者不能为空"
)
@NotBlank
(
message
=
"作者不能为空"
)
private
String
functionAuthor
;
private
String
functionAuthor
;
/** 生成代码方式(0zip压缩包 1自定义路径) */
private
String
genType
;
/** 生成路径(不填默认项目路径) */
private
String
genPath
;
/** 主键信息 */
/** 主键信息 */
private
GenTableColumn
pkColumn
;
private
GenTableColumn
pkColumn
;
...
@@ -180,6 +186,26 @@ public class GenTable extends BaseEntity
...
@@ -180,6 +186,26 @@ public class GenTable extends BaseEntity
this
.
functionAuthor
=
functionAuthor
;
this
.
functionAuthor
=
functionAuthor
;
}
}
public
String
getGenType
()
{
return
genType
;
}
public
void
setGenType
(
String
genType
)
{
this
.
genType
=
genType
;
}
public
String
getGenPath
()
{
return
genPath
;
}
public
void
setGenPath
(
String
genPath
)
{
this
.
genPath
=
genPath
;
}
public
GenTableColumn
getPkColumn
()
public
GenTableColumn
getPkColumn
()
{
{
return
pkColumn
;
return
pkColumn
;
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
浏览文件 @
6e7d7aba
package
com
.
ruoyi
.
generator
.
service
;
package
com
.
ruoyi
.
generator
.
service
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
...
@@ -21,9 +22,11 @@ import com.alibaba.fastjson.JSON;
...
@@ -21,9 +22,11 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.GenConstants
;
import
com.ruoyi.common.constant.GenConstants
;
import
com.ruoyi.common.core.text.CharsetKit
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.file.FileUtils
;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTableColumn
;
import
com.ruoyi.generator.domain.GenTableColumn
;
import
com.ruoyi.generator.mapper.GenTableColumnMapper
;
import
com.ruoyi.generator.mapper.GenTableColumnMapper
;
...
@@ -202,13 +205,13 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -202,13 +205,13 @@ public class GenTableServiceImpl implements IGenTableService
}
}
/**
/**
* 生成代码
* 生成代码
(下载方式)
*
*
* @param tableName 表名称
* @param tableName 表名称
* @return 数据
* @return 数据
*/
*/
@Override
@Override
public
byte
[]
generator
Code
(
String
tableName
)
public
byte
[]
download
Code
(
String
tableName
)
{
{
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ZipOutputStream
zip
=
new
ZipOutputStream
(
outputStream
);
ZipOutputStream
zip
=
new
ZipOutputStream
(
outputStream
);
...
@@ -218,13 +221,55 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -218,13 +221,55 @@ public class GenTableServiceImpl implements IGenTableService
}
}
/**
/**
* 批量生成代码
* 生成代码(自定义路径)
*
* @param tableName 表名称
* @return 数据
*/
@Override
public
void
generatorCode
(
String
tableName
)
{
// 查询表信息
GenTable
table
=
genTableMapper
.
selectGenTableByName
(
tableName
);
// 查询列信息
List
<
GenTableColumn
>
columns
=
table
.
getColumns
();
setPkColumn
(
table
,
columns
);
VelocityInitializer
.
initVelocity
();
VelocityContext
context
=
VelocityUtils
.
prepareContext
(
table
);
// 获取模板列表
List
<
String
>
templates
=
VelocityUtils
.
getTemplateList
(
table
.
getTplCategory
());
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
CustomException
(
"渲染模板失败,表名:"
+
table
.
getTableName
());
}
}
}
}
/**
* 批量生成代码(下载方式)
*
*
* @param tableNames 表数组
* @param tableNames 表数组
* @return 数据
* @return 数据
*/
*/
@Override
@Override
public
byte
[]
generator
Code
(
String
[]
tableNames
)
public
byte
[]
download
Code
(
String
[]
tableNames
)
{
{
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
outputStream
=
new
ByteArrayOutputStream
();
ZipOutputStream
zip
=
new
ZipOutputStream
(
outputStream
);
ZipOutputStream
zip
=
new
ZipOutputStream
(
outputStream
);
...
@@ -347,4 +392,21 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -347,4 +392,21 @@ public class GenTableServiceImpl implements IGenTableService
genTable
.
setParentMenuName
(
parentMenuName
);
genTable
.
setParentMenuName
(
parentMenuName
);
}
}
}
}
/**
* 获取代码生成地址
*
* @param table 业务表信息
* @param template 模板文件路径
* @return 生成地址
*/
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
);
}
return
genPath
+
File
.
separator
+
VelocityUtils
.
getFileName
(
template
,
table
);
}
}
}
\ No newline at end of file
ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java
浏览文件 @
6e7d7aba
...
@@ -75,20 +75,28 @@ public interface IGenTableService
...
@@ -75,20 +75,28 @@ public interface IGenTableService
public
Map
<
String
,
String
>
previewCode
(
Long
tableId
);
public
Map
<
String
,
String
>
previewCode
(
Long
tableId
);
/**
/**
* 生成代码
* 生成代码
(下载方式)
*
*
* @param tableName 表名称
* @param tableName 表名称
* @return 数据
* @return 数据
*/
*/
public
byte
[]
generator
Code
(
String
tableName
);
public
byte
[]
download
Code
(
String
tableName
);
/**
/**
* 批量生成代码
* 生成代码(自定义路径)
*
* @param tableName 表名称
* @return 数据
*/
public
void
generatorCode
(
String
tableName
);
/**
* 批量生成代码(下载方式)
*
*
* @param tableNames 表数组
* @param tableNames 表数组
* @return 数据
* @return 数据
*/
*/
public
byte
[]
generator
Code
(
String
[]
tableNames
);
public
byte
[]
download
Code
(
String
[]
tableNames
);
/**
/**
* 修改保存参数校验
* 修改保存参数校验
...
...
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
浏览文件 @
6e7d7aba
...
@@ -15,6 +15,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -15,6 +15,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"businessName"
column=
"business_name"
/>
<result
property=
"businessName"
column=
"business_name"
/>
<result
property=
"functionName"
column=
"function_name"
/>
<result
property=
"functionName"
column=
"function_name"
/>
<result
property=
"functionAuthor"
column=
"function_author"
/>
<result
property=
"functionAuthor"
column=
"function_author"
/>
<result
property=
"genType"
column=
"gen_type"
/>
<result
property=
"genPath"
column=
"gen_path"
/>
<result
property=
"options"
column=
"options"
/>
<result
property=
"options"
column=
"options"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
<result
property=
"createTime"
column=
"create_time"
/>
...
@@ -50,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -50,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
</resultMap>
<sql
id=
"selectGenTableVo"
>
<sql
id=
"selectGenTableVo"
>
select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table
select table_id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author,
gen_type, gen_path,
options, create_by, create_time, update_by, update_time, remark from gen_table
</sql>
</sql>
<select
id=
"selectGenTableList"
parameterType=
"GenTable"
resultMap=
"GenTableResult"
>
<select
id=
"selectGenTableList"
parameterType=
"GenTable"
resultMap=
"GenTableResult"
>
...
@@ -106,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -106,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</select>
<select
id=
"selectGenTableById"
parameterType=
"Long"
resultMap=
"GenTableResult"
>
<select
id=
"selectGenTableById"
parameterType=
"Long"
resultMap=
"GenTableResult"
>
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.
gen_type, t.gen_path, t.
options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
...
@@ -114,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -114,7 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
</select>
<select
id=
"selectGenTableByName"
parameterType=
"String"
resultMap=
"GenTableResult"
>
<select
id=
"selectGenTableByName"
parameterType=
"String"
resultMap=
"GenTableResult"
>
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
SELECT t.table_id, t.table_name, t.table_comment, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.
gen_type, t.gen_path, t.
options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
...
@@ -132,6 +134,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -132,6 +134,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"businessName != null and businessName != ''"
>
business_name,
</if>
<if
test=
"businessName != null and businessName != ''"
>
business_name,
</if>
<if
test=
"functionName != null and functionName != ''"
>
function_name,
</if>
<if
test=
"functionName != null and functionName != ''"
>
function_name,
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
function_author,
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
function_author,
</if>
<if
test=
"genType != null and genType != ''"
>
gen_type,
</if>
<if
test=
"genPath != null and genPath != ''"
>
gen_path,
</if>
<if
test=
"remark != null and remark != ''"
>
remark,
</if>
<if
test=
"remark != null and remark != ''"
>
remark,
</if>
<if
test=
"createBy != null and createBy != ''"
>
create_by,
</if>
<if
test=
"createBy != null and createBy != ''"
>
create_by,
</if>
create_time
create_time
...
@@ -145,6 +149,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -145,6 +149,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"businessName != null and businessName != ''"
>
#{businessName},
</if>
<if
test=
"businessName != null and businessName != ''"
>
#{businessName},
</if>
<if
test=
"functionName != null and functionName != ''"
>
#{functionName},
</if>
<if
test=
"functionName != null and functionName != ''"
>
#{functionName},
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
#{functionAuthor},
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
#{functionAuthor},
</if>
<if
test=
"genType != null and genType != ''"
>
#{genType},
</if>
<if
test=
"genPath != null and genPath != ''"
>
#{genPath},
</if>
<if
test=
"remark != null and remark != ''"
>
#{remark},
</if>
<if
test=
"remark != null and remark != ''"
>
#{remark},
</if>
<if
test=
"createBy != null and createBy != ''"
>
#{createBy},
</if>
<if
test=
"createBy != null and createBy != ''"
>
#{createBy},
</if>
sysdate()
sysdate()
...
@@ -158,6 +164,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -158,6 +164,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"tableComment != null and tableComment != ''"
>
table_comment = #{tableComment},
</if>
<if
test=
"tableComment != null and tableComment != ''"
>
table_comment = #{tableComment},
</if>
<if
test=
"className != null and className != ''"
>
class_name = #{className},
</if>
<if
test=
"className != null and className != ''"
>
class_name = #{className},
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
function_author = #{functionAuthor},
</if>
<if
test=
"functionAuthor != null and functionAuthor != ''"
>
function_author = #{functionAuthor},
</if>
<if
test=
"genType != null and genType != ''"
>
gen_type = #{genType},
</if>
<if
test=
"genPath != null and genPath != ''"
>
gen_path = #{genPath},
</if>
<if
test=
"tplCategory != null and tplCategory != ''"
>
tpl_category = #{tplCategory},
</if>
<if
test=
"tplCategory != null and tplCategory != ''"
>
tpl_category = #{tplCategory},
</if>
<if
test=
"packageName != null and packageName != ''"
>
package_name = #{packageName},
</if>
<if
test=
"packageName != null and packageName != ''"
>
package_name = #{packageName},
</if>
<if
test=
"moduleName != null and moduleName != ''"
>
module_name = #{moduleName},
</if>
<if
test=
"moduleName != null and moduleName != ''"
>
module_name = #{moduleName},
</if>
...
...
ruoyi-ui/src/api/tool/gen.js
浏览文件 @
6e7d7aba
...
@@ -42,6 +42,7 @@ export function importTable(data) {
...
@@ -42,6 +42,7 @@ export function importTable(data) {
params
:
data
params
:
data
})
})
}
}
// 预览生成代码
// 预览生成代码
export
function
previewTable
(
tableId
)
{
export
function
previewTable
(
tableId
)
{
return
request
({
return
request
({
...
@@ -49,6 +50,7 @@ export function previewTable(tableId) {
...
@@ -49,6 +50,7 @@ export function previewTable(tableId) {
method
:
'get'
method
:
'get'
})
})
}
}
// 删除表数据
// 删除表数据
export
function
delTable
(
tableId
)
{
export
function
delTable
(
tableId
)
{
return
request
({
return
request
({
...
@@ -57,3 +59,11 @@ export function delTable(tableId) {
...
@@ -57,3 +59,11 @@ export function delTable(tableId) {
})
})
}
}
// 生成代码(自定义路径)
export
function
genCode
(
tableName
)
{
return
request
({
url
:
'/tool/gen/genCode/'
+
tableName
,
method
:
'get'
})
}
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
浏览文件 @
6e7d7aba
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<span
slot=
"label"
>
生成模板
</span>
<span
slot=
"label"
>
生成模板
</span>
<el-select
v-model=
"info.tplCategory"
>
<el-select
v-model=
"info.tplCategory"
>
<el-option
label=
"单表(增删改查)"
value=
"crud"
/>
<el-option
label=
"单表(增删改查)"
value=
"crud"
/>
<el-option
label=
"树表(增删改查)"
value=
"tree"
/>
<el-option
label=
"树表(增删改查)"
value=
"tree"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
...
@@ -60,14 +60,56 @@
...
@@ -60,14 +60,56 @@
</el-col>
</el-col>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
<el-form-item
prop=
"functionName"
>
<el-form-item>
<span
slot=
"label"
>
<span
slot=
"label"
>
上级菜单
上级菜单
<el-tooltip
content=
"分配到指定菜单下,例如 系统管理"
placement=
"top"
>
<el-tooltip
content=
"分配到指定菜单下,例如 系统管理"
placement=
"top"
>
<i
class=
"el-icon-question"
></i>
<i
class=
"el-icon-question"
></i>
</el-tooltip>
</el-tooltip>
</span>
</span>
<treeselect
:append-to-body=
"true"
v-model=
"info.parentMenuId"
:options=
"menus"
:normalizer=
"normalizer"
:show-count=
"true"
placeholder=
"请选择系统菜单"
/>
<treeselect
:append-to-body=
"true"
v-model=
"info.parentMenuId"
:options=
"menus"
:normalizer=
"normalizer"
:show-count=
"true"
placeholder=
"请选择系统菜单"
/>
</el-form-item>
</el-col>
<el-col
:span=
"12"
>
<el-form-item
prop=
"genType"
>
<span
slot=
"label"
>
生成代码方式
<el-tooltip
content=
"默认为zip压缩包下载,也可以自定义生成路径"
placement=
"top"
>
<i
class=
"el-icon-question"
></i>
</el-tooltip>
</span>
<el-radio
v-model=
"info.genType"
label=
"0"
>
zip压缩包
</el-radio>
<el-radio
v-model=
"info.genType"
label=
"1"
>
自定义路径
</el-radio>
</el-form-item>
</el-col>
<el-col
:span=
"24"
v-if=
"info.genType == '1'"
>
<el-form-item
prop=
"genPath"
>
<span
slot=
"label"
>
自定义路径
<el-tooltip
content=
"填写磁盘绝对路径,若不填写,则生成到当前Web项目下"
placement=
"top"
>
<i
class=
"el-icon-question"
></i>
</el-tooltip>
</span>
<el-input
v-model=
"info.genPath"
>
<el-dropdown
slot=
"append"
>
<el-button
type=
"primary"
>
最近路径快速选择
<i
class=
"el-icon-arrow-down el-icon--right"
></i>
</el-button>
<el-dropdown-menu
slot=
"dropdown"
>
<el-dropdown-item
@
click
.
native=
"info.genPath = '/'"
>
恢复默认的生成基础路径
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-input>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
...
@@ -165,7 +207,7 @@ export default {
...
@@ -165,7 +207,7 @@ export default {
],
],
functionName
:
[
functionName
:
[
{
required
:
true
,
message
:
"请输入生成功能名"
,
trigger
:
"blur"
}
{
required
:
true
,
message
:
"请输入生成功能名"
,
trigger
:
"blur"
}
]
]
,
}
}
};
};
},
},
...
...
ruoyi-ui/src/views/tool/gen/index.vue
浏览文件 @
6e7d7aba
...
@@ -166,7 +166,7 @@
...
@@ -166,7 +166,7 @@
</template>
</template>
<
script
>
<
script
>
import
{
listTable
,
previewTable
,
delTable
}
from
"@/api/tool/gen"
;
import
{
listTable
,
previewTable
,
delTable
,
genCode
}
from
"@/api/tool/gen"
;
import
importTable
from
"./importTable"
;
import
importTable
from
"./importTable"
;
import
{
downLoadZip
}
from
"@/utils/zipdownload"
;
import
{
downLoadZip
}
from
"@/utils/zipdownload"
;
export
default
{
export
default
{
...
@@ -241,7 +241,13 @@ export default {
...
@@ -241,7 +241,13 @@ export default {
this
.
msgError
(
"请选择要生成的数据"
);
this
.
msgError
(
"请选择要生成的数据"
);
return
;
return
;
}
}
downLoadZip
(
"/tool/gen/batchGenCode?tables="
+
tableNames
,
"ruoyi"
);
if
(
row
.
genType
===
"1"
)
{
genCode
(
row
.
tableName
).
then
(
response
=>
{
this
.
msgSuccess
(
"成功生成到自定义路径:"
+
row
.
genPath
);
});
}
else
{
downLoadZip
(
"/tool/gen/batchGenCode?tables="
+
tableNames
,
"ruoyi"
);
}
},
},
/** 打开导入表弹窗 */
/** 打开导入表弹窗 */
openImportTable
()
{
openImportTable
()
{
...
...
sql/ry_2020072
3
.sql
→
sql/ry_2020072
4
.sql
浏览文件 @
6e7d7aba
...
@@ -635,6 +635,8 @@ create table gen_table (
...
@@ -635,6 +635,8 @@ create table gen_table (
business_name
varchar
(
30
)
comment
'生成业务名'
,
business_name
varchar
(
30
)
comment
'生成业务名'
,
function_name
varchar
(
50
)
comment
'生成功能名'
,
function_name
varchar
(
50
)
comment
'生成功能名'
,
function_author
varchar
(
50
)
comment
'生成功能作者'
,
function_author
varchar
(
50
)
comment
'生成功能作者'
,
gen_type
char
(
1
)
default
'0'
comment
'生成代码方式(0zip压缩包 1自定义路径)'
,
gen_path
varchar
(
200
)
default
'/'
comment
'生成路径(不填默认项目路径)'
,
options
varchar
(
1000
)
comment
'其它生成选项'
,
options
varchar
(
1000
)
comment
'其它生成选项'
,
create_by
varchar
(
64
)
default
''
comment
'创建者'
,
create_by
varchar
(
64
)
default
''
comment
'创建者'
,
create_time
datetime
comment
'创建时间'
,
create_time
datetime
comment
'创建时间'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论