Initial
This commit is contained in:
53
src/socket-server/services/assets/flooritem-Controller.ts
Normal file
53
src/socket-server/services/assets/flooritem-Controller.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Request, Response } from "express";
|
||||
import floorItemsModel from "../../../shared/model/assets/flooritems-Model";
|
||||
|
||||
export const setFloorItems = async (data: any) => {
|
||||
try {
|
||||
const { modelfileID,modeluuid, modelname, position, rotation,isLocked,isVisible, organization } = data
|
||||
|
||||
|
||||
|
||||
const findvalue = await floorItemsModel(organization).findOne({ modeluuid: modeluuid, modelname: modelname })
|
||||
|
||||
if (findvalue) {
|
||||
|
||||
const updatevalue = await floorItemsModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid, modelname: modelname }, { position: position, rotation: rotation ,isVisible:isVisible,isLocked:isLocked}, { new: true });
|
||||
return { success: true, message: 'flooritems updated', data: updatevalue,organization:organization }
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
const newValue = await floorItemsModel(organization).create({ modeluuid, modelname, modelfileID,position, rotation,isLocked,isVisible });
|
||||
|
||||
|
||||
return { success: true, message: 'flooritem created', data: newValue,organization:organization }
|
||||
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error creating flooritems:', error);
|
||||
return { success: false, message: 'Error creating or updating camera', error }
|
||||
}
|
||||
}
|
||||
|
||||
export const deleteFloorItems = async (data: any)=>{
|
||||
try {
|
||||
const { modeluuid,modelname,organization } = data;
|
||||
|
||||
const findValue = await floorItemsModel(organization).findOneAndDelete({modeluuid:modeluuid,modelname:modelname})
|
||||
if (!findValue) {
|
||||
return { success: false, message: 'model not found',organization:organization }
|
||||
|
||||
} else {
|
||||
|
||||
return { success: true, message: 'flooritem deleted', data: findValue,organization:organization }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error get flooritems:', error);
|
||||
return { success: false, message: 'Failed to delete flooritems', error }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
60
src/socket-server/services/assets/wallitem-Controller.ts
Normal file
60
src/socket-server/services/assets/wallitem-Controller.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { Request, Response } from "express";
|
||||
import wallItenmModel from "../../../shared/model/assets/wallitems-Model";
|
||||
|
||||
|
||||
export const setWallItems = async (data: any) => {
|
||||
try {
|
||||
const { modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale, organization } = data
|
||||
|
||||
|
||||
const findvalue = await wallItenmModel(organization).findOne({ modeluuid: modeluuid })
|
||||
if (findvalue) {
|
||||
|
||||
const updatevalue = await wallItenmModel(organization).findOneAndUpdate(
|
||||
{ modeluuid: modeluuid },
|
||||
{
|
||||
modelname,
|
||||
position,
|
||||
type,
|
||||
csgposition,
|
||||
csgscale,
|
||||
quaternion,
|
||||
scale,
|
||||
},
|
||||
{ new: true } // Return the updated document
|
||||
);
|
||||
return { success: true, message: 'wallIitem updated', data: updatevalue, organization: organization }
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
const newValue = await wallItenmModel(organization).create({ modeluuid, modelname, position, type, csgposition, csgscale, quaternion, scale });
|
||||
return { success: true, message: 'wallIitem created', data: newValue, organization: organization }
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error creating wallIitem:', error);
|
||||
return { success: false, message: 'Error creating or updating camera', error }
|
||||
}
|
||||
}
|
||||
|
||||
export const deleteWallItems = async (data: any) => {
|
||||
try {
|
||||
const { modeluuid, modelname, organization } = data;
|
||||
|
||||
|
||||
const findValue = await wallItenmModel(organization).findOneAndDelete({ modeluuid: modeluuid, modelname: modelname })
|
||||
if (!findValue) {
|
||||
return { success: false, message: 'model not found', organization: organization }
|
||||
|
||||
} else {
|
||||
|
||||
return { success: true, message: 'wallitem deleted', data: findValue, organization: organization }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error get wallitem:', error);
|
||||
return { success: false, message: 'Failed to delete wallitem', error }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user