V1 for the builder processing
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import { ZoneService } from "../controller/lines/zoneService.ts";
|
import { ZoneService } from "../controller/lines/zoneService.ts";
|
||||||
|
import { zone } from "../controller/lines/zone-Services.ts";
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
/**
|
/**
|
||||||
@@ -539,4 +540,6 @@ router.get("/A_zone/:zoneId/:organization", ZoneService.ZoneData);
|
|||||||
*/
|
*/
|
||||||
router.patch("/zone/:zoneId", ZoneService.deleteAZone); //delete Zone
|
router.patch("/zone/:zoneId", ZoneService.deleteAZone); //delete Zone
|
||||||
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
router.patch("/zones/lockedPanels", ZoneService.lockedPanel);
|
||||||
|
|
||||||
|
router.get("/findZones/:organization", zone.getZones);
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -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 (
|
export const searchProjectController = async (
|
||||||
req: Request,
|
req: AuthenticatedRequest,
|
||||||
res: Response
|
res: Response
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { searchName, organization, userId } = req.query as {
|
const { userId, organization, role } = req.user || {};
|
||||||
organization: string;
|
if (!userId || !organization || !role) {
|
||||||
searchName: string;
|
|
||||||
userId: string;
|
|
||||||
};
|
|
||||||
if (!userId || !organization || !searchName) {
|
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const { searchName } = req.query as {
|
||||||
|
searchName: string;
|
||||||
|
};
|
||||||
const result = await searchProject({
|
const result = await searchProject({
|
||||||
searchName,
|
searchName,
|
||||||
organization,
|
organization,
|
||||||
@@ -100,21 +99,21 @@ export const searchProjectController = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const searchTrashProjectController = async (
|
export const searchTrashProjectController = async (
|
||||||
req: Request,
|
req: AuthenticatedRequest,
|
||||||
res: Response
|
res: Response
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { searchName, organization, userId } = req.query as {
|
const { userId, organization, role } = req.user || {};
|
||||||
organization: string;
|
if (!userId || !organization || !role) {
|
||||||
searchName: string;
|
|
||||||
userId: string;
|
|
||||||
};
|
|
||||||
if (!userId || !organization || !searchName) {
|
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const { searchName } = req.query as {
|
||||||
|
searchName: string;
|
||||||
|
};
|
||||||
|
|
||||||
const result = await searchTrashProject({
|
const result = await searchTrashProject({
|
||||||
searchName,
|
searchName,
|
||||||
organization,
|
organization,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export const createProjectController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
console.log("req.user: ", req.user);
|
|
||||||
const { projectUuid, thumbnail } = req.body;
|
const { projectUuid, thumbnail } = req.body;
|
||||||
if (!req.user || !req.user.userId || !req.user.organization) {
|
if (!req.user || !req.user.userId || !req.user.organization) {
|
||||||
res.status(401).json({ message: "Unauthorized" });
|
res.status(401).json({ message: "Unauthorized" });
|
||||||
@@ -82,7 +81,7 @@ export const GetProjects = async (
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "Success":
|
case "Success":
|
||||||
res.status(201).json({
|
res.status(200).json({
|
||||||
Projects: result?.Datas,
|
Projects: result?.Datas,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import { tokenValidator } from "../../../shared/utils/token.ts";
|
import { tokenValidator } from "../../../shared/utils/token.ts";
|
||||||
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
import authorizedRoles from "../../../shared/middleware/rbacMiddleware.ts";
|
||||||
import { recentDataController } from "../../V1/v1Controllers/homeController/v1homeController.ts";
|
import {
|
||||||
|
recentDataController,
|
||||||
|
searchProjectController,
|
||||||
|
searchTrashProjectController,
|
||||||
|
} from "../../V1/v1Controllers/homeController/v1homeController.ts";
|
||||||
|
|
||||||
const v1homeRoutes = express.Router();
|
const v1homeRoutes = express.Router();
|
||||||
|
|
||||||
@@ -9,8 +13,20 @@ const v1homeRoutes = express.Router();
|
|||||||
v1homeRoutes.get(
|
v1homeRoutes.get(
|
||||||
"/RecentlyViewed",
|
"/RecentlyViewed",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
recentDataController
|
recentDataController
|
||||||
);
|
);
|
||||||
|
v1homeRoutes.get(
|
||||||
|
"/searchProjects",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
searchProjectController
|
||||||
|
);
|
||||||
|
v1homeRoutes.get(
|
||||||
|
"/searchTrashProjects",
|
||||||
|
tokenValidator,
|
||||||
|
// authorizedRoles("Admin", "User"),
|
||||||
|
searchTrashProjectController
|
||||||
|
);
|
||||||
|
|
||||||
export default v1homeRoutes;
|
export default v1homeRoutes;
|
||||||
|
|||||||
@@ -16,26 +16,26 @@ v1projectRouter.post("/upsertProject", tokenValidator, createProjectController);
|
|||||||
v1projectRouter.get(
|
v1projectRouter.get(
|
||||||
"/Projects",
|
"/Projects",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
GetProjects
|
GetProjects
|
||||||
);
|
);
|
||||||
v1projectRouter.patch(
|
v1projectRouter.patch(
|
||||||
"/Project/archive/:projectId",
|
"/Project/archive/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
RemoveProject
|
RemoveProject
|
||||||
);
|
);
|
||||||
|
|
||||||
v1projectRouter.patch(
|
v1projectRouter.patch(
|
||||||
"/Project/:projectId",
|
"/Project/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
updateProjectController
|
updateProjectController
|
||||||
);
|
);
|
||||||
v1projectRouter.get(
|
v1projectRouter.get(
|
||||||
"/Project/:projectId",
|
"/Project/:projectId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
ViewData
|
ViewData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -7,19 +7,18 @@ import {
|
|||||||
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
} from "../../V1/v1Controllers/trashController/v1trashController.ts";
|
||||||
|
|
||||||
const v1TrashRoutes = express.Router();
|
const v1TrashRoutes = express.Router();
|
||||||
|
|
||||||
//trash
|
//trash
|
||||||
v1TrashRoutes.get(
|
v1TrashRoutes.get(
|
||||||
"/TrashItems ",
|
"/TrashItems",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
GetTrashList
|
GetTrashList
|
||||||
);
|
);
|
||||||
|
|
||||||
v1TrashRoutes.patch(
|
v1TrashRoutes.patch(
|
||||||
"/Trash/restore",
|
"/Trash/restore",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
authorizedRoles("Admin", "User"),
|
// authorizedRoles("Admin", "User"),
|
||||||
RestoreTrash
|
RestoreTrash
|
||||||
);
|
);
|
||||||
export default v1TrashRoutes;
|
export default v1TrashRoutes;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class Environment {
|
|||||||
shadowVisibility,
|
shadowVisibility,
|
||||||
organization,
|
organization,
|
||||||
renderDistance,
|
renderDistance,
|
||||||
limitDistance,
|
limitDistance,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
const findvalue = await environmentModel(organization).findOne({
|
const findvalue = await environmentModel(organization).findOne({
|
||||||
|
|||||||
117
src/api-server/controller/lines/zone-Services.ts
Normal file
117
src/api-server/controller/lines/zone-Services.ts
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
import { Request, Response } from "express";
|
||||||
|
import zoneModel from "../../../shared/model/lines/zone-Model.ts";
|
||||||
|
export class zone {
|
||||||
|
static async setZone(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, userId, zoneData } = req.body;
|
||||||
|
// console.log('req.body: ', req.body);
|
||||||
|
const zoneId = zoneData.zoneId;
|
||||||
|
const points = zoneData.points;
|
||||||
|
const zoneName = zoneData.zoneName;
|
||||||
|
const layer = zoneData.layer;
|
||||||
|
const viewPortCenter = zoneData.viewPortCenter;
|
||||||
|
const viewPortposition = zoneData.viewPortposition;
|
||||||
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (findZoneId) {
|
||||||
|
const updateZone = await zoneModel(organization)
|
||||||
|
.findOneAndUpdate(
|
||||||
|
{ zoneId: zoneId },
|
||||||
|
{
|
||||||
|
points: points,
|
||||||
|
viewPortposition: viewPortposition,
|
||||||
|
viewPortCenter: viewPortCenter,
|
||||||
|
},
|
||||||
|
{ new: true }
|
||||||
|
)
|
||||||
|
.select("-_id -__v");
|
||||||
|
res.status(201).json({
|
||||||
|
message: "zone updated",
|
||||||
|
data: updateZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const zoneCreate = await zoneModel(organization).create({
|
||||||
|
zoneId,
|
||||||
|
createBy: userId,
|
||||||
|
zoneName: zoneName,
|
||||||
|
points,
|
||||||
|
layer,
|
||||||
|
viewPortCenter,
|
||||||
|
viewPortposition,
|
||||||
|
});
|
||||||
|
const createdZone = await zoneModel(organization)
|
||||||
|
.findById(zoneCreate._id)
|
||||||
|
.select("-_id -__v")
|
||||||
|
.lean();
|
||||||
|
res.status(201).json({
|
||||||
|
message: "zone created",
|
||||||
|
data: createdZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async deleteZone(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, userId, zoneId } = req.body;
|
||||||
|
|
||||||
|
const findZoneId = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
if (findZoneId) {
|
||||||
|
const deleteZone = await zoneModel(organization)
|
||||||
|
.findOneAndDelete({ zoneId: zoneId, createBy: userId })
|
||||||
|
.select("-_id -__v");
|
||||||
|
res.status(201).json({
|
||||||
|
message: "zone deleted",
|
||||||
|
data: deleteZone,
|
||||||
|
organization: organization,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.status(500).json({ message: "Invalid zone ID" });
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static async getZones(req: Request, res: Response) {
|
||||||
|
try {
|
||||||
|
const { organization, userId } = req.params;
|
||||||
|
|
||||||
|
const findZoneId = await zoneModel(organization)
|
||||||
|
.find()
|
||||||
|
.select(
|
||||||
|
"zoneId zoneName layer points viewPortCenter viewPortposition -_id"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!findZoneId) {
|
||||||
|
res.status(500).json({ message: "Invalid zone" });
|
||||||
|
}
|
||||||
|
res.status(200).json({ data: findZoneId, organization: organization });
|
||||||
|
} catch (error) {
|
||||||
|
console.log("error: ", error);
|
||||||
|
res.status(500).json({ message: "Zone not found", error });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async ZoneData(req: Request, res: Response): Promise<any> {
|
||||||
|
try {
|
||||||
|
const organization = req.params.organization;
|
||||||
|
const zoneId = req.params.zoneId;
|
||||||
|
const findZone = await zoneModel(organization).findOne({
|
||||||
|
zoneId: zoneId,
|
||||||
|
});
|
||||||
|
// .select("zoneName");
|
||||||
|
console.log("findZone: ", findZone);
|
||||||
|
if (findZone) return res.status(200).json(findZone);
|
||||||
|
} catch (error: any) {
|
||||||
|
return res.status(500).send(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Document, Schema } from "mongoose";
|
import { Document, Schema } from "mongoose";
|
||||||
import MainModel from "../connect/mongoose.ts";
|
import MainModel from "../connect/mongoose.ts";
|
||||||
export interface User extends Document {
|
export interface User extends Document {
|
||||||
userName: String;
|
userName: String;
|
||||||
@@ -49,7 +49,8 @@ const signupschema: Schema = new Schema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const userModel = (db:string) => {
|
const userModel = (db: string) => {
|
||||||
return MainModel(db, "Users", signupschema, "Users")
|
return MainModel(db, "Users", signupschema, "Users")
|
||||||
|
// return MainModel(db, "UserAuth", signupschema, "UserAuth");
|
||||||
};
|
};
|
||||||
export default userModel;
|
export default userModel;
|
||||||
|
|||||||
0
src/shared/services/builder/assetService.ts
Normal file
0
src/shared/services/builder/assetService.ts
Normal file
0
src/shared/services/builder/lineService.ts
Normal file
0
src/shared/services/builder/lineService.ts
Normal file
117
src/shared/services/builder/wallService.ts
Normal file
117
src/shared/services/builder/wallService.ts
Normal 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" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
0
src/shared/services/builder/zoneService.ts
Normal file
0
src/shared/services/builder/zoneService.ts
Normal file
@@ -103,9 +103,9 @@ export const GetAllProjects = async (data: GetProjectsInterface) => {
|
|||||||
await existingUser(userId, organization);
|
await existingUser(userId, organization);
|
||||||
if (!existingUser) return { status: "User not found" };
|
if (!existingUser) return { status: "User not found" };
|
||||||
let filter = { isArchive: false } as RoleFilter;
|
let filter = { isArchive: false } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const projectDatas = await projectModel(organization)
|
const projectDatas = await projectModel(organization)
|
||||||
.find(filter)
|
.find(filter)
|
||||||
.select("_id projectName createdBy thumbnail createdAt projectUuid");
|
.select("_id projectName createdBy thumbnail createdAt projectUuid");
|
||||||
@@ -121,9 +121,9 @@ export const DeleteProject = async (data: ProjectInterface) => {
|
|||||||
const ExistingUser = await existingUser(userId, organization);
|
const ExistingUser = await existingUser(userId, organization);
|
||||||
if (!ExistingUser) return { status: "User not found" };
|
if (!ExistingUser) return { status: "User not found" };
|
||||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const existingProject = await projectModel(organization).findOne(filter);
|
const existingProject = await projectModel(organization).findOne(filter);
|
||||||
if (!existingProject) return { status: "Project not found" };
|
if (!existingProject) return { status: "Project not found" };
|
||||||
const updateProject = await projectModel(organization).findOneAndUpdate(
|
const updateProject = await projectModel(organization).findOneAndUpdate(
|
||||||
@@ -143,9 +143,9 @@ export const updateProject = async (data: updateProjectInput) => {
|
|||||||
const ExistingUser = await existingUser(userId, organization);
|
const ExistingUser = await existingUser(userId, organization);
|
||||||
if (!ExistingUser) return { status: "User not found" };
|
if (!ExistingUser) return { status: "User not found" };
|
||||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const existingProject = await projectModel(organization).findOne(filter);
|
const existingProject = await projectModel(organization).findOne(filter);
|
||||||
if (!existingProject) return { status: "Project not found" };
|
if (!existingProject) return { status: "Project not found" };
|
||||||
if (projectName !== undefined) projectName;
|
if (projectName !== undefined) projectName;
|
||||||
@@ -173,9 +173,9 @@ export const viewProject = async (data: ProjectInterface) => {
|
|||||||
isArchive: false,
|
isArchive: false,
|
||||||
});
|
});
|
||||||
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
let filter = { _id: projectId, isArchive: false } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const existingProject = await projectModel(organization).findOne(filter);
|
const existingProject = await projectModel(organization).findOne(filter);
|
||||||
if (!existingProject) return { status: "Project not found" };
|
if (!existingProject) return { status: "Project not found" };
|
||||||
const newArr = RecentUserDoc?.recentlyViewed || [];
|
const newArr = RecentUserDoc?.recentlyViewed || [];
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ export const RecentlyAdded = async (data: IRecentData) => {
|
|||||||
select: "_id",
|
select: "_id",
|
||||||
});
|
});
|
||||||
let filter = { isArchive: false } as RoleFilter;
|
let filter = { isArchive: false } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const populatedProjects = userRecentData.recentlyViewed as IProject[];
|
const populatedProjects = userRecentData.recentlyViewed as IProject[];
|
||||||
const RecentDatas = await Promise.all(
|
const RecentDatas = await Promise.all(
|
||||||
populatedProjects.map(async (project) => {
|
populatedProjects.map(async (project) => {
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ export const TrashDatas = async (data: IOrg) => {
|
|||||||
try {
|
try {
|
||||||
const { organization, role, userId } = data;
|
const { organization, role, userId } = data;
|
||||||
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
|
let filter = { isArchive: true, isDeleted: false } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const TrashLists = await projectModel(organization).find(filter);
|
const TrashLists = await projectModel(organization).find(filter);
|
||||||
if (!TrashLists) return { staus: "Trash is Empty" };
|
if (!TrashLists) return { staus: "Trash is Empty" };
|
||||||
const TrashDocs: any[] = [];
|
const TrashDocs: any[] = [];
|
||||||
@@ -57,9 +57,9 @@ export const RestoreTrashData = async (data: IRestore) => {
|
|||||||
try {
|
try {
|
||||||
const { projectId, organization, role, userId } = data;
|
const { projectId, organization, role, userId } = data;
|
||||||
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
let filter = { isArchive: true, _id: projectId } as RoleFilter;
|
||||||
if (role === "User") {
|
// if (role === "User") {
|
||||||
filter.createdBy = userId;
|
// filter.createdBy = userId;
|
||||||
}
|
// }
|
||||||
const findProject = await projectModel(organization).findOne(filter);
|
const findProject = await projectModel(organization).findOne(filter);
|
||||||
if (!findProject) return { status: "Project not found" };
|
if (!findProject) return { status: "Project not found" };
|
||||||
const restoreData = await projectModel(organization).findOneAndUpdate(
|
const restoreData = await projectModel(organization).findOneAndUpdate(
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const tokenGenerator = (
|
|||||||
organization: string
|
organization: string
|
||||||
) => {
|
) => {
|
||||||
const token = Jwt.sign(
|
const token = Jwt.sign(
|
||||||
{ Email: Email, role: role, userId, organization: organization },
|
{ Email: Email, role: role, userId: userId, organization: organization },
|
||||||
jwt_secret,
|
jwt_secret,
|
||||||
{
|
{
|
||||||
expiresIn: "3h",
|
expiresIn: "3h",
|
||||||
@@ -37,7 +37,7 @@ const tokenRefreshGenerator = (
|
|||||||
organization: string
|
organization: string
|
||||||
) => {
|
) => {
|
||||||
const token = Jwt.sign(
|
const token = Jwt.sign(
|
||||||
{ Email: Email, role: role, userId, organization: organization },
|
{ Email: Email, role: role, userId: userId, organization: organization },
|
||||||
refresh_jwt_secret,
|
refresh_jwt_secret,
|
||||||
{
|
{
|
||||||
expiresIn: "30d",
|
expiresIn: "30d",
|
||||||
@@ -95,6 +95,7 @@ const tokenValidator = async (
|
|||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
};
|
};
|
||||||
|
console.log("refresh token");
|
||||||
if (!decodedRefresh) {
|
if (!decodedRefresh) {
|
||||||
res.status(403).json({
|
res.status(403).json({
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user