feat: 代码生成器-前端

V0.5.x
jay 2023-07-04 13:56:14 +08:00
parent a44128fc1f
commit 563459ba77
2 changed files with 50 additions and 62 deletions

View File

@ -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<string | number>) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'delete'
method: 'post',
data: ${pkColumn.javaField}
})
}

View File

@ -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<string | number>) => {
// 删除${functionName}
export const del${BusinessName}(${pkColumn.javaField}: Array<string | number>) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'delete'
});
};
method: 'post',
data: ${pkColumn.javaField}
})
}