swagger documentation for Api
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
import { Request, Response } from "express";
|
||||
import { Socket } from "socket.io";
|
||||
import cameraModel from "../../../shared/model/camera/camera-Model";
|
||||
|
||||
export const createCamera = async (data: any,) => {
|
||||
try {
|
||||
|
||||
const { userId, position, target, organization,rotation } = data
|
||||
|
||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
||||
if (findCamera) {
|
||||
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
||||
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
|
||||
// io.emit('cameraUpdateResponse', { success: true, message: 'Camera updated', data: updateCamera });
|
||||
return { success: true, message: 'Camera updated', data: updateCamera,organization:organization}
|
||||
|
||||
}
|
||||
else {
|
||||
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
|
||||
|
||||
return { success: false, message: 'Camera created' ,data:newCamera,organization:organization}
|
||||
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error creating camera:', error);
|
||||
return { success: false, message: 'Error creating or updating camera', error, }
|
||||
}
|
||||
}
|
||||
|
||||
import { Request, Response } from "express";
|
||||
import { Socket } from "socket.io";
|
||||
import cameraModel from "../../../shared/model/camera/camera-Model";
|
||||
|
||||
export const createCamera = async (data: any,) => {
|
||||
try {
|
||||
|
||||
const { userId, position, target, organization,rotation } = data
|
||||
|
||||
const findCamera = await cameraModel(organization).findOne({ userId: userId })
|
||||
if (findCamera) {
|
||||
const updateCamera = await cameraModel(organization).findOneAndUpdate(
|
||||
{ userId: userId }, { position: position, target: target,rotation:rotation }, { new: true });
|
||||
// io.emit('cameraUpdateResponse', { success: true, message: 'Camera updated', data: updateCamera });
|
||||
return { success: true, message: 'Camera updated', data: updateCamera,organization:organization}
|
||||
|
||||
}
|
||||
else {
|
||||
const newCamera = await cameraModel(organization).create({ userId, position, target,rotation })
|
||||
|
||||
return { success: false, message: 'Camera created' ,data:newCamera,organization:organization}
|
||||
|
||||
}
|
||||
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error creating camera:', error);
|
||||
return { success: false, message: 'Error creating or updating camera', error, }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user