2025-05-29 09:24:16 +05:30
|
|
|
import { Mixed } from "mongoose";
|
|
|
|
|
import assetModel from "../../V1Models/Builder/assetModel.ts";
|
|
|
|
|
import EventsDataModel from "../../V1Models/Simulation/eventsDataModel.ts";
|
2025-05-29 15:34:12 +05:30
|
|
|
import {
|
|
|
|
|
existingProjectById,
|
|
|
|
|
existingUser,
|
|
|
|
|
} from "../helpers/v1projecthelperFns.ts";
|
2025-05-29 09:24:16 +05:30
|
|
|
|
|
|
|
|
interface setAssetInput {
|
2025-05-29 15:34:12 +05:30
|
|
|
modelUuid: string;
|
|
|
|
|
modelName: string;
|
|
|
|
|
position: []; // user ID
|
|
|
|
|
rotation: object;
|
|
|
|
|
eventData: Mixed;
|
|
|
|
|
modelfileID: string;
|
|
|
|
|
isLocked: boolean;
|
|
|
|
|
isVisible: boolean;
|
|
|
|
|
organization: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
userId: string;
|
|
|
|
|
}
|
|
|
|
|
interface AssetUpdate {
|
|
|
|
|
modelUuid: string;
|
|
|
|
|
modelName: string;
|
|
|
|
|
position: []; // user ID
|
|
|
|
|
rotation: object;
|
|
|
|
|
isLocked: boolean;
|
|
|
|
|
isVisible: boolean;
|
|
|
|
|
organization: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
userId: string;
|
|
|
|
|
}
|
|
|
|
|
interface DelAssetInput {
|
|
|
|
|
modelUuid: string;
|
|
|
|
|
modelName: string;
|
|
|
|
|
organization: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
userId: string;
|
|
|
|
|
}
|
|
|
|
|
interface GetAssetInput {
|
|
|
|
|
organization: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
userId: string;
|
|
|
|
|
}
|
|
|
|
|
interface ReplaceEventInput {
|
|
|
|
|
organization: string;
|
|
|
|
|
projectId: string;
|
|
|
|
|
userId: string;
|
|
|
|
|
eventData: Mixed;
|
|
|
|
|
modelUuid: string;
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
|
|
|
|
export const setAssetModel = async (
|
2025-05-29 15:34:12 +05:30
|
|
|
data: setAssetInput
|
2025-05-29 09:24:16 +05:30
|
|
|
): Promise<{ status: string; data?: Object }> => {
|
2025-05-29 15:34:12 +05:30
|
|
|
try {
|
|
|
|
|
const {
|
|
|
|
|
modelUuid,
|
|
|
|
|
modelName,
|
|
|
|
|
position,
|
|
|
|
|
rotation,
|
|
|
|
|
eventData,
|
|
|
|
|
modelfileID,
|
|
|
|
|
isLocked,
|
|
|
|
|
isVisible,
|
|
|
|
|
organization,
|
|
|
|
|
projectId,
|
|
|
|
|
userId,
|
|
|
|
|
} = data;
|
|
|
|
|
const UserExists = await existingUser(userId, organization);
|
|
|
|
|
if (!UserExists) return { status: "User not found" };
|
|
|
|
|
const LivingProject = await existingProjectById(
|
|
|
|
|
projectId,
|
|
|
|
|
organization,
|
|
|
|
|
userId
|
|
|
|
|
);
|
|
|
|
|
if (!LivingProject) return { status: "Project not found" };
|
|
|
|
|
const findvalue = await assetModel(organization).findOne({
|
|
|
|
|
modelUuid: modelUuid,
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
userId: userId,
|
|
|
|
|
isArchive: false,
|
|
|
|
|
});
|
|
|
|
|
if (findvalue) {
|
|
|
|
|
const updatevalue = await assetModel(organization).findOneAndUpdate(
|
|
|
|
|
{
|
|
|
|
|
modelUuid: modelUuid,
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
userId: userId,
|
|
|
|
|
isArchive: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
modelName: modelName,
|
|
|
|
|
position: position,
|
|
|
|
|
rotation: rotation,
|
|
|
|
|
isVisible: isVisible,
|
|
|
|
|
isLocked: isLocked,
|
|
|
|
|
eventData: eventData,
|
|
|
|
|
},
|
|
|
|
|
{ new: true }
|
|
|
|
|
);
|
|
|
|
|
// return {
|
|
|
|
|
// success: true,
|
|
|
|
|
// message: "Model updated successfully",
|
|
|
|
|
// data: updatevalue,
|
|
|
|
|
// organization: organization,
|
|
|
|
|
// };
|
|
|
|
|
return {
|
|
|
|
|
status: "Updated successfully",
|
|
|
|
|
data: updatevalue,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
let assetData: any = {
|
|
|
|
|
projectId,
|
|
|
|
|
userId,
|
|
|
|
|
modelUuid,
|
|
|
|
|
modelName,
|
|
|
|
|
position,
|
|
|
|
|
modelfileID,
|
|
|
|
|
rotation,
|
|
|
|
|
isLocked,
|
|
|
|
|
isVisible,
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
// if (eventData) {
|
|
|
|
|
// if (eventData?.type === "Conveyor") {
|
|
|
|
|
// assetData.eventData = {
|
|
|
|
|
// type: eventData.type,
|
|
|
|
|
// // point:undefined,
|
|
|
|
|
// points: eventData.points,
|
|
|
|
|
// };
|
|
|
|
|
// } else {
|
|
|
|
|
// assetData.eventData = {
|
|
|
|
|
// type: eventData.type,
|
|
|
|
|
// point: eventData.point,
|
|
|
|
|
// // points: undefined
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (eventData) {
|
|
|
|
|
const typedEventData = eventData as unknown as {
|
|
|
|
|
type: string;
|
|
|
|
|
point?: any;
|
|
|
|
|
points?: any[];
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
if (typedEventData.type === "Conveyor") {
|
|
|
|
|
assetData.eventData = {
|
|
|
|
|
type: typedEventData.type,
|
|
|
|
|
points: typedEventData.points,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
assetData.eventData = {
|
|
|
|
|
type: typedEventData.type,
|
|
|
|
|
point: typedEventData.point,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
if (eventData) {
|
|
|
|
|
const typedEventData = eventData as unknown as {
|
|
|
|
|
type: string;
|
|
|
|
|
point?: any;
|
|
|
|
|
points?: any[];
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
if (typedEventData.type === "Conveyor") {
|
|
|
|
|
assetData.eventData = {
|
|
|
|
|
type: typedEventData.type,
|
|
|
|
|
points: typedEventData.points,
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
} else {
|
2025-05-29 15:34:12 +05:30
|
|
|
assetData.eventData = {
|
|
|
|
|
type: typedEventData.type,
|
|
|
|
|
point: typedEventData.point,
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
2025-05-29 15:34:12 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const assetDoc = await assetModel(organization).create(assetData);
|
|
|
|
|
await assetDoc.save();
|
|
|
|
|
let assetDatas;
|
|
|
|
|
const typedEventData = eventData as unknown as { type: string };
|
|
|
|
|
if (typedEventData && typedEventData.type === "Conveyor") {
|
|
|
|
|
assetDatas = {
|
|
|
|
|
projectId: assetDoc.projectId,
|
|
|
|
|
userId: assetDoc.userId,
|
|
|
|
|
modelUuid: assetDoc.modelUuid,
|
|
|
|
|
modelName: assetDoc.modelName,
|
|
|
|
|
modelfileID: assetDoc.modelfileID,
|
|
|
|
|
position: assetDoc.position,
|
|
|
|
|
rotation: assetDoc.rotation,
|
|
|
|
|
isLocked: assetDoc.isLocked,
|
|
|
|
|
isVisible: assetDoc.isVisible,
|
|
|
|
|
eventData: eventData,
|
|
|
|
|
};
|
|
|
|
|
} else if (eventData && assetDoc.type === "Vehicle") {
|
|
|
|
|
assetDatas = {
|
|
|
|
|
projectId: assetDoc.projectId,
|
|
|
|
|
userId: assetDoc.userId,
|
|
|
|
|
modelUuid: assetDoc.modelUuid,
|
|
|
|
|
modelName: assetDoc.modelName,
|
|
|
|
|
modelfileID: assetDoc.modelfileID,
|
|
|
|
|
position: assetDoc.position,
|
|
|
|
|
rotation: assetDoc.rotation,
|
|
|
|
|
isLocked: assetDoc.isLocked,
|
|
|
|
|
isVisible: assetDoc.isVisible,
|
|
|
|
|
eventData: {
|
|
|
|
|
points: assetDoc.points,
|
|
|
|
|
type: assetDoc.type,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
} else if (eventData && assetDoc.type === "ArmBot") {
|
|
|
|
|
assetDatas = {
|
|
|
|
|
projectId: assetDoc.projectId,
|
|
|
|
|
userId: assetDoc.userId,
|
|
|
|
|
modelUuid: assetDoc.modelUuid,
|
|
|
|
|
modelName: assetDoc.modelName,
|
|
|
|
|
modelfileID: assetDoc.modelfileID,
|
|
|
|
|
position: assetDoc.position,
|
|
|
|
|
rotation: assetDoc.rotation,
|
|
|
|
|
isLocked: assetDoc.isLocked,
|
|
|
|
|
isVisible: assetDoc.isVisible,
|
|
|
|
|
eventData: {
|
|
|
|
|
points: assetDoc.points,
|
|
|
|
|
type: assetDoc.type,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
} else if (eventData && assetDoc.type === "StaticMachine") {
|
|
|
|
|
assetDatas = {
|
|
|
|
|
projectId: assetDoc.projectId,
|
|
|
|
|
userId: assetDoc.userId,
|
|
|
|
|
modelUuid: assetDoc.modelUuid,
|
|
|
|
|
modelName: assetDoc.modelName,
|
|
|
|
|
modelfileID: assetDoc.modelfileID,
|
|
|
|
|
position: assetDoc.position,
|
|
|
|
|
rotation: assetDoc.rotation,
|
|
|
|
|
isLocked: assetDoc.isLocked,
|
|
|
|
|
isVisible: assetDoc.isVisible,
|
|
|
|
|
eventData: {
|
|
|
|
|
points: assetDoc.points,
|
|
|
|
|
type: assetDoc.type,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
assetDatas = {
|
|
|
|
|
projectId: assetDoc.projectId,
|
|
|
|
|
userId: assetDoc.userId,
|
|
|
|
|
modelUuid: assetDoc.modelUuid,
|
|
|
|
|
modelName: assetDoc.modelName,
|
|
|
|
|
modelfileID: assetDoc.modelfileID,
|
|
|
|
|
position: assetDoc.position,
|
|
|
|
|
rotation: assetDoc.rotation,
|
|
|
|
|
isLocked: assetDoc.isLocked,
|
|
|
|
|
isVisible: assetDoc.isVisible,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// return {
|
|
|
|
|
// success: true,
|
|
|
|
|
// message: "Model created successfully",
|
|
|
|
|
// data: assetDatas,
|
|
|
|
|
// organization: organization,
|
|
|
|
|
// };
|
|
|
|
|
return {
|
|
|
|
|
status: "Success",
|
|
|
|
|
data: assetDatas,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
} catch (error: unknown) {
|
|
|
|
|
if (error instanceof Error) {
|
|
|
|
|
return {
|
|
|
|
|
status: error.message,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
status: "An unexpected error occurred",
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
2025-05-29 15:34:12 +05:30
|
|
|
}
|
2025-05-29 09:24:16 +05:30
|
|
|
};
|
|
|
|
|
export const deleteAssetModel = async (
|
2025-05-29 15:34:12 +05:30
|
|
|
data: DelAssetInput
|
2025-05-29 09:24:16 +05:30
|
|
|
): Promise<{ status: string; data?: Object }> => {
|
2025-05-29 15:34:12 +05:30
|
|
|
try {
|
|
|
|
|
const { modelUuid, modelName, organization, projectId, userId } = data;
|
|
|
|
|
const UserExists = await existingUser(userId, organization);
|
|
|
|
|
if (!UserExists) return { status: "User not found" };
|
|
|
|
|
const LivingProject = await existingProjectById(
|
|
|
|
|
projectId,
|
|
|
|
|
organization,
|
|
|
|
|
userId
|
|
|
|
|
);
|
|
|
|
|
if (!LivingProject) return { status: "Project not found" };
|
|
|
|
|
const asset = await assetModel(organization).findOne({
|
|
|
|
|
modelUuid,
|
|
|
|
|
modelName,
|
|
|
|
|
projectId,
|
|
|
|
|
isArchive: false,
|
|
|
|
|
});
|
|
|
|
|
if (!asset) {
|
|
|
|
|
return {
|
|
|
|
|
status: "model not found",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const archivedAsset = await assetModel(organization).findOneAndUpdate(
|
|
|
|
|
{ modelUuid, modelName, projectId },
|
|
|
|
|
{ $set: { isArchive: true } },
|
|
|
|
|
{ new: true }
|
|
|
|
|
);
|
|
|
|
|
if (!archivedAsset) {
|
|
|
|
|
// return {
|
|
|
|
|
// success: false,
|
|
|
|
|
// status: "Failed to archive asset",
|
|
|
|
|
// organization: organization,
|
|
|
|
|
// };
|
|
|
|
|
return {
|
|
|
|
|
status: "Failed to archive asset",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
const updatedEvents = await EventsDataModel(organization).updateMany(
|
|
|
|
|
{ modelUuid, productId: projectId },
|
|
|
|
|
{ $set: { isArchive: true } }
|
|
|
|
|
);
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
// return {
|
|
|
|
|
// success: true,
|
|
|
|
|
// message: "Model deleted successfully",
|
|
|
|
|
// data: archivedAsset,
|
|
|
|
|
// organization: organization,
|
|
|
|
|
// };
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
return {
|
|
|
|
|
status: "Success",
|
|
|
|
|
data: archivedAsset,
|
|
|
|
|
};
|
|
|
|
|
} catch (error: unknown) {
|
|
|
|
|
if (error instanceof Error) {
|
|
|
|
|
return {
|
|
|
|
|
status: error.message,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
status: "An unexpected error occurred",
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
2025-05-29 15:34:12 +05:30
|
|
|
}
|
2025-05-29 09:24:16 +05:30
|
|
|
};
|
|
|
|
|
export const replaceEventDatas = async (
|
2025-05-29 15:34:12 +05:30
|
|
|
data: ReplaceEventInput
|
2025-05-29 09:24:16 +05:30
|
|
|
): Promise<{ status: string; data?: Object }> => {
|
2025-05-29 15:34:12 +05:30
|
|
|
try {
|
|
|
|
|
const { modelUuid, organization, eventData, projectId, userId } = data;
|
|
|
|
|
const UserExists = await existingUser(userId, organization);
|
|
|
|
|
if (!UserExists) return { status: "User not found" };
|
|
|
|
|
const LivingProject = await existingProjectById(
|
|
|
|
|
projectId,
|
|
|
|
|
organization,
|
|
|
|
|
userId
|
|
|
|
|
);
|
|
|
|
|
if (!LivingProject) return { status: "Project not found" };
|
|
|
|
|
const existingModel = await assetModel(organization).findOne({
|
|
|
|
|
modelUuid: modelUuid,
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
isArchive: false,
|
|
|
|
|
});
|
|
|
|
|
if (!existingModel) {
|
|
|
|
|
return { status: "Model not for this UUID" };
|
|
|
|
|
// return {
|
|
|
|
|
// success: false,
|
|
|
|
|
// message: "Model not for this UUID",
|
|
|
|
|
// organization: organization,
|
|
|
|
|
// };
|
|
|
|
|
} else {
|
|
|
|
|
const typedEventData = eventData as unknown as {
|
|
|
|
|
speed: number;
|
|
|
|
|
points?: any[];
|
|
|
|
|
type?: string;
|
|
|
|
|
};
|
|
|
|
|
let speed;
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
if (existingModel.type === "Conveyor") {
|
|
|
|
|
speed = typedEventData?.speed;
|
|
|
|
|
}
|
|
|
|
|
const updatedModel = await assetModel(organization).findOneAndUpdate(
|
|
|
|
|
{ modelUuid, projectId, isArchive: false },
|
|
|
|
|
{
|
|
|
|
|
points: typedEventData?.points,
|
|
|
|
|
// speed: speed,
|
|
|
|
|
type: typedEventData?.type || existingModel?.type,
|
|
|
|
|
},
|
|
|
|
|
{ new: true }
|
|
|
|
|
);
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
// if (updatedModel)
|
|
|
|
|
// // return {
|
|
|
|
|
// // success: true,
|
|
|
|
|
// // message: "Data updated successfully",
|
|
|
|
|
// // data: updatedModel,
|
|
|
|
|
// // organization: organization,
|
|
|
|
|
// // };
|
|
|
|
|
// return {
|
|
|
|
|
// status: "Success",
|
|
|
|
|
// data: updatedModel,
|
|
|
|
|
// };
|
|
|
|
|
return {
|
|
|
|
|
status: "Success",
|
|
|
|
|
data: updatedModel,
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
2025-05-29 15:34:12 +05:30
|
|
|
} catch (error: unknown) {
|
|
|
|
|
if (error instanceof Error) {
|
|
|
|
|
return {
|
|
|
|
|
status: error.message,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
status: "An unexpected error occurred",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-29 09:24:16 +05:30
|
|
|
};
|
|
|
|
|
export const updateAssetPositionRotation = async (
|
2025-05-29 15:34:12 +05:30
|
|
|
data: AssetUpdate
|
2025-05-29 09:24:16 +05:30
|
|
|
): Promise<{ status: string; data?: Object }> => {
|
2025-05-29 15:34:12 +05:30
|
|
|
try {
|
|
|
|
|
const {
|
|
|
|
|
modelUuid,
|
|
|
|
|
modelName,
|
|
|
|
|
position,
|
|
|
|
|
rotation,
|
|
|
|
|
isLocked,
|
|
|
|
|
isVisible,
|
|
|
|
|
organization,
|
|
|
|
|
projectId,
|
|
|
|
|
userId,
|
|
|
|
|
} = data;
|
|
|
|
|
const UserExists = await existingUser(userId, organization);
|
|
|
|
|
if (!UserExists) return { status: "User not found" };
|
|
|
|
|
const LivingProject = await existingProjectById(
|
|
|
|
|
projectId,
|
|
|
|
|
organization,
|
|
|
|
|
userId
|
|
|
|
|
);
|
|
|
|
|
if (!LivingProject) return { status: "Project not found" };
|
|
|
|
|
const existingAsset = await assetModel(organization).findOne({
|
|
|
|
|
modelUuid: modelUuid,
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
isArchive: false,
|
|
|
|
|
});
|
|
|
|
|
if (!existingAsset) {
|
|
|
|
|
return { status: "Asset not found" };
|
|
|
|
|
// return res.send("Asset not found");
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
2025-05-29 15:34:12 +05:30
|
|
|
const updateAsset = await assetModel(organization).updateMany(
|
|
|
|
|
{
|
|
|
|
|
modelUuid: modelUuid,
|
|
|
|
|
projectId: projectId,
|
|
|
|
|
modelName: modelName,
|
|
|
|
|
isArchive: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
position: position,
|
|
|
|
|
rotation: rotation,
|
|
|
|
|
isVisible: isVisible,
|
|
|
|
|
isLocked: isLocked,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
// if (updateAsset)
|
|
|
|
|
return {
|
|
|
|
|
status: "Success",
|
|
|
|
|
data: updateAsset,
|
|
|
|
|
};
|
|
|
|
|
// return res.status(200).json({ message: "Asset updated successfully" });
|
|
|
|
|
} catch (error: unknown) {
|
|
|
|
|
if (error instanceof Error) {
|
|
|
|
|
return {
|
|
|
|
|
status: error.message,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
status: "An unexpected error occurred",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-29 09:24:16 +05:30
|
|
|
};
|
|
|
|
|
export const getFloorItems = async (
|
2025-05-29 15:34:12 +05:30
|
|
|
data: GetAssetInput
|
2025-05-29 09:24:16 +05:30
|
|
|
): Promise<{ status: string; data?: Object }> => {
|
2025-05-29 15:34:12 +05:30
|
|
|
try {
|
|
|
|
|
const { organization, projectId, userId } = data;
|
|
|
|
|
const UserExists = await existingUser(userId, organization);
|
|
|
|
|
if (!UserExists) return { status: "User not found" };
|
|
|
|
|
const LivingProject = await existingProjectById(
|
|
|
|
|
projectId,
|
|
|
|
|
organization,
|
|
|
|
|
userId
|
|
|
|
|
);
|
|
|
|
|
if (!LivingProject) return { status: "Project not found" };
|
|
|
|
|
const findValues = await assetModel(organization)
|
|
|
|
|
.find({ isArchive: false })
|
|
|
|
|
.select("-_id -isArchive");
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
if (!findValues || findValues.length === 0) {
|
|
|
|
|
return { status: "floorItems not found" };
|
|
|
|
|
// return res.status(200).json({ message: "floorItems not found" });
|
|
|
|
|
}
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
const response = findValues.map((item) => {
|
|
|
|
|
const responseItem: any = {
|
|
|
|
|
projectId: item.productId,
|
|
|
|
|
modelUuid: item.modelUuid,
|
|
|
|
|
modelName: item.modelName,
|
|
|
|
|
position: item.position,
|
|
|
|
|
rotation: item.rotation,
|
|
|
|
|
modelfileID: item.modelfileID,
|
|
|
|
|
isLocked: item.isLocked,
|
|
|
|
|
isVisible: item.isVisible,
|
|
|
|
|
eventData: item.eventData,
|
|
|
|
|
};
|
|
|
|
|
return responseItem;
|
|
|
|
|
});
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
// return res.status(200).json(response);
|
2025-05-29 09:24:16 +05:30
|
|
|
|
2025-05-29 15:34:12 +05:30
|
|
|
return {
|
|
|
|
|
status: "Success",
|
|
|
|
|
data: response,
|
|
|
|
|
};
|
|
|
|
|
} catch (error: unknown) {
|
|
|
|
|
if (error instanceof Error) {
|
|
|
|
|
return {
|
|
|
|
|
status: error.message,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
status: "An unexpected error occurred",
|
|
|
|
|
};
|
2025-05-29 09:24:16 +05:30
|
|
|
}
|
2025-05-29 15:34:12 +05:30
|
|
|
}
|
|
|
|
|
};
|