This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from AIerLab/study-abroad-planning
Study abroad planning
- Loading branch information
Showing
9 changed files
with
462 additions
and
189 deletions.
There are no files selected for viewing
Binary file not shown.
44 changes: 44 additions & 0 deletions
44
react-app/src/api/db/prisma/migrations/20231027101800_init/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `filePath` on the `ReviewStorage` table. All the data in the column will be lost. | ||
- You are about to drop the column `filename` on the `ReviewStorage` table. All the data in the column will be lost. | ||
- You are about to drop the column `filesize` on the `ReviewStorage` table. All the data in the column will be lost. | ||
- You are about to drop the column `filetype` on the `ReviewStorage` table. All the data in the column will be lost. | ||
- You are about to drop the column `hash` on the `ReviewStorage` table. All the data in the column will be lost. | ||
- Added the required column `fileStorageHash` to the `ReviewStorage` table without a default value. This is not possible if the table is not empty. | ||
*/ | ||
-- CreateTable | ||
CREATE TABLE "FileStorage" ( | ||
"hash" TEXT NOT NULL PRIMARY KEY, | ||
"file" BLOB NOT NULL, | ||
"filePath" TEXT, | ||
"filename" TEXT, | ||
"filesize" INTEGER, | ||
"filetype" TEXT | ||
); | ||
|
||
-- RedefineTables | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_ReviewStorage" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"profile_id" TEXT NOT NULL DEFAULT '', | ||
"RequestMessage" TEXT, | ||
"RequestUser" TEXT NOT NULL, | ||
"mentioned" TEXT NOT NULL DEFAULT '', | ||
"deleted" BOOLEAN NOT NULL DEFAULT false, | ||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" DATETIME NOT NULL, | ||
"fileStorageHash" TEXT NOT NULL, | ||
CONSTRAINT "ReviewStorage_fileStorageHash_fkey" FOREIGN KEY ("fileStorageHash") REFERENCES "FileStorage" ("hash") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
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"; | ||
DROP TABLE "ReviewStorage"; | ||
ALTER TABLE "new_ReviewStorage" RENAME TO "ReviewStorage"; | ||
CREATE UNIQUE INDEX "ReviewStorage_id_key" ON "ReviewStorage"("id"); | ||
PRAGMA foreign_key_check; | ||
PRAGMA foreign_keys=ON; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "FileStorage_hash_key" ON "FileStorage"("hash"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// import { | ||
// ReviewStorage, | ||
// createReviewStorage, | ||
// getReviewStorage, | ||
// updateReviewStorage, | ||
// deleteReviewStorage, | ||
// } from "./review"; | ||
|
||
// describe("Prisma CRUD", () => { | ||
// let testReview: ReviewStorage = { | ||
// id: 1, | ||
// profile_id: "media", | ||
// RequestUser: "18330785221", | ||
// mentioned: "18330785221", | ||
// filename: "Test Filename", | ||
// filesize: 100, | ||
// filetype: "Test Type", | ||
// }; | ||
|
||
// it("creates a review", async () => { | ||
// const review = await createReviewStorage(testReview); | ||
|
||
// expect(review.id).toBeDefined(); | ||
// }); | ||
|
||
// it("gets the created review", async () => { | ||
// const review = await getReviewStorage(testReview.id); | ||
|
||
// if (review) { | ||
// expect(review.profile_id).toBe("media"); | ||
// } else { | ||
// fail("Review is null"); | ||
// } | ||
// }); | ||
|
||
// it("updates the review", async () => { | ||
// await updateReviewStorage(testReview.id, { | ||
// ...testReview, | ||
// profile_id: "", | ||
// // 如果你更新了其他属性,也需要在这里添加 | ||
// }); | ||
|
||
// const review = await getReviewStorage(testReview.id); | ||
// if (review) { | ||
// expect(review.profile_id).toBe("Updated Profile"); | ||
// } else { | ||
// fail("Review is null"); | ||
// } | ||
// }); | ||
|
||
// it("deletes the review", async () => { | ||
// await deleteReviewStorage(testReview.id); | ||
|
||
// try { | ||
// await getReviewStorage(testReview.id); | ||
// fail("Review was not deleted"); | ||
// } catch (error) { | ||
// // Review was deleted | ||
// } | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,70 @@ | ||
import axios, { AxiosProgressEvent, AxiosRequestConfig } from 'axios' | ||
import axios, { AxiosProgressEvent, AxiosRequestConfig } from "axios"; | ||
|
||
const API_ENDPOINT = "http://aidvisor.valmech.net:5000"; | ||
// const API_ENDPOINT = "http://localhost:8000"; | ||
const API_ENDPOINT = "http://aidvisor.valmech.net"; | ||
const api = axios.create({ | ||
baseURL: API_ENDPOINT, | ||
headers: { | ||
'X-API-Key': 'secret_api_key', | ||
} | ||
}) | ||
"X-API-Key": "secret_api_key", | ||
}, | ||
}); | ||
|
||
export const GetOpenAIConnectionTest = async () => { | ||
return await api.post("/api/test/conn/"); | ||
}; | ||
|
||
export interface GetFileReviewResponse { | ||
data: string | ||
data: string; | ||
} | ||
|
||
export const GetFileReview = async (payload: FormData, onProgressUpdate: (p: AxiosProgressEvent) => void) => { | ||
export const GetFileReview = async ( | ||
payload: FormData, | ||
onProgressUpdate: (p: AxiosProgressEvent) => void | ||
) => { | ||
const config: AxiosRequestConfig = { | ||
onUploadProgress: onProgressUpdate | ||
} | ||
onUploadProgress: onProgressUpdate, | ||
}; | ||
// return await api.post('/api/file/review', payload, config) | ||
return await api.post('/api/file/rating', payload, config) | ||
return await api.post("/api/tabs/reports-review/", payload, config); | ||
}; | ||
|
||
interface GetStudyAboardPlanningResponse { | ||
data: { | ||
冲刺院校1: { | ||
学校名称: string; | ||
推荐专业: string; | ||
推荐原因: string; | ||
}; | ||
冲刺院校2: { | ||
学校名称: string; | ||
推荐专业: string; | ||
推荐原因: string; | ||
}; | ||
适中院校1: { | ||
学校名称: string; | ||
推荐专业: string; | ||
推荐原因: string; | ||
}; | ||
适中院校2: { | ||
学校名称: string; | ||
推荐专业: string; | ||
推荐原因: string; | ||
}; | ||
保底院校1: { | ||
学校名称: string; | ||
推荐专业: string; | ||
推荐原因: string; | ||
}; | ||
保底院校2: { | ||
学校名称: string; | ||
推荐专业: string; | ||
推荐原因: string; | ||
}; | ||
}; | ||
} | ||
|
||
export const GetOpenAIConnectionTest = async () => { | ||
return await api.post("/api/conn/test"); | ||
export const GetStudyAboardPlanning = async ( | ||
payload: FormData | ||
): Promise<GetStudyAboardPlanningResponse> => { | ||
return await api.post("/api/tabs/study-aboard-planning/", payload); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.