idz: Add SqlProfileRepository
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
import { ExtId } from "../model/base";
|
||||
import { MissionState } from "../model/mission";
|
||||
import { Profile } from "../model/profile";
|
||||
import { Settings } from "../model/settings";
|
||||
import { Story } from "../model/story";
|
||||
import { Team } from "../model/team";
|
||||
import { Unlocks } from "../model/unlocks";
|
||||
import { CreateProfileRequest } from "../request/createProfile";
|
||||
import { GenericResponse } from "../response/generic";
|
||||
import { Repositories } from "../repo";
|
||||
import { ProfileSpec, Repositories } from "../repo";
|
||||
|
||||
export async function createProfile(
|
||||
w: Repositories,
|
||||
req: CreateProfileRequest
|
||||
): Promise<GenericResponse> {
|
||||
const profileId = await w.profile().generateId();
|
||||
|
||||
const profile: Profile = {
|
||||
id: profileId,
|
||||
const profile: ProfileSpec = {
|
||||
teamId: 2 as ExtId<Team>, // TODO
|
||||
name: req.name,
|
||||
lv: 1,
|
||||
@@ -36,17 +32,16 @@ export async function createProfile(
|
||||
lastMileageReward: 0,
|
||||
};
|
||||
|
||||
await Promise.all([
|
||||
w.profile().save(profile.id, profile),
|
||||
w.chara().save(profile.id, req.chara),
|
||||
w.car().saveCar(profile.id, req.car),
|
||||
w.car().saveSelection(profile.id, req.car.selector),
|
||||
w.missions().save(profile.id, missions),
|
||||
w.settings().save(profile.id, settings),
|
||||
w.story().save(profile.id, story),
|
||||
w.unlocks().save(profile.id, unlocks),
|
||||
w.tickets().save(profile.id, {}),
|
||||
]);
|
||||
const profileId = await w.profile().create(profile);
|
||||
|
||||
await w.chara().save(profileId, req.chara);
|
||||
await w.car().saveCar(profileId, req.car);
|
||||
await w.car().saveSelection(profileId, req.car.selector);
|
||||
await w.missions().save(profileId, missions);
|
||||
await w.settings().save(profileId, settings);
|
||||
await w.story().save(profileId, story);
|
||||
await w.unlocks().save(profileId, unlocks);
|
||||
await w.tickets().save(profileId, {});
|
||||
|
||||
return {
|
||||
type: "generic_res",
|
||||
|
||||
@@ -9,29 +9,29 @@ export async function saveProfile(
|
||||
const profile = await w.profile().load(req.profileId);
|
||||
const chara = await w.chara().load(req.profileId);
|
||||
|
||||
await Promise.all([
|
||||
w.profile().save(req.profileId, {
|
||||
...profile,
|
||||
lv: req.lv,
|
||||
exp: req.exp,
|
||||
fame: req.fame,
|
||||
dpoint: req.dpoint,
|
||||
mileage: req.mileage,
|
||||
}),
|
||||
w.chara().save(req.profileId, {
|
||||
...chara,
|
||||
title: req.title,
|
||||
background: req.background,
|
||||
}),
|
||||
w.car().saveCar(req.profileId, req.car),
|
||||
w.coursePlays().saveAll(req.profileId, req.coursePlays),
|
||||
w.missions().save(req.profileId, req.missions),
|
||||
w.story().save(req.profileId, req.story),
|
||||
w.titles().saveAll(req.profileId, req.titles),
|
||||
w.unlocks().save(req.profileId, req.unlocks),
|
||||
w.settings().save(req.profileId, req.settings),
|
||||
w.tickets().save(req.profileId, req.tickets),
|
||||
]);
|
||||
await w.profile().save({
|
||||
...profile,
|
||||
lv: req.lv,
|
||||
exp: req.exp,
|
||||
fame: req.fame,
|
||||
dpoint: req.dpoint,
|
||||
mileage: req.mileage,
|
||||
});
|
||||
|
||||
await w.chara().save(req.profileId, {
|
||||
...chara,
|
||||
title: req.title,
|
||||
background: req.background,
|
||||
});
|
||||
|
||||
await w.car().saveCar(req.profileId, req.car);
|
||||
await w.coursePlays().saveAll(req.profileId, req.coursePlays);
|
||||
await w.missions().save(req.profileId, req.missions);
|
||||
await w.story().save(req.profileId, req.story);
|
||||
await w.titles().saveAll(req.profileId, req.titles);
|
||||
await w.unlocks().save(req.profileId, req.unlocks);
|
||||
await w.settings().save(req.profileId, req.settings);
|
||||
await w.tickets().save(req.profileId, req.tickets);
|
||||
|
||||
return {
|
||||
type: "generic_res",
|
||||
|
||||
Reference in New Issue
Block a user