Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled
144 lines
2.8 KiB
TypeScript
144 lines
2.8 KiB
TypeScript
import type { Recordable } from '@vben/types';
|
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
export namespace FeatureApi {
|
|
export interface FeatureItem {
|
|
id: string;
|
|
api_id: string;
|
|
name: string;
|
|
whitelist_price: number;
|
|
cost_price: number;
|
|
create_time: string;
|
|
update_time: string;
|
|
}
|
|
|
|
export interface FeatureList {
|
|
total: number;
|
|
items: FeatureItem[];
|
|
}
|
|
|
|
export interface CreateFeatureRequest {
|
|
api_id: string;
|
|
name: string;
|
|
whitelist_price?: number;
|
|
cost_price?: number;
|
|
}
|
|
|
|
export interface UpdateFeatureRequest {
|
|
api_id?: string;
|
|
name?: string;
|
|
whitelist_price?: number;
|
|
cost_price?: number;
|
|
}
|
|
|
|
export interface FeatureExampleItem {
|
|
id: number;
|
|
feature_id: number;
|
|
api_id: string;
|
|
data: string;
|
|
create_time: string;
|
|
update_time: string;
|
|
}
|
|
|
|
export interface ConfigFeatureExampleRequest {
|
|
feature_id: string;
|
|
data: string;
|
|
}
|
|
|
|
export interface ConfigFeatureExampleResponse {
|
|
success: boolean;
|
|
}
|
|
|
|
export interface GetFeatureExampleRequest {
|
|
feature_id: string;
|
|
}
|
|
|
|
export interface GetFeatureExampleResponse {
|
|
id: string;
|
|
feature_id: string;
|
|
api_id: string;
|
|
data: string;
|
|
create_time: string;
|
|
update_time: string;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取模块列表数据
|
|
*/
|
|
async function getFeatureList(params: Recordable<any>) {
|
|
return requestClient.get<FeatureApi.FeatureList>('/feature/list', {
|
|
params,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 获取模块详情
|
|
* @param id 模块ID
|
|
*/
|
|
async function getFeatureDetail(id: string) {
|
|
return requestClient.get<FeatureApi.FeatureItem>(`/feature/detail/${id}`);
|
|
}
|
|
|
|
/**
|
|
* 创建模块
|
|
* @param data 模块数据
|
|
*/
|
|
async function createFeature(data: FeatureApi.CreateFeatureRequest) {
|
|
return requestClient.post<{ id: string }>('/feature/create', data);
|
|
}
|
|
|
|
/**
|
|
* 更新模块
|
|
* @param id 模块ID
|
|
* @param data 模块数据
|
|
*/
|
|
async function updateFeature(
|
|
id: string,
|
|
data: FeatureApi.UpdateFeatureRequest,
|
|
) {
|
|
return requestClient.put<{ success: boolean }>(`/feature/update/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* 删除模块
|
|
* @param id 模块ID
|
|
*/
|
|
async function deleteFeature(id: string) {
|
|
return requestClient.delete<{ success: boolean }>(`/feature/delete/${id}`);
|
|
}
|
|
|
|
/**
|
|
* 配置功能示例数据
|
|
* @param data 示例数据配置
|
|
*/
|
|
async function configFeatureExample(
|
|
data: FeatureApi.ConfigFeatureExampleRequest,
|
|
) {
|
|
return requestClient.post<FeatureApi.ConfigFeatureExampleResponse>(
|
|
'/feature/config-example',
|
|
data,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 获取功能示例数据
|
|
* @param featureId 功能ID
|
|
*/
|
|
async function getFeatureExample(featureId: string) {
|
|
return requestClient.get<FeatureApi.GetFeatureExampleResponse>(
|
|
`/feature/example/${featureId}`,
|
|
);
|
|
}
|
|
|
|
export {
|
|
configFeatureExample,
|
|
createFeature,
|
|
deleteFeature,
|
|
getFeatureDetail,
|
|
getFeatureExample,
|
|
getFeatureList,
|
|
updateFeature,
|
|
};
|