2025-01-30 12:44:04 +05:30
|
|
|
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 }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|