Files
Dwinzo-Backend-V0.0/src/api-server/controller/share/share-Controller.ts

47 lines
1.4 KiB
TypeScript

import { Request, Response } from "express";
import userModel from "../../../shared/model/user-Model.ts";
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");
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 " });
}
}
}