Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Commit a3c461c

Browse files
author
Weidows
committed
complete study_aboard_planning
1 parent f22d564 commit a3c461c

7 files changed

Lines changed: 254 additions & 39 deletions

File tree

12.5 KB
Binary file not shown.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `filePath` on the `ReviewStorage` table. All the data in the column will be lost.
5+
- You are about to drop the column `filename` on the `ReviewStorage` table. All the data in the column will be lost.
6+
- You are about to drop the column `filesize` on the `ReviewStorage` table. All the data in the column will be lost.
7+
- You are about to drop the column `filetype` on the `ReviewStorage` table. All the data in the column will be lost.
8+
- You are about to drop the column `hash` on the `ReviewStorage` table. All the data in the column will be lost.
9+
- Added the required column `fileStorageHash` to the `ReviewStorage` table without a default value. This is not possible if the table is not empty.
10+
11+
*/
12+
-- CreateTable
13+
CREATE TABLE "FileStorage" (
14+
"hash" TEXT NOT NULL PRIMARY KEY,
15+
"file" BLOB NOT NULL,
16+
"filePath" TEXT,
17+
"filename" TEXT,
18+
"filesize" INTEGER,
19+
"filetype" TEXT
20+
);
21+
22+
-- RedefineTables
23+
PRAGMA foreign_keys=OFF;
24+
CREATE TABLE "new_ReviewStorage" (
25+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
26+
"profile_id" TEXT NOT NULL DEFAULT '',
27+
"RequestMessage" TEXT,
28+
"RequestUser" TEXT NOT NULL,
29+
"mentioned" TEXT NOT NULL DEFAULT '',
30+
"deleted" BOOLEAN NOT NULL DEFAULT false,
31+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
32+
"updatedAt" DATETIME NOT NULL,
33+
"fileStorageHash" TEXT NOT NULL,
34+
CONSTRAINT "ReviewStorage_fileStorageHash_fkey" FOREIGN KEY ("fileStorageHash") REFERENCES "FileStorage" ("hash") ON DELETE RESTRICT ON UPDATE CASCADE
35+
);
36+
INSERT INTO "new_ReviewStorage" ("RequestMessage", "RequestUser", "createdAt", "deleted", "id", "mentioned", "profile_id", "updatedAt") SELECT "RequestMessage", "RequestUser", "createdAt", "deleted", "id", "mentioned", "profile_id", "updatedAt" FROM "ReviewStorage";
37+
DROP TABLE "ReviewStorage";
38+
ALTER TABLE "new_ReviewStorage" RENAME TO "ReviewStorage";
39+
CREATE UNIQUE INDEX "ReviewStorage_id_key" ON "ReviewStorage"("id");
40+
PRAGMA foreign_key_check;
41+
PRAGMA foreign_keys=ON;
42+
43+
-- CreateIndex
44+
CREATE UNIQUE INDEX "FileStorage_hash_key" ON "FileStorage"("hash");
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// import {
2+
// ReviewStorage,
3+
// createReviewStorage,
4+
// getReviewStorage,
5+
// updateReviewStorage,
6+
// deleteReviewStorage,
7+
// } from "./review";
8+
9+
// describe("Prisma CRUD", () => {
10+
// let testReview: ReviewStorage = {
11+
// id: 1,
12+
// profile_id: "media",
13+
// RequestUser: "18330785221",
14+
// mentioned: "18330785221",
15+
// filename: "Test Filename",
16+
// filesize: 100,
17+
// filetype: "Test Type",
18+
// };
19+
20+
// it("creates a review", async () => {
21+
// const review = await createReviewStorage(testReview);
22+
23+
// expect(review.id).toBeDefined();
24+
// });
25+
26+
// it("gets the created review", async () => {
27+
// const review = await getReviewStorage(testReview.id);
28+
29+
// if (review) {
30+
// expect(review.profile_id).toBe("media");
31+
// } else {
32+
// fail("Review is null");
33+
// }
34+
// });
35+
36+
// it("updates the review", async () => {
37+
// await updateReviewStorage(testReview.id, {
38+
// ...testReview,
39+
// profile_id: "",
40+
// // 如果你更新了其他属性,也需要在这里添加
41+
// });
42+
43+
// const review = await getReviewStorage(testReview.id);
44+
// if (review) {
45+
// expect(review.profile_id).toBe("Updated Profile");
46+
// } else {
47+
// fail("Review is null");
48+
// }
49+
// });
50+
51+
// it("deletes the review", async () => {
52+
// await deleteReviewStorage(testReview.id);
53+
54+
// try {
55+
// await getReviewStorage(testReview.id);
56+
// fail("Review was not deleted");
57+
// } catch (error) {
58+
// // Review was deleted
59+
// }
60+
// });
61+
// });

