Skip to content

Commit 641f955

Browse files
2.0.0 breaking change: student profile支持传入studentNumber
1 parent 4ed6964 commit 641f955

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ccw-api/api",
3-
"version": "1.0.6",
3+
"version": "2.0.0",
44
"description": "ccw api collections",
55
"license": "MIT",
66
"author": "Meng Fuzi",

src/community-web/students/profile.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ import assert from "node:assert/strict";
55
const STUDENT_OID = "63c2807d669fa967f17f5559";
66

77
test("get student profile", async () => {
8-
const profile = await getStudentProfile(STUDENT_OID);
9-
assert.strictEqual(profile.studentOid, (STUDENT_OID), "expected values to be strictly equal");
8+
const profile = await getStudentProfile({ studentOid: STUDENT_OID });
9+
assert.strictEqual(
10+
profile.studentOid,
11+
STUDENT_OID,
12+
"expected values to be strictly equal",
13+
);
14+
const profile2 = await getStudentProfile({
15+
studentNumber: profile.studentNumber,
16+
});
17+
assert.strictEqual(
18+
profile2.studentOid,
19+
STUDENT_OID,
20+
"expected values to be strictly equal",
21+
);
1022
});

src/community-web/students/profile.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { StudentProfile } from "src/types/userData";
55
export const url = "https://community-web.ccw.site/students/profile";
66

77
export type Req = {
8-
studentOid: MongoDBId;
8+
studentNumber?: string;
9+
studentOid?: MongoDBId;
910
};
1011

1112
export type Res = StudentProfile;
@@ -15,8 +16,14 @@ export type Res = StudentProfile;
1516
* @param {MongoDBId} studentOid 学生id
1617
* @returns {Promise<Res>} 学生资料
1718
*/
18-
export async function getStudentProfile(studentOid: MongoDBId): Promise<Res> {
19-
const req: Req = { studentOid };
19+
export async function getStudentProfile({
20+
studentOid,
21+
studentNumber,
22+
}: {
23+
studentNumber?: string;
24+
studentOid?: MongoDBId;
25+
}): Promise<Res> {
26+
const req: Req = { studentOid, studentNumber };
2027
return await request
2128
.post<ApiResponse<Res>>(url, req)
2229
.then((res) => res.data.body);

0 commit comments

Comments
 (0)