搜索关键字爬虫
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { api } from '@/apis/index';
|
||||
import type { CrontabTask, CrontabLog, ResultDomain, PageParam } from '@/types';
|
||||
import type { CrontabTask, CrontabLog, DataCollectionItem, CrontabItem, ResultDomain, PageParam } from '@/types';
|
||||
|
||||
/**
|
||||
* 定时任务API服务
|
||||
@@ -14,14 +14,23 @@ export const crontabApi = {
|
||||
baseUrl: '/crontab',
|
||||
|
||||
// ==================== 定时任务管理 ====================
|
||||
|
||||
|
||||
/**
|
||||
* 获取可创建的定时任务模板列表
|
||||
* @returns Promise<ResultDomain<CrontabItem>>
|
||||
*/
|
||||
async getEnabledCrontabList(): Promise<ResultDomain<CrontabItem>> {
|
||||
const response = await api.get<CrontabItem>(`${this.baseUrl}/getEnabledCrontabList`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建定时任务
|
||||
* @param task 任务对象
|
||||
* @returns Promise<ResultDomain<CrontabTask>>
|
||||
*/
|
||||
async createTask(task: CrontabTask): Promise<ResultDomain<CrontabTask>> {
|
||||
const response = await api.post<CrontabTask>(`${this.baseUrl}/task`, task);
|
||||
const response = await api.post<CrontabTask>(`${this.baseUrl}/crontabTask`, task);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -31,7 +40,7 @@ export const crontabApi = {
|
||||
* @returns Promise<ResultDomain<CrontabTask>>
|
||||
*/
|
||||
async updateTask(task: CrontabTask): Promise<ResultDomain<CrontabTask>> {
|
||||
const response = await api.put<CrontabTask>(`${this.baseUrl}/task`, task);
|
||||
const response = await api.put<CrontabTask>(`${this.baseUrl}/crontabTask`, task);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -41,7 +50,7 @@ export const crontabApi = {
|
||||
* @returns Promise<ResultDomain<CrontabTask>>
|
||||
*/
|
||||
async deleteTask(task: CrontabTask): Promise<ResultDomain<CrontabTask>> {
|
||||
const response = await api.delete<CrontabTask>(`${this.baseUrl}/task`, task);
|
||||
const response = await api.delete<CrontabTask>(`${this.baseUrl}/crontabTask`, task);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -72,11 +81,11 @@ export const crontabApi = {
|
||||
* @returns Promise<ResultDomain<CrontabTask>>
|
||||
*/
|
||||
async getTaskPage(filter?: Partial<CrontabTask>, pageParam?: PageParam): Promise<ResultDomain<CrontabTask>> {
|
||||
const response = await api.post<CrontabTask>(`${this.baseUrl}/task/page`, {
|
||||
const response = await api.post<CrontabTask>(`${this.baseUrl}/crontabTaskPage`, {
|
||||
filter,
|
||||
pageParam: {
|
||||
pageNumber: pageParam?.page || 1,
|
||||
pageSize: pageParam?.size || 10
|
||||
pageNumber: pageParam?.pageNumber || 1,
|
||||
pageSize: pageParam?.pageSize || 10
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
@@ -153,11 +162,11 @@ export const crontabApi = {
|
||||
* @returns Promise<ResultDomain<CrontabLog>>
|
||||
*/
|
||||
async getLogPage(filter?: Partial<CrontabLog>, pageParam?: PageParam): Promise<ResultDomain<CrontabLog>> {
|
||||
const response = await api.post<CrontabLog>(`${this.baseUrl}/log/page`, {
|
||||
const response = await api.post<CrontabLog>(`${this.baseUrl}/crontabTaskLogPage`, {
|
||||
filter,
|
||||
pageParam: {
|
||||
pageNumber: pageParam?.page || 1,
|
||||
pageSize: pageParam?.size || 10
|
||||
pageNumber: pageParam?.pageNumber || 1,
|
||||
pageSize: pageParam?.pageSize || 10
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
@@ -191,6 +200,49 @@ export const crontabApi = {
|
||||
async deleteLog(log: CrontabLog): Promise<ResultDomain<CrontabLog>> {
|
||||
const response = await api.delete<CrontabLog>(`${this.baseUrl}/log`, log);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// ==================== 数据采集项管理 ====================
|
||||
|
||||
/**
|
||||
* 根据任务日志ID查询数据采集项列表
|
||||
* @param taskLogId 任务日志ID
|
||||
* @returns Promise<ResultDomain<DataCollectionItem>>
|
||||
*/
|
||||
async getCollectionItemsByLogId(taskLogId: string): Promise<ResultDomain<DataCollectionItem>> {
|
||||
const response = await api.get<DataCollectionItem>(`${this.baseUrl}/collection/item/task/${taskLogId}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 分页查询数据采集项列表
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @returns Promise<ResultDomain<DataCollectionItem>>
|
||||
*/
|
||||
async getCollectionItemPage(filter?: Partial<DataCollectionItem>, pageParam?: PageParam): Promise<ResultDomain<DataCollectionItem>> {
|
||||
const response = await api.post<DataCollectionItem>(`${this.baseUrl}/collection/item/page`, {
|
||||
filter,
|
||||
pageParam: {
|
||||
pageNumber: pageParam?.pageNumber || 1,
|
||||
pageSize: pageParam?.pageSize || 10
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 转换采集项为资源文章
|
||||
* @param itemId 采集项ID
|
||||
* @param tagId 标签ID
|
||||
* @returns Promise<ResultDomain<string>>
|
||||
*/
|
||||
async convertItemToResource(itemId: string, tagId: string): Promise<ResultDomain<string>> {
|
||||
const response = await api.post<string>(`${this.baseUrl}/collection/item/resource`, {
|
||||
itemId,
|
||||
tagId
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user