react-app/src/api/db/review.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { FileCardProps } from "@/components/FileCard";
12
import prisma from "../prisma";
3+
import { FileLocalStorage } from "./file/storage";
24

35
interface ReviewStorage {
46
id?: number;
@@ -19,10 +21,15 @@ interface ReviewStorage {
1921
updatedAt?: Date;
2022
}
2123

22-
// ReviewStorage CRUD
23-
async function createReviewStorage(data: ReviewStorage) {
24+
async function createReviewStorage(
25+
payload: FormData,
26+
fileProps: FileCardProps
27+
) {
28+
FileLocalStorage(payload,fileProps);
2429
return await prisma.reviewStorage.create({
25-
data: data,
30+
data: {
31+
profile_id: "",
32+
},
2633
});
2734
}
2835

@@ -62,7 +69,7 @@ async function deleteReviewStorage(id: number) {
6269

6370
export {
6471
ReviewStorage as ReviewStorage,
65-
createReviewStorage,
72+
// createReviewStorage,
6673
getReviewStorages,
6774
getReviewStoragesDesc,
6875
getReviewStorage,

react-app/src/api/review.ts

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,70 @@
1-
import axios, { AxiosProgressEvent, AxiosRequestConfig } from 'axios'
1+
import axios, { AxiosProgressEvent, AxiosRequestConfig } from "axios";
22

3-
const API_ENDPOINT = "http://aidvisor.valmech.net:5000";
3+
// const API_ENDPOINT = "http://localhost:8000";
4+
const API_ENDPOINT = "http://aidvisor.valmech.net";
45
const api = axios.create({
56
baseURL: API_ENDPOINT,
67
headers: {
7-
'X-API-Key': 'secret_api_key',
8-
}
9-
})
8+
"X-API-Key": "secret_api_key",
9+
},
10+
});
11+
12+
export const GetOpenAIConnectionTest = async () => {
13+
return await api.post("/api/test/conn/");
14+
};
1015

1116
export interface GetFileReviewResponse {
12-
data: string
17+
data: string;
1318
}
1419

15-
export const GetFileReview = async (payload: FormData, onProgressUpdate: (p: AxiosProgressEvent) => void) => {
20+
export const GetFileReview = async (
21+
payload: FormData,
22+
onProgressUpdate: (p: AxiosProgressEvent) => void
23+
) => {
1624
const config: AxiosRequestConfig = {
17-
onUploadProgress: onProgressUpdate
18-
}
25+
onUploadProgress: onProgressUpdate,
26+
};
1927
// return await api.post('/api/file/review', payload, config)
20-
return await api.post('/api/file/rating', payload, config)
28+
return await api.post("/api/tabs/reports-review/", payload, config);
29+
};
30+
31+
interface GetStudyAboardPlanningResponse {
32+
data: {
33+
冲刺院校1: {
34+
学校名称: string;
35+
推荐专业: string;
36+
推荐原因: string;
37+
};
38+
冲刺院校2: {
39+
学校名称: string;
40+
推荐专业: string;
41+
推荐原因: string;
42+
};
43+
适中院校1: {
44+
学校名称: string;
45+
推荐专业: string;
46+
推荐原因: string;
47+
};
48+
适中院校2: {
49+
学校名称: string;
50+
推荐专业: string;
51+
推荐原因: string;
52+
};
53+
保底院校1: {
54+
学校名称: string;
55+
推荐专业: string;
56+
推荐原因: string;
57+
};
58+
保底院校2: {
59+
学校名称: string;
60+
推荐专业: string;
61+
推荐原因: string;
62+
};
63+
};
2164
}
2265

23-
export const GetOpenAIConnectionTest = async () => {
24-
return await api.post("/api/conn/test");
66+
export const GetStudyAboardPlanning = async (
67+
payload: FormData
68+
): Promise<GetStudyAboardPlanningResponse> => {
69+
return await api.post("/api/tabs/study-aboard-planning/", payload);
2570
};

react-app/src/components/FileCard/index.tsx

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ export function FileCard(props: FileCardProps) {
148148
</div>
149149
{props.done && (
150150
<div className={s("card vertical shadow")}>
151-
{props.tab === TabIDsEnum.ReportsReview && (
151+
{props.tab && (
152152
<div className="w-full">
153-
<h2> 审核概述 </h2>
153+
<h2> 处理结果 </h2>
154154
<DashedSparator className={s("my-4")} />
155155
<p className={s("overview")}>{props.overview}</p>
156156
<DashedSparator className={s("my-4")} />
157-
<div className={s("card horizontal bordered")}>
157+
{/* <div className={s("card horizontal bordered")}>
158158
<div className="flex flex-row space-x-4 items-center flex-1 w-0">
159159
<DocumentIcon type={props.filetype} />
160160
<div className={s("file-info-wrap")}>
@@ -178,7 +178,7 @@ export function FileCard(props: FileCardProps) {
178178
mentioned={props.mentioned}
179179
mentionables={props.mentionables}
180180
onCopyOverview={handleOverviewCopy}
181-
/>
181+
/> */}
182182
</div>
183183
)}
184184
{props.tab === TabIDsEnum.ReportsReview && (
@@ -296,7 +296,7 @@ export function DocumentIcon({
296296
".doc": <DocIcon className={classNames} />,
297297
".docx": <DocIcon className={classNames} />,
298298
".md": <TxtIcon className={classNames} />,
299-
".xls": <TableCellsIcon className={classNames} />,
299+
".xls": <ExcelIcon className={classNames} />,
300300
};
301301

302302
return mappings[type];
@@ -388,3 +388,38 @@ const DocIcon = forwardRef<SVGSVGElement, React.HTMLProps<SVGSVGElement>>(
388388
);
389389
}
390390
);
391+
392+
const ExcelIcon = forwardRef<SVGSVGElement, React.HTMLProps<SVGSVGElement>>(
393+
(props, ref) => {
394+
return (
395+
<svg
396+
ref={ref}
397+
{...props}
398+
width="40"
399+
height="40"
400+
viewBox="0 0 40 40"
401+
fill="none"
402+
xmlns="http://www.w3.org/2000/svg"
403+
404+
// stroke-width="1.5"
405+
// stroke="currentColor"
406+
// class="w-6 h-6"
407+
>
408+
{/* <path
409+
d="M5 6C5 3.79086 6.79086 2 9 2H27C31.4183 2 35 5.58172 35 10V34C35 36.2091 33.2091 38 31 38H9C6.79086 38 5 36.2091 5 34V6Z"
410+
fill="#9CCC65"
411+
/>
412+
<path
413+
d="M26.5 3.5C30.366 3.5 33.5 6.63401 33.5 10.5H26.5V3.5Z"
414+
fill="white"
415+
/> */}
416+
<path
417+
stroke-linecap="round"
418+
stroke-linejoin="round"
419+
d="M3.375 19.5h17.25m-17.25 0a1.125 1.125 0 01-1.125-1.125M3.375 19.5h7.5c.621 0 1.125-.504 1.125-1.125m-9.75 0V5.625m0 12.75v-1.5c0-.621.504-1.125 1.125-1.125m18.375 2.625V5.625m0 12.75c0 .621-.504 1.125-1.125 1.125m1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125m0 3.75h-7.5A1.125 1.125 0 0112 18.375m9.75-12.75c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125m19.5 0v1.5c0 .621-.504 1.125-1.125 1.125M2.25 5.625v1.5c0 .621.504 1.125 1.125 1.125m0 0h17.25m-17.25 0h7.5c.621 0 1.125.504 1.125 1.125M3.375 8.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125m17.25-3.75h-7.5c-.621 0-1.125.504-1.125 1.125m8.625-1.125c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125M12 10.875v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 10.875c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125M13.125 12h7.5m-7.5 0c-.621 0-1.125.504-1.125 1.125M20.625 12c.621 0 1.125.504 1.125 1.125v1.5c0 .621-.504 1.125-1.125 1.125m-17.25 0h7.5M12 14.625v-1.5m0 1.5c0 .621-.504 1.125-1.125 1.125M12 14.625c0 .621.504 1.125 1.125 1.125m-2.25 0c.621 0 1.125.504 1.125 1.125m0 1.5v-1.5m0 0c0-.621.504-1.125 1.125-1.125m0 0h7.5"
420+
fill="#9ECC65"
421+
/>
422+
</svg>
423+
);
424+
}
425+
);

react-app/src/pages/home/index.tsx

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import {
2424
FileCard,
2525
FileCardProps,
2626
TabIDsEnum,
27-
ValidFileTypeEnum
27+
ValidFileTypeEnum,
2828
} from "components/FileCard/index";
2929
import { Variants, motion } from "framer-motion";
3030
import { useQueryItem } from "hooks/useQueryItem";
3131
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
3232
import { classNames, modulize } from "utils/classNames";
3333
import { humanizeFileSize } from "utils/humanize";
3434

35-
import { GetFileReview } from "@/api/review";
35+
import { GetFileReview, GetStudyAboardPlanning } from "@/api/review";
3636
import { AxiosProgressEvent } from "axios";
3737
import { historyFiles, settingsGroups } from "./static-conf";
3838

@@ -200,22 +200,45 @@ const Home = () => {
200200
*/
201201
// console.log(fileProps);
202202

203-
GetFileReview(payload, updateProgress)
204-
.then((response) => {
205-
const matchResult = response.data.match(/(\d+?)\/100/);
206-
updateProps({
207-
...fileProps,
208-
uploadProgress: 1,
209-
done: true,
210-
mentioned: [],
211-
mentionables: [],
212-
overview: response.data.replace(/\s*\d+\/100/g, ""),
213-
grade: Number(matchResult ? matchResult[1] : 0),
214-
});
215-
})
216-
.catch((error) => {
217-
console.log(error);
218-
});
203+
switch (currentTab) {
204+
case TabIDsEnum.ReportsReview:
205+
GetFileReview(payload, updateProgress)
206+
.then((response) => {
207+
const matchResult = response.data.match(/(\d+?)\/100/);
208+
updateProps({
209+
...fileProps,
210+
uploadProgress: 1,
211+
done: true,
212+
mentioned: [],
213+
mentionables: [],
214+
overview: response.data.replace(/\s*\d+\/100/g, ""),
215+
grade: Number(matchResult ? matchResult[1] : 0),
216+
});
217+
})
218+
.catch((error) => {
219+
console.log(error);
220+
});
221+
break;
222+
case TabIDsEnum.StudyAbroadPlanning:
223+
GetStudyAboardPlanning(payload)
224+
.then((response) => {
225+
updateProps({
226+
...fileProps,
227+
uploadProgress: 1,
228+
done: true,
229+
mentioned: [],
230+
mentionables: [],
231+
overview: JSON.stringify(response.data, undefined, 2),
232+
grade: 0,
233+
});
234+
})
235+
.catch((error) => {
236+
console.log(error);
237+
});
238+
break;
239+
default:
240+
break;
241+
}
219242

220243
// TODO
221244
// createReviewStorage();

0 commit comments

Comments
 (0)