|
|
@@ -13,6 +13,21 @@ import { decodeAuditRecord } from '#/request/schema/audit-record';
|
|
|
|
|
|
export type PaperCategory = 'conference' | 'degree' | 'journal';
|
|
|
|
|
|
+/** 后端 `type` 字段:0-期刊论文 1-学位论文 2-会议论文 */
|
|
|
+export type PaperTypeDTO = '0' | '1' | '2';
|
|
|
+
|
|
|
+const PAPER_TYPE_TO_DTO: Record<PaperCategory, PaperTypeDTO> = {
|
|
|
+ journal: '0',
|
|
|
+ degree: '1',
|
|
|
+ conference: '2',
|
|
|
+};
|
|
|
+
|
|
|
+const PAPER_TYPE_FROM_DTO: Record<PaperTypeDTO, PaperCategory> = {
|
|
|
+ '0': 'journal',
|
|
|
+ '1': 'degree',
|
|
|
+ '2': 'conference',
|
|
|
+};
|
|
|
+
|
|
|
export const PAPER_CATEGORY_OPTIONS = [
|
|
|
{ label: '期刊论文', value: 'journal' },
|
|
|
{ label: '学位论文', value: 'degree' },
|
|
|
@@ -28,29 +43,57 @@ export function getPaperCategoryLabel(category?: PaperCategory) {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+export function decodePaperType(type?: number | string): PaperCategory {
|
|
|
+ const normalized = type?.toString();
|
|
|
+ if (normalized === '0' || normalized === '1' || normalized === '2') {
|
|
|
+ return PAPER_TYPE_FROM_DTO[normalized];
|
|
|
+ }
|
|
|
+ return 'journal';
|
|
|
+}
|
|
|
+
|
|
|
+/** 按 Tab 分类过滤分页结果(后端未按 type 过滤时的兜底) */
|
|
|
+export function filterPaperPageByCategory<
|
|
|
+ T extends { items: PaperVO[]; total: number },
|
|
|
+>(page: T, category?: PaperCategory): T {
|
|
|
+ if (!category) return page;
|
|
|
+ const items = page.items.filter((item) => item.category === category);
|
|
|
+ return { ...page, items };
|
|
|
+}
|
|
|
+
|
|
|
+function encodePaperType(category: PaperCategory): PaperTypeDTO {
|
|
|
+ return PAPER_TYPE_TO_DTO[category];
|
|
|
+}
|
|
|
+
|
|
|
// ---------------------------------------------------------------------------
|
|
|
// DTO
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
+/** 论文 DTO,对应 `OutcomePaperDetail` */
|
|
|
export interface PaperDTO extends AuditRecordDTO {
|
|
|
id?: number | string;
|
|
|
+ status?: string;
|
|
|
+ remark?: string;
|
|
|
personalStudioId?: number | string;
|
|
|
- category?: PaperCategory;
|
|
|
- title?: string;
|
|
|
- authors?: string;
|
|
|
- journalName?: string;
|
|
|
- publishYear?: string;
|
|
|
- volumeInfo?: string;
|
|
|
- keywords?: string;
|
|
|
fileUrl?: string;
|
|
|
downloadCount?: number;
|
|
|
+ browseCount?: number;
|
|
|
commentCount?: number;
|
|
|
+ praiseCount?: number;
|
|
|
+ /** 分类 0-期刊论文 1-学位论文 2-会议论文 */
|
|
|
+ type?: PaperTypeDTO | string;
|
|
|
+ title?: string;
|
|
|
+ author?: string;
|
|
|
+ journalName?: string;
|
|
|
+ publishYear?: string;
|
|
|
+ phase?: string;
|
|
|
+ keyword?: string;
|
|
|
}
|
|
|
|
|
|
export interface PaperQueryDTO {
|
|
|
mixture?: string;
|
|
|
personalStudioId?: number | string;
|
|
|
- category?: PaperCategory;
|
|
|
+ type?: PaperTypeDTO | string;
|
|
|
+ status?: string;
|
|
|
pageNum?: number;
|
|
|
pageSize?: number;
|
|
|
}
|
|
|
@@ -109,13 +152,13 @@ export function decodePaper(dto: PaperDTO): PaperVO {
|
|
|
...decodeAuditRecord(dto),
|
|
|
id: dto.id?.toString(),
|
|
|
workroomId: dto.personalStudioId?.toString() ?? '',
|
|
|
- category: dto.category ?? 'journal',
|
|
|
+ category: decodePaperType(dto.type),
|
|
|
title: dto.title ?? '',
|
|
|
- authors: dto.authors ?? '',
|
|
|
+ authors: dto.author ?? '',
|
|
|
journalName: dto.journalName ?? '',
|
|
|
publishYear: dto.publishYear ?? '',
|
|
|
- volumeInfo: dto.volumeInfo,
|
|
|
- keywords: dto.keywords,
|
|
|
+ volumeInfo: dto.phase,
|
|
|
+ keywords: dto.keyword,
|
|
|
pdfUrl: dto.fileUrl,
|
|
|
downloadCount: dto.downloadCount ?? 0,
|
|
|
commentCount: dto.commentCount ?? 0,
|
|
|
@@ -126,7 +169,7 @@ export function encodePaperQuery(query: Partial<PaperQueryVO>): PaperQueryDTO {
|
|
|
return {
|
|
|
mixture: query.keyword,
|
|
|
personalStudioId: query.workroomId,
|
|
|
- category: query.category,
|
|
|
+ type: query.category ? encodePaperType(query.category) : undefined,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -134,14 +177,14 @@ export function encodePaper(vo: PaperSubmitVO): PaperDTO {
|
|
|
return {
|
|
|
id: vo.id,
|
|
|
personalStudioId: vo.workroomId,
|
|
|
- category: vo.category,
|
|
|
+ fileUrl: vo.pdfUrl,
|
|
|
+ type: encodePaperType(vo.category),
|
|
|
title: vo.title,
|
|
|
- authors: vo.authors,
|
|
|
+ author: vo.authors,
|
|
|
journalName: vo.journalName,
|
|
|
publishYear: vo.publishYear,
|
|
|
- volumeInfo: vo.volumeInfo,
|
|
|
- keywords: vo.keywords,
|
|
|
- fileUrl: vo.pdfUrl,
|
|
|
+ phase: vo.volumeInfo,
|
|
|
+ keyword: vo.keywords,
|
|
|
};
|
|
|
}
|
|
|
|