Version based API - Pushed here before the 5000 and 8000

This commit is contained in:
2025-06-21 15:16:52 +05:30
parent dead851b1a
commit 3ec45276f4
114 changed files with 7547 additions and 1436 deletions

View File

@@ -1,11 +1,11 @@
import wallItemModel from "../../../shared/model/builder/assets/wallitems-Model.ts";
import wallItemModel from "../../V1Models/Builder/wallItemsModel.ts";
import {
existingProjectById,
existingUser,
LivingCurrentVersion,
} from "../helpers/v1projecthelperFns.ts";
interface IWallSetupData {
modelUuid: string;
assetId: string;
modelName: string;
type: string;
csgposition: [];
@@ -15,12 +15,15 @@ interface IWallSetupData {
scale: [];
organization: string;
projectId: string;
versionId: string;
userId: string;
assetId: string;
}
interface IWallGet {
userId: string;
organization: string;
projectId: string;
versionId: string;
}
interface IWallDelete {
userId: string;
@@ -28,6 +31,7 @@ interface IWallDelete {
modelName: string;
organization: string;
projectId: string;
versionId: string;
}
interface IWallItemResult {
data?: Object;
@@ -41,16 +45,18 @@ export const setWallItems = async (
userId,
modelUuid,
modelName,
assetId,
position,
type,
csgposition,
csgscale,
quaternion,
assetId,
scale,
projectId,
versionId,
organization,
} = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
@@ -59,13 +65,27 @@ export const setWallItems = async (
userId
);
if (!LivingProject) return { status: "Project not found" };
const ExistingVersion = await LivingCurrentVersion(
organization,
LivingProject._id,
versionId
);
if (!ExistingVersion) return { status: "Version Data not found" };
const findvalue = await wallItemModel(organization).findOne({
modelUuid: modelUuid,isArchive:false
modelUuid: modelUuid,
projectId: projectId,
versionId: versionId,
isArchive: false,
});
if (findvalue) {
const updatevalue = await wallItemModel(organization).findOneAndUpdate(
{ modelUuid: modelUuid, projectId: projectId,isArchive:false },
{
modelUuid: modelUuid,
projectId: projectId,
versionId: versionId,
isArchive: false,
},
{
modelName,
position,
@@ -87,14 +107,15 @@ export const setWallItems = async (
modelName,
position,
type,
projectId,
versionId: versionId,
projectId: projectId,
csgposition,
csgscale,
quaternion,
scale,
userId,
assetId,
});
console.log("newValue: ", newValue);
return {
// status: "wall Item created successfully",
status: "Success",
@@ -115,7 +136,7 @@ export const setWallItems = async (
};
export const getWallItems = async (data: IWallGet) => {
try {
const { organization, userId, projectId } = data;
const { organization, userId, projectId, versionId } = data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
@@ -124,8 +145,17 @@ export const getWallItems = async (data: IWallGet) => {
userId
);
if (!LivingProject) return { status: "Project not found" };
const VersionGetId = versionId ? versionId : LivingProject.Present_version;
const ExistingVersion = await LivingCurrentVersion(
organization,
LivingProject._id,
VersionGetId
);
if (!ExistingVersion) return { status: "Version Data not found" };
const findValue = await wallItemModel(organization).find({
projectId: projectId,isArchive:false
projectId: projectId,
versionId: ExistingVersion._id,
isArchive: false,
});
if (!findValue) {
return {
@@ -154,7 +184,8 @@ export const deleteWallItems = async (
data: IWallDelete
): Promise<IWallItemResult> => {
try {
const { modelUuid, modelName, organization, userId, projectId } = data;
const { modelUuid, modelName, organization, userId, versionId, projectId } =
data;
const UserExists = await existingUser(userId, organization);
if (!UserExists) return { status: "User not found" };
const LivingProject = await existingProjectById(
@@ -163,10 +194,18 @@ export const deleteWallItems = async (
userId
);
if (!LivingProject) return { status: "Project not found" };
const ExistingVersion = await LivingCurrentVersion(
organization,
LivingProject._id,
versionId
);
if (!ExistingVersion) return { status: "Version Data not found" };
const findValue = await wallItemModel(organization).findOneAndDelete({
modelUuid: modelUuid,
modelName: modelName,
projectId: projectId,isArchive:false
projectId: projectId,
versionId: versionId,
isArchive: false,
});
if (!findValue) {
return {