Controller and routing for the Vizualtion and builder
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import { Request, Response } from "express";
|
||||
import { 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
|
||||
@@ -18,7 +17,6 @@ export const WallSetup = async (
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
// versionId
|
||||
projectId,
|
||||
} = req.body;
|
||||
if (
|
||||
@@ -29,10 +27,10 @@ export const WallSetup = async (
|
||||
!projectId ||
|
||||
!csgscale ||
|
||||
!csgposition ||
|
||||
// !versionId ||
|
||||
!quaternion ||
|
||||
!scale ||
|
||||
!organization
|
||||
!organization ||
|
||||
!userId
|
||||
) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required!",
|
||||
@@ -42,7 +40,6 @@ export const WallSetup = async (
|
||||
const result = await WallItems.setWallItems({
|
||||
projectId,
|
||||
modelUuid,
|
||||
// versionId,
|
||||
modelName,
|
||||
position,
|
||||
type,
|
||||
@@ -51,13 +48,17 @@ export const WallSetup = async (
|
||||
quaternion,
|
||||
scale,
|
||||
organization,
|
||||
userId,
|
||||
});
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({ message: "User not found" });
|
||||
break;
|
||||
case "Updated successfully":
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
case "wall Item created successfully":
|
||||
res.status(200).json(result.data);
|
||||
res.status(201).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json(error);
|
||||
@@ -75,9 +76,9 @@ export const WallGet = async (
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId } = req.params;
|
||||
if (!organization || !role || !userId || !projectId) {
|
||||
if (!organization || !userId || !projectId) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
@@ -85,21 +86,21 @@ export const WallGet = async (
|
||||
}
|
||||
const result = await WallItems.getWallItems({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
projectId,
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({ message: "User not found" });
|
||||
break;
|
||||
case "wallitems not found":
|
||||
res.status(404).json({
|
||||
message: "wallitems not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
WallItems: result.data,
|
||||
});
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
@@ -118,16 +119,9 @@ export const WallDelete = async (
|
||||
res: Response
|
||||
): Promise<void> => {
|
||||
try {
|
||||
const { organization, role, userId } = req.user || {};
|
||||
const { organization, userId } = req.user || {};
|
||||
const { projectId, modelName, modelUuid } = req.body;
|
||||
if (
|
||||
!organization ||
|
||||
!role ||
|
||||
!userId ||
|
||||
!projectId ||
|
||||
!modelName ||
|
||||
!modelUuid
|
||||
) {
|
||||
if (!organization || !userId || !projectId || !modelName || !modelUuid) {
|
||||
res.status(400).json({
|
||||
message: "All fields are required",
|
||||
});
|
||||
@@ -135,7 +129,6 @@ export const WallDelete = async (
|
||||
}
|
||||
const result = await WallItems.deleteWallItems({
|
||||
organization,
|
||||
role,
|
||||
userId,
|
||||
projectId,
|
||||
modelName,
|
||||
@@ -143,15 +136,16 @@ export const WallDelete = async (
|
||||
});
|
||||
|
||||
switch (result.status) {
|
||||
case "User not found":
|
||||
res.status(404).json({ message: "User not found" });
|
||||
break;
|
||||
case "model not found":
|
||||
res.status(404).json({
|
||||
message: "model not found",
|
||||
});
|
||||
break;
|
||||
case "Success":
|
||||
res.status(200).json({
|
||||
message: "WallItem deleted",
|
||||
});
|
||||
res.status(200).json(result.data);
|
||||
break;
|
||||
default:
|
||||
res.status(500).json({
|
||||
|
||||
Reference in New Issue
Block a user