chuni: implement UserCharge APIs, add table for purchased tickets
This commit is contained in:
committed by
Tau
parent
a8539b475e
commit
6c22c4287e
@@ -1,3 +1,5 @@
|
||||
import { readAimeId } from "../proto/base";
|
||||
import { writeUserCharge } from "../proto/userCharge";
|
||||
import { Repositories } from "../repo";
|
||||
import { GetUserChargeRequest } from "../request/getUserCharge";
|
||||
import { GetUserChargeResponse } from "../response/getUserCharge";
|
||||
@@ -6,9 +8,14 @@ export default async function getUserCharge(
|
||||
rep: Repositories,
|
||||
req: GetUserChargeRequest
|
||||
): Promise<GetUserChargeResponse> {
|
||||
const aimeId = readAimeId(req.userId);
|
||||
|
||||
const profileId = await rep.userData().lookup(aimeId);
|
||||
const items = await rep.userCharge().load(profileId);
|
||||
|
||||
return {
|
||||
userId: req.userId,
|
||||
length: "0",
|
||||
userChargeList: [],
|
||||
length: items.length.toString(),
|
||||
userChargeList: items.map(writeUserCharge),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import upsertClientError from "./upsertClientError";
|
||||
import upsertClientSetting from "./upsertClientSetting";
|
||||
import upsertClientTestmode from "./upsertClientTestmode";
|
||||
import upsertUserAll from "./upsertUserAll";
|
||||
import upsertUserChargelogApi from "./upsertUserChargelogApi";
|
||||
import createSqlWrapper from "../sql";
|
||||
import { DataSource } from "../../sql";
|
||||
|
||||
@@ -113,6 +114,7 @@ export default function chunithm(db: DataSource) {
|
||||
wrapper.rpc("/UpsertClientSettingApi", upsertClientSetting);
|
||||
wrapper.rpc("/UpsertClientTestmodeApi", upsertClientTestmode);
|
||||
wrapper.rpc("/UpsertUserAllApi", upsertUserAll);
|
||||
wrapper.rpc("/UpsertUserChargelogApi", upsertUserChargelogApi)
|
||||
|
||||
const app = express();
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { readUserActivity } from "../proto/userActivity";
|
||||
import { readUserDataEx } from "../proto/userDataEx";
|
||||
import { readUserDuelList } from "../proto/userDuelList";
|
||||
import { readUserPlaylog } from "../proto/userPlaylog";
|
||||
import { readUserCharge } from "../proto/userCharge";
|
||||
import { readUserCourse } from "../proto/userCourse";
|
||||
|
||||
// It shouldn't need to be said really, but seeing as this message (A) requires
|
||||
@@ -67,6 +68,10 @@ export default async function upsertUserAll(
|
||||
await rep.userPlaylog().save(profileId, readUserPlaylog(item));
|
||||
}
|
||||
|
||||
for (const item of payload.userChargeList || []) {
|
||||
await rep.userCharge().save(profileId, readUserCharge(item));
|
||||
}
|
||||
|
||||
for (const item of payload.userCourseList || []) {
|
||||
await rep.userCourse().save(profileId, readUserCourse(item));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Repositories } from "../repo";
|
||||
import { UpsertUserChargelogApiRequest } from "../request/upsertUserChargelogApi";
|
||||
import { UpsertUserChargelogApiResponse } from "../response/upsertUserChargelogApi";
|
||||
|
||||
export default async function UpsertUserChargelogApi(
|
||||
rep: Repositories,
|
||||
req: UpsertUserChargelogApiRequest
|
||||
): Promise<UpsertUserChargelogApiResponse> {
|
||||
return {
|
||||
returnCode: "1",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user