Blame view

yudao-admin-ui/src/api/tool/codegen.js 2.4 KB
b04db3d6   YunaiV   升级 highlight 插件的版本
1
2
  import request from '@/utils/request'
  
3fb292a4   YunaiV   代码生成器的编辑界面~
3
  // 获得表定义分页
0d55ca74   YunaiV   1. 同步数据表和字段定义
4
  export function getCodegenTablePage(query) {
3fb292a4   YunaiV   代码生成器的编辑界面~
5
    return request({
305090b7   YunaiV   1. 完成代码生成的表和字段定义的编辑
6
      url: '/tool/codegen/table/page',
3fb292a4   YunaiV   代码生成器的编辑界面~
7
8
9
10
11
12
      method: 'get',
      params: query
    })
  }
  
  // 获得表和字段的明细
0d55ca74   YunaiV   1. 同步数据表和字段定义
13
  export function getCodegenDetail(tableId) {
3fb292a4   YunaiV   代码生成器的编辑界面~
14
15
16
17
18
    return request({
      url: '/tool/codegen/detail?tableId=' + tableId,
      method: 'get',
    })
  }
305090b7   YunaiV   1. 完成代码生成的表和字段定义的编辑
19
20
21
22
23
24
25
26
27
  
  // 修改代码生成信息
  export function updateCodegen(data) {
    return request({
      url: '/tool/codegen/update',
      method: 'put',
      data: data
    })
  }
8cfb8265   YunaiV   代码预览的功能,完成
28
  
0d55ca74   YunaiV   1. 同步数据表和字段定义
29
  // 基于数据库的表结构,同步数据库的表和字段定义
2f66829a   YunaiV   完成代码生成器~
30
  export function syncCodegenFromDB(tableId) {
0d55ca74   YunaiV   1. 同步数据表和字段定义
31
    return request({
2f66829a   YunaiV   完成代码生成器~
32
      url: '/tool/codegen/sync-from-db?tableId=' + tableId,
0d55ca74   YunaiV   1. 同步数据表和字段定义
33
34
35
36
      method: 'put'
    })
  }
  
2f66829a   YunaiV   完成代码生成器~
37
38
39
40
41
42
43
44
45
46
47
48
  // 基于 SQL 建表语句,同步数据库的表和字段定义
  export function syncCodegenFromSQL(tableId, sql) {
    return request({
      url: '/tool/codegen/sync-from-sql?tableId=' + tableId,
      method: 'put',
      headers:{
        'Content-type': 'application/x-www-form-urlencoded'
      },
      data: 'tableId=' + tableId + "&sql=" + sql,
    })
  }
  
8cfb8265   YunaiV   代码预览的功能,完成
49
50
51
52
  // 预览生成代码
  export function previewCodegen(tableId) {
    return request({
      url: '/tool/codegen/preview?tableId=' + tableId,
54c98c3a   YunaiV   代码生成器的下载功能,完成~
53
      method: 'get',
8cfb8265   YunaiV   代码预览的功能,完成
54
55
56
57
58
59
60
61
62
63
64
    })
  }
  
  // 下载生成代码
  export function downloadCodegen(tableId) {
    return request({
      url: '/tool/codegen/download?tableId=' + tableId,
      method: 'get',
      responseType: 'blob'
    })
  }
0d55ca74   YunaiV   1. 同步数据表和字段定义
65
66
67
68
69
70
71
72
73
74
75
  
  // 获得表定义分页
  export function getSchemaTableList(query) {
    return request({
      url: '/tool/codegen/db/table/list',
      method: 'get',
      params: query
    })
  }
  
  // 基于数据库的表结构,创建代码生成器的表定义
2f66829a   YunaiV   完成代码生成器~
76
  export function createCodegenListFromDB(tableNames) {
0d55ca74   YunaiV   1. 同步数据表和字段定义
77
    return request({
2f66829a   YunaiV   完成代码生成器~
78
      url: '/tool/codegen/create-list-from-db',
0d55ca74   YunaiV   1. 同步数据表和字段定义
79
80
81
82
83
84
85
86
      method: 'post',
      headers:{
        'Content-type': 'application/x-www-form-urlencoded'
      },
      data: 'tableNames=' + tableNames
    })
  }
  
2f66829a   YunaiV   完成代码生成器~
87
88
89
90
91
92
93
94
95
96
97
98
  // 基于 SQL 建表语句,创建代码生成器的表定义
  export function createCodegenListFromSQL(data) {
    return request({
      url: '/tool/codegen/create-list-from-sql',
      method: 'post',
      headers:{
        'Content-type': 'application/x-www-form-urlencoded'
      },
      data: 'sql=' + data.sql,
    })
  }
  
0d55ca74   YunaiV   1. 同步数据表和字段定义
99
100
101
102
103
104
105
  // 删除数据库的表和字段定义
  export function deleteCodegen(tableId) {
    return request({
      url: '/tool/codegen/delete?tableId=' + tableId,
      method: 'delete'
    })
  }