Files
timeline-frontend/src/pages/story/service.ts

96 lines
2.4 KiB
TypeScript
Raw Normal View History

2025-07-22 22:52:55 +08:00
import { request } from '@umijs/max';
2025-07-25 20:25:28 +08:00
import { StoryItem, StoryType } from './data.d';
2025-08-05 19:02:14 +08:00
import {CommonResponse} from "@/types/common";
2025-07-22 22:52:55 +08:00
type ParamsType = {
count?: number;
instanceId?: string;
2025-07-25 20:25:28 +08:00
storyName?: string;
2025-07-22 22:52:55 +08:00
} & Partial<StoryType>;
export async function queryTimelineList(
params: ParamsType,
2025-07-25 20:25:28 +08:00
): Promise<{ data: StoryType[] }> {
2025-07-22 22:52:55 +08:00
return await request('/story/owner/test11', {
2025-07-25 20:25:28 +08:00
params,
2025-07-22 22:52:55 +08:00
});
}
2025-07-25 20:25:28 +08:00
export async function deleteStory(params: ParamsType): Promise<{ data: { list: StoryType[] } }> {
2025-07-22 22:52:55 +08:00
return request(`/story/${params.instanceId}`, {
method: 'DELETE',
});
}
2025-07-25 20:25:28 +08:00
export async function addStory(params: ParamsType): Promise<{ data: { list: StoryType[] } }> {
2025-07-22 22:52:55 +08:00
return request('/story/add', {
method: 'POST',
data: {
...params,
method: 'post',
},
});
}
2025-07-25 20:25:28 +08:00
export async function updateStory(params: ParamsType): Promise<{ data: { list: StoryType[] } }> {
2025-07-22 22:52:55 +08:00
return await request(`/story/${params.instanceId}`, {
method: 'PUT',
data: {
...params,
method: 'put',
},
});
}
2025-08-05 19:02:14 +08:00
export async function queryStoryDetail(itemId: string): Promise<{ data: StoryType }> {
return request(`/story/${itemId}`, {
method: 'GET',
});
}
2025-07-25 20:25:28 +08:00
export async function addStoryItem(params: FormData): Promise<any> {
2025-07-22 22:52:55 +08:00
return request(`/story/item`, {
method: 'POST',
data: params,
requestType: 'form',
getResponse: true,
});
}
2025-07-25 20:25:28 +08:00
2025-08-05 19:02:14 +08:00
export async function queryStoryItem(storyInstanceId: string): Promise<{ data: StoryItem[] }> {
2025-07-22 22:52:55 +08:00
return request(`/story/item/list`, {
method: 'GET',
params: {
2025-08-05 19:02:14 +08:00
storyInstanceId,
2025-07-22 22:52:55 +08:00
},
});
}
2025-07-25 20:25:28 +08:00
2025-08-05 19:02:14 +08:00
export async function queryStoryItemDetail(itemId: string): Promise<{ data: StoryItem }> {
2025-07-22 22:52:55 +08:00
return request(`/story/item/${itemId}`, {
method: 'GET',
});
}
2025-08-05 19:02:14 +08:00
export async function countStoryItem(storyInstanceId: string): Promise<{ data: StoryItem }> {
return request(`/story/item/count/${storyInstanceId}`, {
method: 'GET',
});
}
2025-07-25 20:25:28 +08:00
export async function queryStoryItemImages(itemId: string): Promise<{ data: string[] }> {
2025-07-22 22:52:55 +08:00
return request(`/story/item/images/${itemId}`, {
method: 'GET',
});
}
2025-08-05 19:02:14 +08:00
export async function removeStoryItem(itemId: string): Promise<CommonResponse<string>> {
return request(`/story/item/${itemId}`, {
method: 'DELETE',
});
}
2025-07-25 20:25:28 +08:00
export async function fetchImage(imageInstanceId: string): Promise<any> {
2025-08-04 16:56:39 +08:00
return request(`/file/image/${imageInstanceId}`, {
2025-07-22 22:52:55 +08:00
method: 'GET',
responseType: 'blob',
getResponse: true,
2025-07-25 20:25:28 +08:00
});
2025-07-22 22:52:55 +08:00
}