V1 for the builder processing
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import { Request, Response } from "express";
|
||||
import { WallItems } from "../../../../shared/services/builder/wallService.ts";
|
||||
import { error } from "console";
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
|
||||
export const WallSetup = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { userId, organization } = req.user || {};
|
||||
const {
|
||||
modelUuid,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
// versionId
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
!modelUuid ||
|
||||
!modelName ||
|
||||
!position ||
|
||||
!type ||
|
||||
!projectId ||
|
||||
!csgscale ||
|
||||
!csgposition ||
|
||||
// !versionId ||
|
||||
!quaternion ||
|
||||
!scale ||
|
||||
!organization
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required!",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await WallItems.setWallItems({
|
||||
projectId,
|
||||
modelUuid,
|
||||
// versionId,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
organization,
|
||||
});
|
||||
switch (result.state) {
|
||||
case "Updated successfully":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
case "wall Item created successfully":
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json(error);
|
||||
break;
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
res.status(500).json({ message: "Unknown error" });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
import { Request, Response } from "express";
|
||||
|
||||
import { AuthenticatedRequest } from "../../../../shared/utils/token.ts";
|
||||
import {
|
||||
GetCamers,
|
||||
SetCamera,
|
||||
} from "../../../../shared/services/builder/cameraService.ts";
|
||||
|
||||
export const SetNewCamera = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { position, target, rotation, projectId, versionId } = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!role ||
|
||||
!userId ||
|
||||
!position ||
|
||||
!target ||
|
||||
!rotation ||
|
||||
!projectId ||
|
||||
!versionId
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const data = {
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
projectId,
|
||||
versionId,
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
};
|
||||
const result = await SetCamera(data);
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
});
|
||||
break;
|
||||
|
||||
case "Update Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("error: ", error);
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
export const CameraList = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
if (!organization || !role || !userId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = await GetCamers({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "Project not found":
|
||||
res.status(404).json({
|
||||
message: "Project not found",
|
||||
TrashDatas: [],
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
TrashDatas: result.data,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
message: "Internal server error",
|
||||
});
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: "Unknown error",
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -50,21 +50,20 @@ export const recentDataController = async (
|
||||
}
|
||||
};
|
||||
export const searchProjectController = async (
|
||||
req: Request,
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { searchName, organization, userId } = req.query as {
|
||||
organization: string;
|
||||
searchName: string;
|
||||
userId: string;
|
||||
};
|
||||
if (!userId || !organization || !searchName) {
|
||||
const { userId, organization, role } = req.user || {};
|
||||
if (!userId || !organization || !role) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { searchName } = req.query as {
|
||||
searchName: string;
|
||||
};
|
||||
const result = await searchProject({
|
||||
searchName,
|
||||
organization,
|
||||
@@ -100,21 +99,21 @@ export const searchProjectController = async (
|
||||
}
|
||||
};
|
||||
export const searchTrashProjectController = async (
|
||||
req: Request,
|
||||
req: AuthenticatedRequest,
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { searchName, organization, userId } = req.query as {
|
||||
organization: string;
|
||||
searchName: string;
|
||||
userId: string;
|
||||
};
|
||||
if (!userId || !organization || !searchName) {
|
||||
const { userId, organization, role } = req.user || {};
|
||||
if (!userId || !organization || !role) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { searchName } = req.query as {
|
||||
searchName: string;
|
||||
};
|
||||
|
||||
const result = await searchTrashProject({
|
||||
searchName,
|
||||
organization,
|
||||
|
||||
@@ -14,7 +14,6 @@ export const createProjectController = async (
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { userId, organization } = req.user || {};
|
||||
console.log("req.user: ", req.user);
|
||||
const { projectUuid, thumbnail } = req.body;
|
||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||
res.status(401).json({ message: "Unauthorized" });
|
||||
@@ -82,7 +81,7 @@ export const GetProjects = async (
|
||||
break;
|
||||
|
||||
case "Success":
|
||||
res.status(201).json({
|
||||
res.status(200).json({
|
||||
Projects: result?.Datas,
|
||||
});
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user