代码生成器
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.
 
 

66 lines
1.4 KiB

import { defHttp } from '/@/utils/http/axios';
import { ${entityName}Model, ${entityName}Param } from './model';
enum Api {
List = '/api/${moduleName}/${entityPath}',
Page = '/api/${moduleName}/${entityPath}/page',
Save = '/api/${moduleName}/${entityPath}',
Update = '/api/${moduleName}/${entityPath}',
Delete = '/api/${moduleName}/${entityPath}',
BatchDelete = '/api/${moduleName}/${entityPath}/batch',
}
/**
* ${tableComment} API
*/
export class ${entityName}Api {
/**
* 分页查询
*/
static page = (params: ${entityName}Param) => {
return defHttp.get({ url: Api.Page, params });
};
/**
* 列表查询
*/
static list = (params?: ${entityName}Param) => {
return defHttp.get({ url: Api.List, params });
};
/**
* 根据ID查询
*/
static getById = (id: number) => {
return defHttp.get({ url: `${Api.List}/${id}` });
};
/**
* 新增
*/
static save = (data: ${entityName}Model) => {
return defHttp.post({ url: Api.Save, data });
};
/**
* 修改
*/
static update = (data: ${entityName}Model) => {
return defHttp.put({ url: Api.Update, data });
};
/**
* 删除
*/
static delete = (id: number) => {
return defHttp.delete({ url: `${Api.Delete}/${id}` });
};
/**
* 批量删除
*/
static batchDelete = (ids: number[]) => {
return defHttp.delete({ url: Api.BatchDelete, data: ids });
};
}