unlockShipFeature

This commit is contained in:
Master 2024-06-25 13:52:13 +08:00
parent 3370dc10e1
commit a9cf95242c
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { RequestHandler } from "express";
import { unlockShipFeature } from "@/src/services/personalRoomsService";
import { parseString } from "@/src/helpers/general";
export interface IUnlockShipFeatureRequest {
Feature: string;
KeyChain: string;
ChainStage: number;
}
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const unlockShipFeatureController: RequestHandler = async (req, res) => {
const accountId = parseString(req.query.accountId);
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
const shipFeatureRequest = JSON.parse(req.body as string) as IUnlockShipFeatureRequest;
await unlockShipFeature(accountId, shipFeatureRequest.Feature);
res.send([]);
};

View File

@ -10,3 +10,10 @@ export const getPersonalRooms = async (accountId: string) => {
} }
return personalRooms; return personalRooms;
}; };
export const unlockShipFeature = async (accountId: string, shipFeature: string) => {
const personalRooms = await getPersonalRooms(accountId);
if (!personalRooms.Ship.Features.includes(shipFeature)) personalRooms.Ship.Features.push(shipFeature);
await personalRooms.save();
};