diff --git a/iot-module/iot-generator/src/main/resources/vm/js/api.js.vm b/iot-module/iot-generator/src/main/resources/vm/js/api.js.vm index 9295524a..1df6ef37 100644 --- a/iot-module/iot-generator/src/main/resources/vm/js/api.js.vm +++ b/iot-module/iot-generator/src/main/resources/vm/js/api.js.vm @@ -1,44 +1,47 @@ import request from '@/utils/request' +import { ${BusinessName}Form, ${BusinessName}Query, ${BusinessName}VO } from './types' // 查询${functionName}列表 -export function list${BusinessName}(query) { +export function list${BusinessName}(query: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> { return request({ url: '/${moduleName}/${businessName}/list', - method: 'get', + method: 'post', params: query }) } // 查询${functionName}详细 -export function get${BusinessName}(${pkColumn.javaField}) { +export function get${BusinessName}(${pkColumn.javaField}: string | number) : AxiosPromise<${BusinessName}VO> { return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'get' + url: '/${moduleName}/${businessName}/getDetail', + method: 'post', + data: ${pkColumn.javaField} }) } // 新增${functionName} -export function add${BusinessName}(data) { +export function add${BusinessName}(data: ${BusinessName}Form) { return request({ - url: '/${moduleName}/${businessName}', + url: '/${moduleName}/${businessName}/add', method: 'post', - data: data + data, }) } // 修改${functionName} -export function update${BusinessName}(data) { +export function update${BusinessName}(data: ${BusinessName}Form) { return request({ - url: '/${moduleName}/${businessName}', - method: 'put', - data: data + url: '/${moduleName}/${businessName}/edit', + method: 'post', + data, }) } // 删除${functionName} -export function del${BusinessName}(${pkColumn.javaField}) { +export function del${BusinessName}(${pkColumn.javaField}: Array) { return request({ url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'delete' + method: 'post', + data: ${pkColumn.javaField} }) } diff --git a/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm b/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm index 3aa4a5f6..4341db23 100644 --- a/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm +++ b/iot-module/iot-generator/src/main/resources/vm/ts/api.ts.vm @@ -1,63 +1,48 @@ import request from '@/utils/request'; import { AxiosPromise } from 'axios'; -import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from '@/api/${moduleName}/${businessName}/types'; +import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from './types'; -/** - * 查询${functionName}列表 - * @param query - * @returns {*} - */ - -export const list${BusinessName} = (query?: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> => { +// 查询${functionName}列表 +export const list${BusinessName}(query: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> { return request({ url: '/${moduleName}/${businessName}/list', - method: 'get', + method: 'post', params: query - }); -}; + }) +} -/** - * 查询${functionName}详细 - * @param ${pkColumn.javaField} - */ -export const get${BusinessName} = (${pkColumn.javaField}: string | number): AxiosPromise<${BusinessName}VO> => { +// 查询${functionName}详细 +export const get${BusinessName}(${pkColumn.javaField}: string | number) : AxiosPromise<${BusinessName}VO> { return request({ - url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'get' - }); -}; + url: '/${moduleName}/${businessName}/getDetail', + method: 'post', + data: ${pkColumn.javaField} + }) +} -/** - * 新增${functionName} - * @param data - */ -export const add${BusinessName} = (data: ${BusinessName}Form) => { +// 新增${functionName} +export const add${BusinessName}(data: ${BusinessName}Form) { return request({ - url: '/${moduleName}/${businessName}', + url: '/${moduleName}/${businessName}/add', + method: 'post', + data + }) +} + +// 修改${functionName} +export const update${BusinessName}(data: ${BusinessName}Form) { + return request({ + url: '/${moduleName}/${businessName}/edit', method: 'post', data: data - }); -}; + }) +} -/** - * 修改${functionName} - * @param data - */ -export const update${BusinessName} = (data: ${BusinessName}Form) => { - return request({ - url: '/${moduleName}/${businessName}', - method: 'put', - data: data - }); -}; - -/** - * 删除${functionName} - * @param ${pkColumn.javaField} - */ -export const del${BusinessName} = (${pkColumn.javaField}: string | number | Array) => { +// 删除${functionName} +export const del${BusinessName}(${pkColumn.javaField}: Array) { return request({ url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, - method: 'delete' - }); -}; + method: 'post', + data: ${pkColumn.javaField} + }) +}