chore: remove handleSetPlacedDecoInfo
This commit is contained in:
parent
19cab1805d
commit
1b6c7bb59f
@ -1,11 +1,34 @@
|
|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { ISetPlacedDecoInfoRequest } from "@/src/types/shipTypes";
|
|
||||||
import { RequestHandler } from "express";
|
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) => {
|
export const setPlacedDecoInfoController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const personalRooms = await getPersonalRooms(accountId);
|
||||||
const payload = JSON.parse(req.body as string) as ISetPlacedDecoInfoRequest;
|
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();
|
res.end();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface ISetPlacedDecoInfoRequest {
|
||||||
|
DecoType: string;
|
||||||
|
DecoId: string;
|
||||||
|
Room: string;
|
||||||
|
PictureFrameInfo: IPictureFrameInfo;
|
||||||
|
BootLocation: string;
|
||||||
|
}
|
||||||
|
@ -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();
|
|
||||||
};
|
|
@ -90,14 +90,6 @@ export interface ShipAttachments {
|
|||||||
HOOD_ORNAMENT: string;
|
HOOD_ORNAMENT: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISetPlacedDecoInfoRequest {
|
|
||||||
DecoType: string;
|
|
||||||
DecoId: string;
|
|
||||||
Room: string;
|
|
||||||
PictureFrameInfo: IPictureFrameInfo;
|
|
||||||
BootLocation: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPictureFrameInfo {
|
export interface IPictureFrameInfo {
|
||||||
Image: string;
|
Image: string;
|
||||||
Filter: string;
|
Filter: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user