2025-01-30 12:44:04 +05:30
|
|
|
import { Request, Response } from "express";
|
2025-03-28 12:45:59 +05:30
|
|
|
import userModel from "../../../shared/model/user-Model.ts";
|
2025-01-30 12:44:04 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
export class share {
|
|
|
|
|
static async shareUser(req: Request, res: Response) {
|
|
|
|
|
try {
|
|
|
|
|
const { email, isShare, organization } = req.body
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const findValue = await userModel(organization).findOneAndUpdate({email:email},{isShare:isShare},{new:true})
|
|
|
|
|
|
|
|
|
|
res.status(201).json({message:"scene shared successfully",data:findValue});
|
|
|
|
|
if (!findValue) {
|
|
|
|
|
res.status(404).json({message:"Not found"})
|
|
|
|
|
}
|
|
|
|
|
// Send response with the created document
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error creating Share:', error);
|
|
|
|
|
res.status(500).json({message:"Failed to create Share"});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async findshareUser(req: Request, res: Response) {
|
|
|
|
|
try {
|
|
|
|
|
const organization = req.query.organization as string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const findValue = await userModel(organization).find({}).select("isShare email userName -_id")
|
|
|
|
|
// console.log('findValue: ', findValue);
|
|
|
|
|
|
|
|
|
|
res.status(201).json({message:"scene shared datas",data:findValue});
|
|
|
|
|
if (!findValue) {
|
|
|
|
|
res.status(404).json({message:"Not found"})
|
|
|
|
|
}
|
|
|
|
|
// Send response with the created document
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error Share:', error);
|
|
|
|
|
res.status(500).json({message:"Failed to Share datas "});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|