references.ts
5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*
* @Author: 赵丽婷
* @Date: 2025-10-21 11:40:50
* @LastEditors: 赵丽婷
* @LastEditTime: 2026-01-09 11:11:57
* @FilePath: \LinkMed\linkmed-vue3\src\api\references.ts
* @Description:
* Copyright (c) 2025 by 北京连心医疗科技有限公司, All Rights Reserved.
*/
import { service as http } from "@/utils/request";
// 参考文献项接口
export interface ReferenceItem {
id: number;
fileId: number;
workId: number;
title: string;
publicationYear: number;
authorsText: string;
doi: string;
landingUrl: string;
pdfUrl: string;
note: string;
updatedAt: string;
}
// 分页响应接口
export interface ReferenceListResponse {
items: ReferenceItem[];
total: number;
page: number;
size: number;
}
// 导入搜索结果项接口
export interface ImportSearchResultItem {
workId: number;
doi: string;
title: string;
publicationYear: number;
fileLibraryItemId: number | null;
createdNewWork: boolean;
createdFileLink: boolean;
source: string;
authorsText: string;
itemType: string;
venueName: string;
journalAbbr: string;
issn: string;
volume: string;
issue: string | null;
pages: string;
language: string;
landingUrl: string;
pdfUrl: string;
}
// 文献详情接口
export interface ReferenceDetail {
workId: number;
doi: string;
title: string;
publicationYear: number;
publicationDate: string;
itemType: string;
authorsText: string;
abstractText: string;
venueName: string;
journalAbbr: string;
issn: string;
volume: string;
issue: string;
pages: string;
language: string;
landingUrl: string;
pdfUrl: string;
source: string;
identifiersJson: string;
createdAt: string;
updatedAt: string;
note: string;
}
// 导入搜索响应接口
export interface ImportSearchResponse {
items: ImportSearchResultItem[];
}
// 小工具:拼 query params,过滤 undefined
function qp(obj: any = {}) {
const params: any = {};
Object.keys(obj).forEach((k) => {
const v = obj[k];
if (v !== undefined && v !== null) params[k] = v;
});
return params;
}
/**
* 分页查询文件文献列表
* @param fileId 文件ID(必填)
* @param page 页码
* @param size 每页数量
* @param isDraft 是否为草稿文件(默认false)
* - true: 从快问快答/深度检索创建的草稿文件
* - false: 从知识库打开的普通文件
*/
export const getFileReferences = (
fileId: string | number,
page?: number,
size?: number,
isDraft: boolean = false,
) => {
return http.get<ReferenceListResponse>("/references/file-library", {
params: qp({ fileId, page, size, isDraft }),
});
};
/**
* 按标题搜索参考文献
* @param title 标题关键字
*/
export const searchReferencesByTitle = (title: string) => {
return http.post<ImportSearchResponse>("/references/import/by-title", {
title,
});
};
/**
* 按DOI搜索参考文献
* @param doi DOI(支持带/不带 https://doi.org/ 前缀)
*/
export const searchReferencesByDoi = (doi: string) => {
return http.post<ImportSearchResponse>("/references/import/by-doi", {
doi,
});
};
/**
* 添加参考文献到文件
* @param fileId 文件ID
* @param workId 文献ID
*/
export const addReferenceToFile = (fileId: number, workId: number) => {
return http.post("/references/file-library/add", {
fileId,
workId,
});
};
/**
* 【深度检索】获取参考文献详情
* @param workId 文献ID(必填)
* @returns 返回包含完整文献信息的 ReferenceDetail 对象
*/
export const getReferenceDetail = (workId: number) => {
return http.get<ReferenceDetail>(`/references/${workId}`);
};
/**
* 删除文件的参考文献
* @param fileId 文件ID
* @param workId 文献ID
*/
export const deleteReferenceFromFile = (
fileId: number | string,
workId: number,
) => {
return http.delete(`/references/file-library/${fileId}/${workId}`);
};
/**
* 更新文件的参考文献别名
* @param fileId 文件ID
* @param workId 文献ID
* @param note 别名
*/
export const updateReferenceNote = (
fileId: number | string,
workId: number,
note: string,
) => {
return http.patch("/references/file-library/note", {
fileId,
workId,
note,
});
};
// 文内引用格式化响应接口
export interface InTextCitationResponse {
format: "apa" | "ieee";
texts: string[];
}
/**
* 获取文内引用格式化文本
* @param fileId 文件ID
* @param citationGroups 二维文献ID分组(按出现顺序)
* @param format 引用格式(apa/ieee)
* @param outputFormat 输出格式(text/html/markdown)
*/
export const getInTextCitation = (
fileId: number | string,
citationGroups: number[][],
format: "apa" | "ieee",
outputFormat: "text" | "html" | "markdown",
) => {
return http.post<InTextCitationResponse>(
"/references/file-library/in-text-citation",
{
fileId,
citationGroups,
format,
outputFormat,
},
);
};
// 完整参考文献列表响应接口
export interface FormatCitationResponse {
format: "apa" | "ieee";
entries: string[];
count: number;
}
/**
* 获取格式化的参考文献列表
* @param fileId 文件ID
* @param citationGroups 二维文献ID分组(按出现顺序)
* @param format 引用格式(apa/ieee)
* @param outputFormat 输出格式(text/html/markdown)
*/
export const getFormatCitation = (
fileId: number | string,
citationGroups: number[][],
format: "apa" | "ieee",
outputFormat: "text" | "html" | "markdown",
) => {
return http.post<FormatCitationResponse>(
"/references/file-library/format-citation",
{
fileId,
citationGroups,
format,
outputFormat,
},
);
};