chore: remove handleSetPlacedDecoInfo

This commit is contained in:
Sainan 2025-01-11 08:22:40 +01:00
parent 19cab1805d
commit 1b6c7bb59f
3 changed files with 26 additions and 31 deletions

View File

@ -1,11 +1,34 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { ISetPlacedDecoInfoRequest } from "@/src/types/shipTypes";
import { RequestHandler } from "express";
import { handleSetPlacedDecoInfo } from "@/src/services/shipCustomizationsService";
import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { IPictureFrameInfo } from "@/src/types/shipTypes";
export const setPlacedDecoInfoController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const personalRooms = await getPersonalRooms(accountId);
const payload = JSON.parse(req.body as string) as ISetPlacedDecoInfoRequest;
await handleSetPlacedDecoInfo(accountId, payload);
const room = personalRooms.Ship.Rooms.find(room => room.Name === payload.Room);
if (!room) {
throw new Error("room not found");
}
const placedDeco = room.PlacedDecos?.find(x => x._id.toString() == payload.DecoId);
if (!placedDeco) {
throw new Error("deco not found");
}
placedDeco.PictureFrameInfo = payload.PictureFrameInfo;
await personalRooms.save();
res.end();
};
interface ISetPlacedDecoInfoRequest {
DecoType: string;
DecoId: string;
Room: string;
PictureFrameInfo: IPictureFrameInfo;
BootLocation: string;
}

View File

@ -1,20 +0,0 @@
import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { ISetPlacedDecoInfoRequest } from "@/src/types/shipTypes";
export const handleSetPlacedDecoInfo = async (accountId: string, req: ISetPlacedDecoInfoRequest): Promise<void> => {
const personalRooms = await getPersonalRooms(accountId);
const room = personalRooms.Ship.Rooms.find(room => room.Name === req.Room);
if (!room) {
throw new Error("room not found");
}
const placedDeco = room.PlacedDecos?.find(x => x._id.toString() == req.DecoId);
if (!placedDeco) {
throw new Error("deco not found");
}
placedDeco.PictureFrameInfo = req.PictureFrameInfo;
await personalRooms.save();
};

View File

@ -90,14 +90,6 @@ export interface ShipAttachments {
HOOD_ORNAMENT: string;
}
export interface ISetPlacedDecoInfoRequest {
DecoType: string;
DecoId: string;
Room: string;
PictureFrameInfo: IPictureFrameInfo;
BootLocation: string;
}
export interface IPictureFrameInfo {
Image: string;
Filter: string;