codegen.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import request from '@/utils/request'
  2. // 获得表定义分页
  3. export function getCodegenTablePage(query) {
  4. return request({
  5. url: '/infra/codegen/table/page',
  6. method: 'get',
  7. params: query
  8. })
  9. }
  10. // 获得表和字段的明细
  11. export function getCodegenDetail(tableId) {
  12. return request({
  13. url: '/infra/codegen/detail?tableId=' + tableId,
  14. method: 'get',
  15. })
  16. }
  17. // 修改代码生成信息
  18. export function updateCodegen(data) {
  19. return request({
  20. url: '/infra/codegen/update',
  21. method: 'put',
  22. data: data
  23. })
  24. }
  25. // 基于数据库的表结构,同步数据库的表和字段定义
  26. export function syncCodegenFromDB(tableId) {
  27. return request({
  28. url: '/infra/codegen/sync-from-db?tableId=' + tableId,
  29. method: 'put'
  30. })
  31. }
  32. // 基于 SQL 建表语句,同步数据库的表和字段定义
  33. export function syncCodegenFromSQL(tableId, sql) {
  34. return request({
  35. url: '/infra/codegen/sync-from-sql?tableId=' + tableId,
  36. method: 'put',
  37. headers:{
  38. 'Content-type': 'application/x-www-form-urlencoded'
  39. },
  40. data: 'tableId=' + tableId + "&sql=" + sql,
  41. })
  42. }
  43. // 预览生成代码
  44. export function previewCodegen(tableId) {
  45. return request({
  46. url: '/infra/codegen/preview?tableId=' + tableId,
  47. method: 'get',
  48. })
  49. }
  50. // 下载生成代码
  51. export function downloadCodegen(tableId) {
  52. return request({
  53. url: '/infra/codegen/download?tableId=' + tableId,
  54. method: 'get',
  55. responseType: 'blob'
  56. })
  57. }
  58. // 获得表定义分页
  59. export function getSchemaTableList(query) {
  60. return request({
  61. url: '/infra/codegen/db/table/list',
  62. method: 'get',
  63. params: query
  64. })
  65. }
  66. // 基于数据库的表结构,创建代码生成器的表定义
  67. export function createCodegenList(data) {
  68. return request({
  69. url: '/infra/codegen/create-list',
  70. method: 'post',
  71. data: data
  72. })
  73. }
  74. // 删除数据库的表和字段定义
  75. export function deleteCodegen(tableId) {
  76. return request({
  77. url: '/infra/codegen/delete?tableId=' + tableId,
  78. method: 'delete'
  79. })
  80. }