From 3524e3525b635f83c28bc2ff9cbd3ea0e4ac2066 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 14 Nov 2023 09:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=AE=BE=E7=BD=AE=E4=B8=BB=E5=AD=90=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 45656562a82353927da0aa614a1ce0689e7bd6b0) --- src/api/infra/codegen/index.ts | 10 +- src/api/infra/demo12/index.ts | 48 +++++- src/views/infra/codegen/EditTable.vue | 2 +- .../codegen/components/GenerateInfoForm.vue | 94 ++++++----- src/views/infra/demo12/Demo12StudentForm.vue | 2 +- .../components/Demo12StudentContactForm.vue | 152 +++++++++++++++++- .../components/Demo12StudentContactList.vue | 95 ++++++++++- .../components/Demo12StudentTeacherForm.vue | 152 +++++++++++++++++- .../components/Demo12StudentTeacherList.vue | 99 ++++++++++-- src/views/infra/demo12/index.vue | 28 +++- 10 files changed, 612 insertions(+), 70 deletions(-) diff --git a/src/api/infra/codegen/index.ts b/src/api/infra/codegen/index.ts index 54f00ff0..d4add25e 100644 --- a/src/api/infra/codegen/index.ts +++ b/src/api/infra/codegen/index.ts @@ -1,6 +1,11 @@ import request from '@/config/axios' import type { CodegenUpdateReqVO, CodegenCreateListReqVO } from './types' +// 查询列表代码生成表定义 +export const getCodegenTableList = (dataSourceConfigId: number) => { + return request.get({ url: '/infra/codegen/table/list?dataSourceConfigId=' + dataSourceConfigId }) +} + // 查询列表代码生成表定义 export const getCodegenTablePageApi = (params) => { return request.get({ url: '/infra/codegen/table/page', params }) @@ -26,11 +31,6 @@ export const syncCodegenFromDBApi = (id: number) => { return request.put({ url: '/infra/codegen/sync-from-db?tableId=' + id }) } -// 基于 SQL 建表语句,同步数据库的表和字段定义 -export const syncCodegenFromSQLApi = (id: number, sql: string) => { - return request.put({ url: '/infra/codegen/sync-from-sql?tableId=' + id + '&sql=' + sql }) -} - // 预览生成代码 export const previewCodegenApi = (id: number) => { return request.get({ url: '/infra/codegen/preview?tableId=' + id }) diff --git a/src/api/infra/demo12/index.ts b/src/api/infra/demo12/index.ts index 33c3fb4f..3f2be47e 100644 --- a/src/api/infra/demo12/index.ts +++ b/src/api/infra/demo12/index.ts @@ -44,14 +44,52 @@ export const exportDemo12Student = async (params) => { // ==================== 子表(学生联系人) ==================== -// 获得学生联系人列表 -export const getDemo12StudentContactListByStudentId = async (studentId) => { - return await request.get({ url: `/infra/demo12-student/demo12-student/list-by-student-id?studentId=` + studentId }) +// 获得学生联系人分页 +export const getDemo12StudentContactPage = async (params) => { + return await request.get({ url: `/infra/demo12-student/demo12-student-contact/page`, params }) +} +// 新增学生联系人 +export const createDemo12StudentContact = async (data) => { + return await request.post({ url: `/infra/demo12-student/demo12-student-contact/create`, data }) +} + +// 修改学生联系人 +export const updateDemo12StudentContact = async (data) => { + return await request.put({ url: `/infra/demo12-student/demo12-student-contact/update`, data }) +} + +// 删除学生联系人 +export const deleteDemo12StudentContact = async (id: number) => { + return await request.delete({ url: `/infra/demo12-student/demo12-student-contact/delete?id=` + id }) +} + +// 获得学生联系人 +export const getDemo12StudentContact = async (id: number) => { + return await request.get({ url: `/infra/demo12-student/demo12-student-contact/get?id=` + id }) } // ==================== 子表(学生班主任) ==================== +// 获得学生班主任分页 +export const getDemo12StudentTeacherPage = async (params) => { + return await request.get({ url: `/infra/demo12-student/demo12-student-teacher/page`, params }) +} +// 新增学生班主任 +export const createDemo12StudentTeacher = async (data) => { + return await request.post({ url: `/infra/demo12-student/demo12-student-teacher/create`, data }) +} + +// 修改学生班主任 +export const updateDemo12StudentTeacher = async (data) => { + return await request.put({ url: `/infra/demo12-student/demo12-student-teacher/update`, data }) +} + +// 删除学生班主任 +export const deleteDemo12StudentTeacher = async (id: number) => { + return await request.delete({ url: `/infra/demo12-student/demo12-student-teacher/delete?id=` + id }) +} + // 获得学生班主任 -export const getDemo12StudentTeacherByStudentId = async (studentId) => { - return await request.get({ url: `/infra/demo12-student/demo12-student/get-by-student-id?studentId=` + studentId }) +export const getDemo12StudentTeacher = async (id: number) => { + return await request.get({ url: `/infra/demo12-student/demo12-student-teacher/get?id=` + id }) } \ No newline at end of file diff --git a/src/views/infra/codegen/EditTable.vue b/src/views/infra/codegen/EditTable.vue index 4ff02e7a..ececa7cd 100644 --- a/src/views/infra/codegen/EditTable.vue +++ b/src/views/infra/codegen/EditTable.vue @@ -8,7 +8,7 @@ - + diff --git a/src/views/infra/codegen/components/GenerateInfoForm.vue b/src/views/infra/codegen/components/GenerateInfoForm.vue index 744edfe6..178b4e0f 100644 --- a/src/views/infra/codegen/components/GenerateInfoForm.vue +++ b/src/views/infra/codegen/components/GenerateInfoForm.vue @@ -3,7 +3,7 @@ - + - -

