Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
T
topology
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
姜立玮
topology
Commits
9e38c7de
提交
9e38c7de
authored
4 年前
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
代码生成支持同步数据库
上级
9ca28d6d
变更
8
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
96 行增加
和
5 行删除
+96
-5
GenController.java
...in/java/com/ruoyi/generator/controller/GenController.java
+13
-1
GenTableColumnMapper.java
...java/com/ruoyi/generator/mapper/GenTableColumnMapper.java
+9
-1
GenTableServiceImpl.java
...java/com/ruoyi/generator/service/GenTableServiceImpl.java
+32
-1
IGenTableService.java
...in/java/com/ruoyi/generator/service/IGenTableService.java
+7
-0
GenTableColumnMapper.xml
.../main/resources/mapper/generator/GenTableColumnMapper.xml
+6
-0
GenTableMapper.xml
...or/src/main/resources/mapper/generator/GenTableMapper.xml
+1
-1
gen.js
ruoyi-ui/src/api/tool/gen.js
+7
-0
index.vue
ruoyi-ui/src/views/tool/gen/index.vue
+21
-1
没有找到文件。
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
浏览文件 @
9e38c7de
...
...
@@ -165,12 +165,24 @@ public class GenController extends BaseController
@PreAuthorize
(
"@ss.hasPermi('tool:gen:code')"
)
@Log
(
title
=
"代码生成"
,
businessType
=
BusinessType
.
GENCODE
)
@GetMapping
(
"/genCode/{tableName}"
)
public
AjaxResult
genCode
(
HttpServletResponse
response
,
@PathVariable
(
"tableName"
)
String
tableName
)
public
AjaxResult
genCode
(
@PathVariable
(
"tableName"
)
String
tableName
)
{
genTableService
.
generatorCode
(
tableName
);
return
AjaxResult
.
success
();
}
/**
* 同步数据库
*/
@PreAuthorize
(
"@ss.hasPermi('tool:gen:edit')"
)
@Log
(
title
=
"代码生成"
,
businessType
=
BusinessType
.
UPDATE
)
@GetMapping
(
"/synchDb/{tableName}"
)
public
AjaxResult
synchDb
(
@PathVariable
(
"tableName"
)
String
tableName
)
{
genTableService
.
synchDb
(
tableName
);
return
AjaxResult
.
success
();
}
/**
* 批量生成代码
*/
...
...
This diff is collapsed.
Click to expand it.
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java
浏览文件 @
9e38c7de
...
...
@@ -42,6 +42,14 @@ public interface GenTableColumnMapper
*/
public
int
updateGenTableColumn
(
GenTableColumn
genTableColumn
);
/**
* 删除业务字段
*
* @param genTableColumns 列数据
* @return 结果
*/
public
int
deleteGenTableColumns
(
List
<
GenTableColumn
>
genTableColumns
);
/**
* 批量删除业务字段
*
...
...
This diff is collapsed.
Click to expand it.
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
浏览文件 @
9e38c7de
...
...
@@ -7,6 +7,7 @@ import java.io.StringWriter;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
org.apache.commons.io.IOUtils
;
...
...
@@ -224,7 +225,6 @@ public class GenTableServiceImpl implements IGenTableService
* 生成代码(自定义路径)
*
* @param tableName 表名称
* @return 数据
*/
@Override
public
void
generatorCode
(
String
tableName
)
...
...
@@ -262,6 +262,37 @@ public class GenTableServiceImpl implements IGenTableService
}
}
/**
* 同步数据库
*
* @param tableName 表名称
*/
@Override
@Transactional
public
void
synchDb
(
String
tableName
)
{
GenTable
table
=
genTableMapper
.
selectGenTableByName
(
tableName
);
List
<
GenTableColumn
>
tableColumns
=
table
.
getColumns
();
List
<
String
>
tableColumnNames
=
tableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
List
<
GenTableColumn
>
dbTableColumns
=
genTableColumnMapper
.
selectDbTableColumnsByName
(
tableName
);
List
<
String
>
dbTableColumnNames
=
dbTableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
dbTableColumns
.
forEach
(
column
->
{
if
(!
tableColumnNames
.
contains
(
column
.
getColumnName
()))
{
GenUtils
.
initColumnField
(
column
,
table
);
genTableColumnMapper
.
insertGenTableColumn
(
column
);
}
});
List
<
GenTableColumn
>
delColumns
=
tableColumns
.
stream
().
filter
(
column
->
!
dbTableColumnNames
.
contains
(
column
.
getColumnName
())).
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotEmpty
(
delColumns
))
{
genTableColumnMapper
.
deleteGenTableColumns
(
delColumns
);
}
}
/**
* 批量生成代码(下载方式)
*
...
...
This diff is collapsed.
Click to expand it.
ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java
浏览文件 @
9e38c7de
...
...
@@ -90,6 +90,13 @@ public interface IGenTableService
*/
public
void
generatorCode
(
String
tableName
);
/**
* 同步数据库
*
* @param tableName 表名称
*/
public
void
synchDb
(
String
tableName
);
/**
* 批量生成代码(下载方式)
*
...
...
This diff is collapsed.
Click to expand it.
ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
浏览文件 @
9e38c7de
...
...
@@ -117,4 +117,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete
id=
"deleteGenTableColumns"
>
delete from gen_table_column where column_id in
<foreach
collection=
"list"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item.columnId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
浏览文件 @
9e38c7de
This diff is collapsed.
Click to expand it.
ruoyi-ui/src/api/tool/gen.js
浏览文件 @
9e38c7de
...
...
@@ -67,3 +67,10 @@ export function genCode(tableName) {
})
}
// 同步数据库
export
function
synchDb
(
tableName
)
{
return
request
({
url
:
'/tool/gen/synchDb/'
+
tableName
,
method
:
'get'
})
}
This diff is collapsed.
Click to expand it.
ruoyi-ui/src/views/tool/gen/index.vue
浏览文件 @
9e38c7de
...
...
@@ -132,6 +132,13 @@
@
click=
"handleDelete(scope.row)"
v-hasPermi=
"['tool:gen:remove']"
>
删除
</el-button>
<el-button
type=
"text"
size=
"small"
icon=
"el-icon-refresh"
@
click=
"handleSynchDb(scope.row)"
v-hasPermi=
"['tool:gen:edit']"
>
同步
</el-button>
<el-button
type=
"text"
size=
"small"
...
...
@@ -167,7 +174,7 @@
</template>
<
script
>
import
{
listTable
,
previewTable
,
delTable
,
genCode
}
from
"@/api/tool/gen"
;
import
{
listTable
,
previewTable
,
delTable
,
genCode
,
synchDb
}
from
"@/api/tool/gen"
;
import
importTable
from
"./importTable"
;
import
{
downLoadZip
}
from
"@/utils/zipdownload"
;
export
default
{
...
...
@@ -252,6 +259,19 @@ export default {
downLoadZip
(
"/tool/gen/batchGenCode?tables="
+
tableNames
,
"ruoyi"
);
}
},
/** 同步数据库操作 */
handleSynchDb
(
row
)
{
const
tableName
=
row
.
tableName
;
this
.
$confirm
(
'确认要强制同步"'
+
tableName
+
'"表结构吗?'
,
"警告"
,
{
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
}).
then
(
function
()
{
return
synchDb
(
tableName
);
}).
then
(()
=>
{
this
.
msgSuccess
(
"同步成功"
);
}).
catch
(
function
()
{});
},
/** 打开导入表弹窗 */
openImportTable
()
{
this
.
$refs
.
import
.
show
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论