Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
76c5c7c1
authored
Mar 29, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REVIEW 代码生成
parent
95b7eb98
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
172 deletions
+127
-172
src/api/infra/codegen/index.ts
+68
-2
src/api/infra/codegen/types.ts
+0
-61
src/locales/zh-CN.ts
+1
-2
src/views/infra/codegen/EditTable.vue
+1
-1
src/views/infra/codegen/codegen.data.ts
+0
-53
src/views/infra/codegen/index.vue
+57
-53
No files found.
src/api/infra/codegen/index.ts
View file @
76c5c7c1
import
request
from
'@/config/axios'
import
request
from
'@/config/axios'
import
type
{
CodegenUpdateReqVO
,
CodegenCreateListReqVO
}
from
'./types'
export
type
CodegenTableVO
=
{
id
:
number
tableId
:
number
isParentMenuIdValid
:
boolean
dataSourceConfigId
:
number
scene
:
number
tableName
:
string
tableComment
:
string
remark
:
string
moduleName
:
string
businessName
:
string
className
:
string
classComment
:
string
author
:
string
createTime
:
Date
updateTime
:
Date
templateType
:
number
parentMenuId
:
number
}
export
type
CodegenColumnVO
=
{
id
:
number
tableId
:
number
columnName
:
string
dataType
:
string
columnComment
:
string
nullable
:
number
primaryKey
:
number
autoIncrement
:
string
ordinalPosition
:
number
javaType
:
string
javaField
:
string
dictType
:
string
example
:
string
createOperation
:
number
updateOperation
:
number
listOperation
:
number
listOperationCondition
:
string
listOperationResult
:
number
htmlType
:
string
}
export
type
DatabaseTableVO
=
{
name
:
string
comment
:
string
}
export
type
CodegenDetailVO
=
{
table
:
CodegenTableVO
columns
:
CodegenColumnVO
[]
}
export
type
CodegenPreviewVO
=
{
filePath
:
string
code
:
string
}
export
type
CodegenUpdateReqVO
=
{
table
:
CodegenTableVO
|
any
columns
:
CodegenColumnVO
[]
}
export
type
CodegenCreateListReqVO
=
{
dataSourceConfigId
:
number
tableNames
:
string
[]
}
// 查询列表代码生成表定义
// 查询列表代码生成表定义
export
const
getCodegenTablePage
=
(
params
)
=>
{
export
const
getCodegenTablePage
=
(
params
:
PageParam
)
=>
{
return
request
.
get
({
url
:
'/infra/codegen/table/page'
,
params
})
return
request
.
get
({
url
:
'/infra/codegen/table/page'
,
params
})
}
}
...
...
src/api/infra/codegen/types.ts
deleted
100644 → 0
View file @
95b7eb98
export
type
CodegenTableVO
=
{
id
:
number
tableId
:
number
isParentMenuIdValid
:
boolean
dataSourceConfigId
:
number
scene
:
number
tableName
:
string
tableComment
:
string
remark
:
string
moduleName
:
string
businessName
:
string
className
:
string
classComment
:
string
author
:
string
createTime
:
Date
updateTime
:
Date
templateType
:
number
parentMenuId
:
number
}
export
type
CodegenColumnVO
=
{
id
:
number
tableId
:
number
columnName
:
string
dataType
:
string
columnComment
:
string
nullable
:
number
primaryKey
:
number
autoIncrement
:
string
ordinalPosition
:
number
javaType
:
string
javaField
:
string
dictType
:
string
example
:
string
createOperation
:
number
updateOperation
:
number
listOperation
:
number
listOperationCondition
:
string
listOperationResult
:
number
htmlType
:
string
}
export
type
DatabaseTableVO
=
{
name
:
string
comment
:
string
}
export
type
CodegenDetailVO
=
{
table
:
CodegenTableVO
columns
:
CodegenColumnVO
[]
}
export
type
CodegenPreviewVO
=
{
filePath
:
string
code
:
string
}
export
type
CodegenUpdateReqVO
=
{
table
:
CodegenTableVO
|
any
columns
:
CodegenColumnVO
[]
}
export
type
CodegenCreateListReqVO
=
{
dataSourceConfigId
:
number
tableNames
:
string
[]
}
src/locales/zh-CN.ts
View file @
76c5c7c1
...
@@ -298,8 +298,7 @@ export default {
...
@@ -298,8 +298,7 @@ export default {
typeUpdate
:
'字典类型编辑'
,
typeUpdate
:
'字典类型编辑'
,
dataCreate
:
'字典数据新增'
,
dataCreate
:
'字典数据新增'
,
dataUpdate
:
'字典数据编辑'
,
dataUpdate
:
'字典数据编辑'
,
fileUpload
:
'上传文件'
,
fileUpload
:
'上传文件'
back
:
'返回'
},
},
dialog
:
{
dialog
:
{
dialog
:
'弹窗'
,
dialog
:
'弹窗'
,
...
...
src/views/infra/codegen/EditTable.vue
View file @
76c5c7c1
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<el-button
type=
"primary"
@
click=
"submitForm"
:loading=
"submitLoading"
>
<el-button
type=
"primary"
@
click=
"submitForm"
:loading=
"submitLoading"
>
{{
t
(
'action.save'
)
}}
{{
t
(
'action.save'
)
}}
</el-button>
</el-button>
<el-button
@
click=
"close"
>
{{
t
(
'action.back'
)
}}
</el-button>
<el-button
@
click=
"close"
>
返回
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
</content-wrap>
</content-wrap>
...
...
src/views/infra/codegen/codegen.data.ts
deleted
100644 → 0
View file @
95b7eb98
import
type
{
VxeCrudSchema
}
from
'@/hooks/web/useVxeCrudSchemas'
const
{
t
}
=
useI18n
()
// 国际化
// 表单校验
export
const
rules
=
reactive
({
title
:
[
required
],
type
:
[
required
],
status
:
[
required
]
})
// CrudSchema
const
crudSchemas
=
reactive
<
VxeCrudSchema
>
({
primaryKey
:
'id'
,
primaryType
:
'seq'
,
action
:
true
,
actionWidth
:
'400px'
,
columns
:
[
{
title
:
'表名称'
,
field
:
'tableName'
,
isSearch
:
true
},
{
title
:
'表描述'
,
field
:
'tableComment'
,
isSearch
:
true
},
{
title
:
'实体'
,
field
:
'className'
,
isSearch
:
true
},
{
title
:
t
(
'common.createTime'
),
field
:
'createTime'
,
formatter
:
'formatDate'
,
isForm
:
false
,
search
:
{
show
:
true
,
itemRender
:
{
name
:
'XDataTimePicker'
}
}
},
{
title
:
t
(
'common.updateTime'
),
field
:
'updateTime'
,
formatter
:
'formatDate'
,
isForm
:
false
}
]
})
export
const
{
allSchemas
}
=
useVxeCrudSchemas
(
crudSchemas
)
src/views/infra/codegen/index.vue
View file @
76c5c7c1
<
template
>
<
template
>
<!-- 搜索 -->
<!-- 搜索 -->
<content-wrap>
<content-wrap>
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
>
<el-form
class=
"-mb-15px"
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"表名称"
prop=
"tableName"
>
<el-form-item
label=
"表名称"
prop=
"tableName"
>
<el-input
<el-input
v-model=
"queryParams.tableName"
v-model=
"queryParams.tableName"
placeholder=
"请输入表名称"
placeholder=
"请输入表名称"
clearable
clearable
@
keyup
.
enter=
"handleQuery"
@
keyup
.
enter=
"handleQuery"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"表描述"
prop=
"tableComment"
>
<el-form-item
label=
"表描述"
prop=
"tableComment"
>
...
@@ -16,23 +23,25 @@
...
@@ -16,23 +23,25 @@
placeholder=
"请输入表描述"
placeholder=
"请输入表描述"
clearable
clearable
@
keyup
.
enter=
"handleQuery"
@
keyup
.
enter=
"handleQuery"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"创建时间"
prop=
"createTime"
>
<el-form-item
label=
"创建时间"
prop=
"createTime"
>
<el-date-picker
<el-date-picker
v-model=
"queryParams.createTime"
v-model=
"queryParams.createTime"
value-format=
"
yyyy
-MM-dd HH:mm:ss"
value-format=
"
YYYY
-MM-dd HH:mm:ss"
type=
"daterange"
type=
"daterange"
start-placeholder=
"开始日期"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
end-placeholder=
"结束日期"
:default-time=
"[new Date('1 00:00:00'), new Date('1 23:59:59')]"
:default-time=
"[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
v-hasPermi=
"['infra:codegen:create']"
@
click=
"openImportTable()"
>
<el-button
type=
"primary"
v-hasPermi=
"['infra:codegen:create']"
@
click=
"openImportTable()"
>
<Icon
icon=
"ep:zoom-in"
class=
"mr-5px"
/>
{{
t
(
'action.import'
)
}}
<Icon
icon=
"ep:zoom-in"
class=
"mr-5px"
/>
导入
</el-button>
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
...
@@ -41,14 +50,20 @@
...
@@ -41,14 +50,20 @@
<!-- 列表 -->
<!-- 列表 -->
<content-wrap>
<content-wrap>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table
v-loading=
"loading"
:data=
"list"
>
<el-table-column
label=
"数据源"
align=
"center"
:formatter=
"dataSourceConfigNameFormat"
/>
<el-table-column
label=
"数据源"
align=
"center"
>
<template
#
default=
"scope"
>
{{
dataSourceConfigList
.
find
((
config
)
=>
config
.
id
===
scope
.
row
.
dataSourceConfigId
)?.
name
}}
</
template
>
</el-table-column>
<el-table-column
label=
"表名称"
align=
"center"
prop=
"tableName"
width=
"200"
/>
<el-table-column
label=
"表名称"
align=
"center"
prop=
"tableName"
width=
"200"
/>
<el-table-column
<el-table-column
label=
"表描述"
label=
"表描述"
align=
"center"
align=
"center"
prop=
"tableComment"
prop=
"tableComment"
:show-overflow-tooltip=
"true"
:show-overflow-tooltip=
"true"
width=
"
12
0"
width=
"
20
0"
/>
/>
<el-table-column
label=
"实体"
align=
"center"
prop=
"className"
width=
"200"
/>
<el-table-column
label=
"实体"
align=
"center"
prop=
"className"
width=
"200"
/>
<el-table-column
<el-table-column
...
@@ -65,53 +80,53 @@
...
@@ -65,53 +80,53 @@
width=
"180"
width=
"180"
:formatter=
"dateFormatter"
:formatter=
"dateFormatter"
/>
/>
<el-table-column
<el-table-column
label=
"操作"
align=
"center"
width=
"300px"
fixed=
"right"
>
label=
"操作"
align=
"center"
width=
"300px"
class-name=
"small-padding fixed-width"
>
<
template
#
default=
"scope"
>
<
template
#
default=
"scope"
>
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"handlePreview(scope.row)"
@
click=
"handlePreview(scope.row)"
v-hasPermi=
"['infra:codegen:preview']"
v-hasPermi=
"['infra:codegen:preview']"
>
预览
</el-button
>
>
预览
</el-button>
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"handleUpdate(scope.row.id)"
@
click=
"handleUpdate(scope.row.id)"
v-hasPermi=
"['infra:codegen:update']"
v-hasPermi=
"['infra:codegen:update']"
>
编辑
</el-button
>
>
编辑
</el-button>
<el-button
<el-button
link
link
type=
"danger"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['infra:codegen:delete']"
v-hasPermi=
"['infra:codegen:delete']"
>
删除
</el-button
>
>
删除
</el-button>
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"handleSync
hDb
(scope.row)"
@
click=
"handleSync
DB
(scope.row)"
v-hasPermi=
"['infra:codegen:update']"
v-hasPermi=
"['infra:codegen:update']"
>
同步
</el-button
>
>
同步
</el-button>
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"handleGenTable(scope.row)"
@
click=
"handleGenTable(scope.row)"
v-hasPermi=
"['infra:codegen:download']"
v-hasPermi=
"['infra:codegen:download']"
>
生成代码
</el-button
>
>
生成代码
</el-button>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
</el-table>
</el-table>
<
pagination
<
!-- 分页 -->
v-show=
"total > 0"
<Pagination
:total=
"total"
:total=
"total"
v-model:page=
"queryParams.pageNo"
v-model:page=
"queryParams.pageNo"
v-model:limit=
"queryParams.pageSize"
v-model:limit=
"queryParams.pageSize"
...
@@ -120,20 +135,16 @@
...
@@ -120,20 +135,16 @@
</content-wrap>
</content-wrap>
<!-- 弹窗:导入表 -->
<!-- 弹窗:导入表 -->
<ImportTable
ref=
"importRef"
@
ok=
"
reload()
"
/>
<ImportTable
ref=
"importRef"
@
ok=
"
getList
"
/>
<!-- 弹窗:预览代码 -->
<!-- 弹窗:预览代码 -->
<Preview
ref=
"previewRef"
/>
<Preview
ref=
"previewRef"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"Codegen"
>
<
script
setup
lang=
"ts"
name=
"Codegen"
>
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
download
from
'@/utils/download'
import
download
from
'@/utils/download'
import
*
as
CodegenApi
from
'@/api/infra/codegen'
import
*
as
CodegenApi
from
'@/api/infra/codegen'
import
*
as
DataSourceConfigApi
from
'@/api/infra/dataSourceConfig'
import
*
as
DataSourceConfigApi
from
'@/api/infra/dataSourceConfig'
import
{
CodegenTableVO
}
from
'@/api/infra/codegen/types'
import
{
ImportTable
,
Preview
}
from
'./components'
import
{
ImportTable
,
Preview
}
from
'./components'
import
ContentWrap
from
'@/components/ContentWrap/src/ContentWrap.vue'
import
{
DataSourceConfigVO
}
from
'@/api/infra/dataSourceConfig'
import
{
dateFormatter
}
from
'@/utils/formatTime'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
{
push
}
=
useRouter
()
// 路由跳转
const
{
push
}
=
useRouter
()
// 路由跳转
...
@@ -149,8 +160,7 @@ const queryParams = reactive({
...
@@ -149,8 +160,7 @@ const queryParams = reactive({
createTime
:
[]
createTime
:
[]
})
})
const
queryFormRef
=
ref
()
// 搜索的表单
const
queryFormRef
=
ref
()
// 搜索的表单
const
dataSourceConfigList
=
ref
<
DataSourceConfigApi
.
DataSourceConfigVO
[]
>
([])
// 数据源列表
const
dataSourceConfigs
=
ref
<
DataSourceConfigVO
[]
>
([])
// 数据源列表
/** 查询参数列表 */
/** 查询参数列表 */
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
...
@@ -176,36 +186,22 @@ const resetQuery = () => {
...
@@ -176,36 +186,22 @@ const resetQuery = () => {
handleQuery
()
handleQuery
()
}
}
/** 初始化 **/
onMounted
(
async
()
=>
{
getList
()
dataSourceConfigs
.
value
=
await
DataSourceConfigApi
.
getDataSourceConfigList
()
})
// 数据源配置的名字
const
dataSourceConfigNameFormat
=
(
row
)
=>
{
for
(
const
config
of
dataSourceConfigs
.
value
)
{
if
(
row
.
dataSourceConfigId
===
config
.
id
)
{
return
config
.
name
}
}
return
'未知【'
+
row
.
leaderUserId
+
'】'
}
// 导入操作
// 导入操作
const
importRef
=
ref
()
const
importRef
=
ref
()
const
openImportTable
=
()
=>
{
const
openImportTable
=
()
=>
{
importRef
.
value
.
show
()
importRef
.
value
.
show
()
}
}
// 预览操作
/** 编辑操作 */
const
handleUpdate
=
(
id
:
number
)
=>
{
push
(
'/codegen/edit?id='
+
id
)
}
/** 预览操作 */
const
previewRef
=
ref
()
const
previewRef
=
ref
()
const
handlePreview
=
(
row
:
CodegenTableVO
)
=>
{
const
handlePreview
=
(
row
:
Codegen
Api
.
Codegen
TableVO
)
=>
{
previewRef
.
value
.
openModal
(
row
.
id
)
previewRef
.
value
.
openModal
(
row
.
id
)
}
}
// 编辑操作
const
handleUpdate
=
(
rowId
:
number
)
=>
{
push
(
'/codegen/edit?id='
+
rowId
)
}
/** 删除按钮操作 */
/** 删除按钮操作 */
const
handleDelete
=
async
(
id
:
number
)
=>
{
const
handleDelete
=
async
(
id
:
number
)
=>
{
...
@@ -219,8 +215,9 @@ const handleDelete = async (id: number) => {
...
@@ -219,8 +215,9 @@ const handleDelete = async (id: number) => {
await
getList
()
await
getList
()
}
catch
{}
}
catch
{}
}
}
// 同步操作
const
handleSynchDb
=
async
(
row
:
CodegenTableVO
)
=>
{
/** 同步操作 */
const
handleSyncDB
=
async
(
row
:
CodegenApi
.
CodegenTableVO
)
=>
{
// 基于 DB 同步
// 基于 DB 同步
const
tableName
=
row
.
tableName
const
tableName
=
row
.
tableName
try
{
try
{
...
@@ -230,9 +227,16 @@ const handleSynchDb = async (row: CodegenTableVO) => {
...
@@ -230,9 +227,16 @@ const handleSynchDb = async (row: CodegenTableVO) => {
}
catch
{}
}
catch
{}
}
}
/
/ 生成代码操作
/
** 生成代码操作 */
const
handleGenTable
=
async
(
row
:
CodegenTableVO
)
=>
{
const
handleGenTable
=
async
(
row
:
Codegen
Api
.
Codegen
TableVO
)
=>
{
const
res
=
await
CodegenApi
.
downloadCodegen
(
row
.
id
)
const
res
=
await
CodegenApi
.
downloadCodegen
(
row
.
id
)
download
.
zip
(
res
,
'codegen-'
+
row
.
className
+
'.zip'
)
download
.
zip
(
res
,
'codegen-'
+
row
.
className
+
'.zip'
)
}
}
/** 初始化 **/
onMounted
(
async
()
=>
{
await
getList
()
// 加载数据源列表
dataSourceConfigList
.
value
=
await
DataSourceConfigApi
.
getDataSourceConfigList
()
})
</
script
>
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment