V1 for the builder processing

This commit is contained in:
2025-05-27 12:19:15 +05:30
parent 9b4f8c0841
commit 7603c1b64a
27 changed files with 836 additions and 261 deletions

View File

@@ -0,0 +1,117 @@
import { Request, Response } from "express";
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
interface IWallSetupData {
modelUuid: string;
modelName: string;
type: string;
csgposition: [];
csgscale: [];
position: [];
quaternion: [];
scale: [];
organization: string;
projectId: string;
}
interface IWallItemResult {
data: {};
state: string;
}
export class WallItems {
static async setWallItems(data: IWallSetupData): Promise<IWallItemResult> {
try {
const {
modelUuid,
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
projectId,
organization,
} = data;
const findvalue = await wallItemModel(organization).findOne({
modelUuid: modelUuid,
});
if (findvalue) {
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
{ modelUuid: modelUuid, projectId: projectId },
{
modelName,
position,
type,
csgposition,
csgscale,
quaternion,
scale,
},
{ new: true } // Return the updated document
);
return {
state: "Updated successfully",
data: updatevalue,
};
// res.status(201).json(updatevalue);
} else {
const newValue = await wallItemModel(organization).create({
modelUuid,
modelName,
position,
type,
projectId,
csgposition,
csgscale,
quaternion,
scale,
});
return {
state: "wall Item created successfully",
data: newValue,
};
// res.status(201).json(newValue);
}
} catch (error: unknown) {
const err = error as Error;
console.error("Error creating wallitems:", error);
return {
state: "Failed to create wallitems",
data: { message: err.message },
};
}
}
static async getWallItems(req: Request, res: Response) {
try {
const { organization } = req.params;
const findValue = await wallItemModel(organization).find();
if (!findValue) {
res.status(200).json("wallitems not found");
} else {
res.status(201).json(findValue);
}
} catch (error) {
console.error("Error get wallitems:", error);
res.status(500).json({ error: "Failed to get wallitems" });
}
}
static async deleteWallItems(req: Request, res: Response) {
try {
const { modelUuid, modelName, organization } = req.body;
const findValue = await wallItemModel(organization).findOneAndDelete({
modelUuid: modelUuid,
modelName: modelName,
});
if (!findValue) {
res.status(200).json("user not found");
} else {
res.status(201).json(findValue);
}
} catch (error) {
console.error("Error get wallitems:", error);
res.status(500).json({ error: "Failed to get wallitems" });
}
}
}

View File

@@ -103,9 +103,9 @@ export const GetAllProjects = async (data: GetProjectsInterface) => {
await existingUser(userId, organization);
if (!existingUser) return { status: "User not found" };
let filter = { isArchive: false } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const projectDatas = await projectModel(organization)
.find(filter)
.select("_id projectName createdBy thumbnail createdAt projectUuid");
@@ -121,9 +121,9 @@ export const DeleteProject = async (data: ProjectInterface) => {
const ExistingUser = await existingUser(userId, organization);
if (!ExistingUser) return { status: "User not found" };
let filter = { _id: projectId, isArchive: false } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const existingProject = await projectModel(organization).findOne(filter);
if (!existingProject) return { status: "Project not found" };
const updateProject = await projectModel(organization).findOneAndUpdate(
@@ -143,9 +143,9 @@ export const updateProject = async (data: updateProjectInput) => {
const ExistingUser = await existingUser(userId, organization);
if (!ExistingUser) return { status: "User not found" };
let filter = { _id: projectId, isArchive: false } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const existingProject = await projectModel(organization).findOne(filter);
if (!existingProject) return { status: "Project not found" };
if (projectName !== undefined) projectName;
@@ -173,9 +173,9 @@ export const viewProject = async (data: ProjectInterface) => {
isArchive: false,
});
let filter = { _id: projectId, isArchive: false } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const existingProject = await projectModel(organization).findOne(filter);
if (!existingProject) return { status: "Project not found" };
const newArr = RecentUserDoc?.recentlyViewed || [];

View File

@@ -38,9 +38,9 @@ export const RecentlyAdded = async (data: IRecentData) => {
select: "_id",
});
let filter = { isArchive: false } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const populatedProjects = userRecentData.recentlyViewed as IProject[];
const RecentDatas = await Promise.all(
populatedProjects.map(async (project) => {

View File

@@ -18,9 +18,9 @@ export const TrashDatas = async (data: IOrg) => {
try {
const { organization, role, userId } = data;
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const TrashLists = await projectModel(organization).find(filter);
if (!TrashLists) return { staus: "Trash is Empty" };
const TrashDocs: any[] = [];
@@ -57,9 +57,9 @@ export const RestoreTrashData = async (data: IRestore) => {
try {
const { projectId, organization, role, userId } = data;
let filter = { isArchive: true, _id: projectId } as RoleFilter;
if (role === "User") {
filter.createdBy = userId;
}
// if (role === "User") {
// filter.createdBy = userId;
// }
const findProject = await projectModel(organization).findOne(filter);
if (!findProject) return { status: "Project not found" };
const restoreData = await projectModel(organization).findOneAndUpdate(