You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

125 lines
2.8 KiB

  1. /*
  2. * Copyright (c) 2018-2025, lengleng All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the pig4cloud.com developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: lengleng (wangiegie@gmail.com)
  16. */
  17. import request from '@/router/axios'
  18. export function fetchList(query) {
  19. return request({
  20. url: '/gen/generator/page',
  21. method: 'get',
  22. params: query
  23. })
  24. }
  25. export function fetchDsList(query) {
  26. return request({
  27. url: '/gen/dsconf/page',
  28. method: 'get',
  29. params: query
  30. })
  31. }
  32. export function fetchSelectDsList() {
  33. return request({
  34. url: '/gen/dsconf/list',
  35. method: 'get'
  36. })
  37. }
  38. export function addObj(obj) {
  39. return request({
  40. url: '/gen/dsconf/',
  41. method: 'post',
  42. data: obj
  43. })
  44. }
  45. export function getObj(id) {
  46. return request({
  47. url: '/gen/dsconf/' + id,
  48. method: 'get'
  49. })
  50. }
  51. export function delObj(id) {
  52. return request({
  53. url: '/gen/dsconf/' + id,
  54. method: 'delete'
  55. })
  56. }
  57. export function putObj(obj) {
  58. return request({
  59. url: '/gen/dsconf/',
  60. method: 'put',
  61. data: obj
  62. })
  63. }
  64. export function preview(table) {
  65. return request({
  66. url: '/gen/generator/preview',
  67. method: 'get',
  68. params: table
  69. })
  70. }
  71. export function handleDown(table) {
  72. return request({
  73. url: '/gen/generator/code',
  74. method: 'post',
  75. data: table,
  76. responseType: 'arraybuffer'
  77. }).then((response) => { // 处理返回的文件流
  78. const blob = new Blob([response.data], {type: 'application/zip'})
  79. const filename = table.tableName + '.zip'
  80. const link = document.createElement('a')
  81. link.href = URL.createObjectURL(blob)
  82. link.download = filename
  83. document.body.appendChild(link)
  84. link.click()
  85. window.setTimeout(function () {
  86. URL.revokeObjectURL(blob)
  87. document.body.removeChild(link)
  88. }, 0)
  89. })
  90. }
  91. export function getGenTable(query) {
  92. return request({
  93. url: '/gen/generator/table',
  94. params: query,
  95. method: 'get'
  96. })
  97. }
  98. export function getForm(tableName, dsName) {
  99. return request({
  100. url: '/gen/form/info',
  101. params: {tableName: tableName, dsName: dsName},
  102. method: 'get'
  103. })
  104. }
  105. export function postForm(formInfo, tableName, dsId) {
  106. return request({
  107. url: '/gen/form/',
  108. method: 'post',
  109. data: Object.assign({formInfo, tableName, dsId})
  110. })
  111. }