fix: vue2代码生成模板
parent
9983590fdf
commit
a57f79cf90
|
@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
#end
|
#end
|
||||||
## 字段模板
|
## 字段模板
|
||||||
#macro(columnTpl $prefix $prefixStr)
|
#macro(columnTpl $prefix $prefixStr)
|
||||||
#if (${column.javaType} == "Date")## 时间类型
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
#end
|
|
||||||
@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||||
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
||||||
#end
|
#end
|
||||||
|
@ -27,12 +24,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
public class ${sceneEnum.prefixClass}${table.className}ExportReqVO {
|
public class ${sceneEnum.prefixClass}${table.className}ExportReqVO {
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
|
||||||
#if (${column.listOperation})##查询操作
|
#if (${column.listOperation})##查询操作
|
||||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||||
#columnTpl('begin', '开始')
|
@ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
#columnTpl('end', '结束')
|
private ${column.javaType}[] ${column.javaField};
|
||||||
#else##情况二,非 Between 的时间
|
#else##情况二,非 Between 的时间
|
||||||
#columnTpl('', '')
|
#columnTpl('', '')
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
#end
|
#end
|
||||||
## 字段模板
|
## 字段模板
|
||||||
#macro(columnTpl $prefix $prefixStr)
|
#macro(columnTpl $prefix $prefixStr)
|
||||||
#if (${column.javaType} == "Date")## 时间类型
|
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
|
||||||
#end
|
|
||||||
@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||||
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
|
||||||
#end
|
#end
|
||||||
|
@ -29,12 +26,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam {
|
public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam {
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
|
|
||||||
#if (${column.listOperation})##查询操作
|
#if (${column.listOperation})##查询操作
|
||||||
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
|
||||||
#columnTpl('begin', '开始')
|
@ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
#columnTpl('end', '结束')
|
private ${column.javaType}[] ${column.javaField};
|
||||||
#else##情况二,非 Between 的时间
|
#else##情况二,非 Between 的时间
|
||||||
#columnTpl('', '')
|
#columnTpl('', '')
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -219,22 +219,16 @@ export default {
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
#foreach ($column in $columns)## 时间范围
|
|
||||||
#if ($column.listOperation)
|
|
||||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
|
||||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
dateRange${AttrName}: [],
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if ($column.listOperation && $column.listOperationCondition != 'BETWEEN')
|
#if ($column.listOperation)
|
||||||
|
#if ($column.listOperationCondition != 'BETWEEN')
|
||||||
$column.javaField: null,
|
$column.javaField: null,
|
||||||
#else if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
#end
|
||||||
|
#if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
|
||||||
$column.javaField: [],
|
$column.javaField: [],
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -72,7 +72,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'edit',
|
path: 'edit',
|
||||||
component: () => import('@/views/infra/codegen/EditTable.vue'),
|
component: () => import('@/views/infra/codegen/components/EditTable.vue'),
|
||||||
name: 'EditTable',
|
name: 'EditTable',
|
||||||
meta: {
|
meta: {
|
||||||
noCache: true,
|
noCache: true,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, unref, onMounted } from 'vue'
|
import { ref, unref, onMounted } from 'vue'
|
||||||
import { ContentDetailWrap } from '@/components/ContentDetailWrap'
|
import { ContentDetailWrap } from '@/components/ContentDetailWrap'
|
||||||
import BasicInfoForm from './components/BasicInfoForm.vue'
|
import BasicInfoForm from './BasicInfoForm.vue'
|
||||||
import CloumInfoFormVue from './components/CloumInfoForm.vue'
|
import CloumInfoFormVue from './CloumInfoForm.vue'
|
||||||
import GenInfoFormVue from './components/GenInfoForm.vue'
|
import GenInfoFormVue from './GenInfoForm.vue'
|
||||||
import { ElTabs, ElTabPane, ElButton } from 'element-plus'
|
import { ElTabs, ElTabPane, ElButton } from 'element-plus'
|
||||||
import { getCodegenTableApi } from '@/api/infra/codegen'
|
import { getCodegenTableApi } from '@/api/infra/codegen'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
|
@ -38,7 +38,6 @@ const submitForm = async () => {
|
||||||
console.info(basicInfoData)
|
console.info(basicInfoData)
|
||||||
console.info(genInfoData)
|
console.info(genInfoData)
|
||||||
}
|
}
|
||||||
console.info(1)
|
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getList()
|
getList()
|
|
@ -47,6 +47,7 @@ const schema = reactive<FormSchema[]>([
|
||||||
label: '模块名',
|
label: '模块名',
|
||||||
field: 'moduleName',
|
field: 'moduleName',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
labelMessage: '模块名,即一级目录,例如 system、infra、tool 等等',
|
||||||
colProps: {
|
colProps: {
|
||||||
span: 12
|
span: 12
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,7 @@ const schema = reactive<FormSchema[]>([
|
||||||
label: '业务名',
|
label: '业务名',
|
||||||
field: 'businessName',
|
field: 'businessName',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
labelMessage: '业务名,即二级目录,例如 user、permission、dict 等等',
|
||||||
colProps: {
|
colProps: {
|
||||||
span: 12
|
span: 12
|
||||||
}
|
}
|
||||||
|
@ -63,6 +65,7 @@ const schema = reactive<FormSchema[]>([
|
||||||
label: '类名称',
|
label: '类名称',
|
||||||
field: 'className',
|
field: 'className',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
labelMessage: '类名称(首字母大写),例如SysUser、SysMenu、SysDictData 等等',
|
||||||
colProps: {
|
colProps: {
|
||||||
span: 12
|
span: 12
|
||||||
}
|
}
|
||||||
|
@ -71,6 +74,7 @@ const schema = reactive<FormSchema[]>([
|
||||||
label: '类描述',
|
label: '类描述',
|
||||||
field: 'classComment',
|
field: 'classComment',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
labelMessage: '用作类描述,例如 用户',
|
||||||
colProps: {
|
colProps: {
|
||||||
span: 12
|
span: 12
|
||||||
}
|
}
|
||||||
|
@ -79,6 +83,7 @@ const schema = reactive<FormSchema[]>([
|
||||||
label: '上级菜单',
|
label: '上级菜单',
|
||||||
field: 'parentMenuId',
|
field: 'parentMenuId',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
labelMessage: '分配到指定菜单下,例如 系统管理',
|
||||||
colProps: {
|
colProps: {
|
||||||
span: 12
|
span: 12
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,18 @@ import {
|
||||||
ElForm,
|
ElForm,
|
||||||
ElFormItem,
|
ElFormItem,
|
||||||
ElInput,
|
ElInput,
|
||||||
ElEmpty
|
ElSelect,
|
||||||
|
ElOption
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
|
||||||
import { getDataSourceConfigListApi } from '@/api/infra/dataSourceConfig'
|
import { getDataSourceConfigListApi } from '@/api/infra/dataSourceConfig'
|
||||||
import type { DataSourceConfigVO } from '@/api/infra/dataSourceConfig/types'
|
import type { DataSourceConfigVO } from '@/api/infra/dataSourceConfig/types'
|
||||||
import type { DatabaseTableVO } from '@/api/infra/codegen/types'
|
import type { DatabaseTableVO } from '@/api/infra/codegen/types'
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const { emitter } = useEmitt()
|
const emit = defineEmits(['ok'])
|
||||||
// ======== 显示页面 ========
|
// ======== 显示页面 ========
|
||||||
const visible = ref(false)
|
const visible = ref(false)
|
||||||
|
const dbLoading = ref(true)
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
tableName: undefined,
|
tableName: undefined,
|
||||||
tableComment: undefined,
|
tableComment: undefined,
|
||||||
|
@ -37,8 +38,10 @@ const dbTableList = ref<DatabaseTableVO[]>([])
|
||||||
|
|
||||||
/** 查询表数据 */
|
/** 查询表数据 */
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
|
dbLoading.value = true
|
||||||
const res = await getSchemaTableListApi(queryParams)
|
const res = await getSchemaTableListApi(queryParams)
|
||||||
dbTableList.value = res
|
dbTableList.value = res
|
||||||
|
dbLoading.value = false
|
||||||
}
|
}
|
||||||
// 查询操作
|
// 查询操作
|
||||||
const handleQuery = async () => {
|
const handleQuery = async () => {
|
||||||
|
@ -56,19 +59,18 @@ const handleSelectionChange = (val: DatabaseTableVO[]) => {
|
||||||
tables.value = val.map((item) => item.name)
|
tables.value = val.map((item) => item.name)
|
||||||
}
|
}
|
||||||
/** 导入按钮操作 */
|
/** 导入按钮操作 */
|
||||||
const handleImportTable = () => {
|
const handleImportTable = async () => {
|
||||||
if (tables.value.length === 0) {
|
if (tables.value.length === 0) {
|
||||||
ElMessage.error('请选择要导入的表')
|
ElMessage.error('请选择要导入的表')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
createCodegenListApi({
|
await createCodegenListApi({
|
||||||
dataSourceConfigId: queryParams.dataSourceConfigId,
|
dataSourceConfigId: queryParams.dataSourceConfigId,
|
||||||
tableNames: tables.value
|
tableNames: tables.value
|
||||||
}).then((res) => {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
visible.value = false
|
|
||||||
emitter.emit('ok')
|
|
||||||
})
|
})
|
||||||
|
ElMessage.success('导入成功')
|
||||||
|
visible.value = false
|
||||||
|
emit('ok')
|
||||||
}
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
show
|
show
|
||||||
|
@ -78,7 +80,7 @@ defineExpose({
|
||||||
<!-- 导入表 -->
|
<!-- 导入表 -->
|
||||||
<Dialog title="导入表" v-model="visible" maxHeight="500px" width="50%">
|
<Dialog title="导入表" v-model="visible" maxHeight="500px" width="50%">
|
||||||
<el-form :model="queryParams" ref="queryRef" :inline="true">
|
<el-form :model="queryParams" ref="queryRef" :inline="true">
|
||||||
<!-- <el-form-item label="数据源" prop="dataSourceConfigId">
|
<el-form-item label="数据源" prop="dataSourceConfigId">
|
||||||
<el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable>
|
<el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="config in dataSourceConfigs"
|
v-for="config in dataSourceConfigs"
|
||||||
|
@ -87,7 +89,7 @@ defineExpose({
|
||||||
:value="config.id"
|
:value="config.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item> -->
|
</el-form-item>
|
||||||
<el-form-item label="表名称" prop="tableName">
|
<el-form-item label="表名称" prop="tableName">
|
||||||
<el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable />
|
<el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -109,11 +111,9 @@ defineExpose({
|
||||||
ref="table"
|
ref="table"
|
||||||
:data="dbTableList"
|
:data="dbTableList"
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
|
v-loading="dbLoading"
|
||||||
height="400px"
|
height="400px"
|
||||||
>
|
>
|
||||||
<template #empty>
|
|
||||||
<el-empty description="加载中" />
|
|
||||||
</template>
|
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
<el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" />
|
<el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" />
|
||||||
<el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" />
|
<el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" />
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
import BasicInfoForm from './BasicInfoForm.vue'
|
||||||
|
import CloumInfoForm from './CloumInfoForm.vue'
|
||||||
|
import EditTable from './EditTable.vue'
|
||||||
|
import GenInfoForm from './GenInfoForm.vue'
|
||||||
|
import ImportTable from './ImportTable.vue'
|
||||||
|
import Preview from './Preview.vue'
|
||||||
|
export { BasicInfoForm, CloumInfoForm, EditTable, GenInfoForm, ImportTable, Preview }
|
|
@ -6,8 +6,7 @@ import { useTable } from '@/hooks/web/useTable'
|
||||||
import { CodegenTableVO } from '@/api/infra/codegen/types'
|
import { CodegenTableVO } from '@/api/infra/codegen/types'
|
||||||
import { allSchemas } from './codegen.data'
|
import { allSchemas } from './codegen.data'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import ImportTable from './components/ImportTable.vue'
|
import { ImportTable, Preview } from './components'
|
||||||
import Preview from './components/Preview.vue'
|
|
||||||
import download from '@/utils/download'
|
import download from '@/utils/download'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen,
|
import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen,
|
||||||
syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/infra/codegen";
|
syncCodegenFromDB } from "@/api/infra/codegen";
|
||||||
|
|
||||||
import importTable from "./importTable";
|
import importTable from "./importTable";
|
||||||
// 代码高亮插件
|
// 代码高亮插件
|
||||||
|
|
Loading…
Reference in New Issue