diff --git a/ruoyi-generator/src/main/resources/vm/js/api.js.vm b/ruoyi-generator/src/main/resources/vm/js/api.js.vm deleted file mode 100644 index cd2403cc6..000000000 --- a/ruoyi-generator/src/main/resources/vm/js/api.js.vm +++ /dev/null @@ -1,53 +0,0 @@ -import request from '@/utils/request' - -// 查询${functionName}列表 -export function list${BusinessName}(query) { - return request({ - url: '/${moduleName}/${businessName}/list', - method: 'get', - params: query - }) -} - -// 查询${functionName}详细 -export function get${BusinessName}(${pkColumn.javaField}) { - return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'get' - }) -} - -// 新增${functionName} -export function add${BusinessName}(data) { - return request({ - url: '/${moduleName}/${businessName}', - method: 'post', - data: data - }) -} - -// 修改${functionName} -export function update${BusinessName}(data) { - return request({ - url: '/${moduleName}/${businessName}', - method: 'put', - data: data - }) -} - -// 删除${functionName} -export function del${BusinessName}(${pkColumn.javaField}) { - return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'delete' - }) -} - -// 导出${functionName} -export function export${BusinessName}(query) { - return request({ - url: '/${moduleName}/${businessName}/export', - method: 'get', - params: query - }) -} \ No newline at end of file diff --git a/ruoyi-ui/src/api/tool/testDemo.js b/ruoyi-ui/src/api/tool/testDemo.js new file mode 100644 index 000000000..c4a5117ca --- /dev/null +++ b/ruoyi-ui/src/api/tool/testDemo.js @@ -0,0 +1,55 @@ +import request from '@/utils/request' + +// 创建字典类型 +export function createTestDemo(data) { + return request({ + url: '/tool/test-demo/create', + method: 'post', + data: data + }) +} + +// 更新字典类型 +export function updateTestDemo(data) { + return request({ + url: '/tool/test-demo/update', + method: 'put', + data: data + }) +} + + +// 删除字典类型 +export function deleteTestDemo(id) { + return request({ + url: '/tool/test-demo/delelte?id=' + id, + method: 'delete' + }) +} + +// 获得字典类型 +export function getTestDemo(id) { + return request({ + url: '/tool/test-demo/get?id=' + id, + method: 'get' + }) +} + +// 获得字典类型分页 +export function getTestDemoPage(query) { + return request({ + url: '/tool/test-demo/page', + method: 'get', + params: query + }) +} + +// 导出字典类型 Excel +export function exportTestDemoExcel(query) { + return request({ + url: '/tool/test-demo/export-excel', + method: 'get', + params: query, + reponseBody: 'blob' + }) +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java b/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java index 809387cfd..548884ec8 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java +++ b/src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java @@ -81,6 +81,8 @@ public class ToolCodegenEngine { // Vue .put(vueTemplatePath("views/index.vue"), vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue")) + .put(vueTemplatePath("api/api.js"), + vueFilePath("api/${table.moduleName}/${classNameVar}.js")) // SQL .build(); @@ -163,6 +165,7 @@ public class ToolCodegenEngine { filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName()); filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName()); filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName()); + filePath = StrUtil.replace(filePath, "${classNameVar}", (String) bindingMap.get("classNameVar")); return filePath; } diff --git a/src/main/resources/codegen/vue/api/api.js.vm b/src/main/resources/codegen/vue/api/api.js.vm index 296d41aed..9dc2bd211 100644 --- a/src/main/resources/codegen/vue/api/api.js.vm +++ b/src/main/resources/codegen/vue/api/api.js.vm @@ -1,53 +1,56 @@ import request from '@/utils/request' +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") -// 查询${functionName}列表 -export function list${BusinessName}(query) { +// 创建${table.classComment} +export function create${simpleClassName}(data) { return request({ - url: '/${moduleName}/${businessName}/list', - method: 'get', - params: query - }) -} - -// 查询${functionName}详细 -export function get${BusinessName}(${pkColumn.javaField}) { - return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'get' - }) -} - -// 新增${functionName} -export function add${BusinessName}(data) { - return request({ - url: '/${moduleName}/${businessName}', + url: '${baseURL}/create', method: 'post', data: data }) } -// 修改${functionName} -export function update${BusinessName}(data) { +// 更新${table.classComment} +export function update${simpleClassName}(data) { return request({ - url: '/${moduleName}/${businessName}', + url: '${baseURL}/update', method: 'put', data: data }) } -// 删除${functionName} -export function del${BusinessName}(${pkColumn.javaField}) { + +// 删除${table.classComment} +export function delete${simpleClassName}(id) { return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, + url: '${baseURL}/delelte?id=' + id, method: 'delete' }) } -// 导出${functionName} -export function export${BusinessName}(query) { +// 获得${table.classComment} +export function get${simpleClassName}(id) { return request({ - url: '/${moduleName}/${businessName}/export', + url: '${baseURL}/get?id=' + id, + method: 'get' + }) +} + +// 获得${table.classComment}分页 +export function get${simpleClassName}Page(query) { + return request({ + url: '${baseURL}/page', method: 'get', params: query }) -} \ No newline at end of file +} + +// 导出${table.classComment} Excel +export function export${simpleClassName}Excel(query) { + return request({ + url: '${baseURL}/export-excel', + method: 'get', + params: query, + reponseBody: 'blob' + }) +} diff --git a/src/main/resources/codegen/vue/views/index.vue.vm b/src/main/resources/codegen/vue/views/index.vue.vm index ffa2ffced..252c91c98 100644 --- a/src/main/resources/codegen/vue/views/index.vue.vm +++ b/src/main/resources/codegen/vue/views/index.vue.vm @@ -111,14 +111,17 @@ #end #elseif($column.htmlType == "imageUpload")## 图片上传 + #set ($hasImageUploadColumn = true) #elseif($column.htmlType == "fileUpload")## 文件上传 + #set ($hasFileUploadColumn = true) #elseif($column.htmlType == "editor")## 文本编辑器 + #set ($hasEditorColumn = true) @@ -176,46 +179,28 @@