关联信息

+ + + + +

主表信息

+
- + - + - + - + + + + + + 一对多 + 一对一 + + +
@@ -305,6 +325,10 @@ const props = defineProps({ table: { type: Object as PropType>, default: () => null + }, + columns: { + type: Array as unknown as PropType, + default: () => null } }) @@ -323,9 +347,10 @@ const formData = ref({ treeParentCode: '', treeName: '', tplCategory: '', - subTableName: '', - subTableFkName: '', - genType: '' + genType: '', + masterTableId: undefined, + subJoinColumnId: undefined, + subJoinMany: undefined }) const rules = reactive({ @@ -336,41 +361,27 @@ const rules = reactive({ businessName: [required], businessPackage: [required], className: [required], - classComment: [required] + classComment: [required], + masterTableId: [required], + subJoinColumnId: [required], + subJoinMany: [required] }) -const tables = ref([]) -const subColumns = ref([]) +const tables = ref([]) // 表定义列表 const menus = ref([]) const menuTreeProps = { label: 'name' } -/** 选择子表名触发 */ -const subSelectChange = () => { - formData.value.subTableFkName = '' -} - -/** 选择生成模板触发 */ -const tplSelectChange = (value) => { - if (value !== 1) { - // TODO 芋艿:暂时不考虑支持树形结构 - message.error( - '暂时不考虑支持【树形】和【主子表】的代码生成。原因是:导致 vm 模板过于复杂,不利于胖友二次开发' - ) - return false - } - if (value !== 'sub') { - formData.value.subTableName = '' - formData.value.subTableFkName = '' - } -} - watch( () => props.table, - (table) => { + async (table) => { if (!table) return formData.value = table as any + // 加载表列表 + if (table.dataSourceConfigId >= 0) { + tables.value = await CodegenApi.getCodegenTableList(formData.value.dataSourceConfigId) + } }, { deep: true, @@ -380,6 +391,7 @@ watch( onMounted(async () => { try { + // 加载菜单 const resp = await MenuApi.getSimpleMenusList() menus.value = handleTree(resp) } catch {} diff --git a/src/views/infra/demo12/Demo12StudentForm.vue b/src/views/infra/demo12/Demo12StudentForm.vue index d3cb482d..af4e2733 100644 --- a/src/views/infra/demo12/Demo12StudentForm.vue +++ b/src/views/infra/demo12/Demo12StudentForm.vue @@ -42,7 +42,7 @@ - + diff --git a/src/views/infra/demo12/components/Demo12StudentContactForm.vue b/src/views/infra/demo12/components/Demo12StudentContactForm.vue index d71f6146..e246678b 100644 --- a/src/views/infra/demo12/components/Demo12StudentContactForm.vue +++ b/src/views/infra/demo12/components/Demo12StudentContactForm.vue @@ -1,5 +1,155 @@ \ No newline at end of file diff --git a/src/views/infra/demo12/components/Demo12StudentContactList.vue b/src/views/infra/demo12/components/Demo12StudentContactList.vue index 65ed9df1..b9b1e717 100644 --- a/src/views/infra/demo12/components/Demo12StudentContactList.vue +++ b/src/views/infra/demo12/components/Demo12StudentContactList.vue @@ -1,6 +1,14 @@ \ No newline at end of file diff --git a/src/views/infra/demo12/components/Demo12StudentTeacherForm.vue b/src/views/infra/demo12/components/Demo12StudentTeacherForm.vue index d71f6146..92e2b373 100644 --- a/src/views/infra/demo12/components/Demo12StudentTeacherForm.vue +++ b/src/views/infra/demo12/components/Demo12StudentTeacherForm.vue @@ -1,5 +1,155 @@ \ No newline at end of file diff --git a/src/views/infra/demo12/components/Demo12StudentTeacherList.vue b/src/views/infra/demo12/components/Demo12StudentTeacherList.vue index 55f6845b..d0594534 100644 --- a/src/views/infra/demo12/components/Demo12StudentTeacherList.vue +++ b/src/views/infra/demo12/components/Demo12StudentTeacherList.vue @@ -1,6 +1,14 @@ \ No newline at end of file diff --git a/src/views/infra/demo12/index.vue b/src/views/infra/demo12/index.vue index c5a82a4c..47ec7f21 100644 --- a/src/views/infra/demo12/index.vue +++ b/src/views/infra/demo12/index.vue @@ -94,7 +94,14 @@ - + @@ -157,6 +164,17 @@ + + + + + + + + + + +