Project based wall,service Functionality processing
This commit is contained in:
@@ -12,9 +12,23 @@ interface IWallSetupData {
|
||||
organization: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface IWallGet {
|
||||
userId: string;
|
||||
role: string;
|
||||
organization: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface IWallDelete {
|
||||
userId: string;
|
||||
modelUuid: string;
|
||||
modelName: string;
|
||||
role: string;
|
||||
organization: string;
|
||||
projectId: string;
|
||||
}
|
||||
interface IWallItemResult {
|
||||
data: {};
|
||||
state: string;
|
||||
data?: Object;
|
||||
status: string;
|
||||
}
|
||||
export class WallItems {
|
||||
static async setWallItems(data: IWallSetupData): Promise<IWallItemResult> {
|
||||
@@ -50,7 +64,7 @@ export class WallItems {
|
||||
{ new: true } // Return the updated document
|
||||
);
|
||||
return {
|
||||
state: "Updated successfully",
|
||||
status: "Updated successfully",
|
||||
data: updatevalue,
|
||||
};
|
||||
// res.status(201).json(updatevalue);
|
||||
@@ -67,51 +81,80 @@ export class WallItems {
|
||||
scale,
|
||||
});
|
||||
return {
|
||||
state: "wall Item created successfully",
|
||||
status: "wall Item created successfully",
|
||||
data: newValue,
|
||||
};
|
||||
// res.status(201).json(newValue);
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
const err = error as Error;
|
||||
console.error("Error creating wallitems:", error);
|
||||
return {
|
||||
state: "Failed to create wallitems",
|
||||
data: { message: err.message },
|
||||
};
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
static async getWallItems(req: Request, res: Response) {
|
||||
static async getWallItems(data: IWallGet) {
|
||||
try {
|
||||
const { organization } = req.params;
|
||||
const { organization, role, userId, projectId } = data;
|
||||
|
||||
const findValue = await wallItemModel(organization).find();
|
||||
if (!findValue) {
|
||||
res.status(200).json("wallitems not found");
|
||||
return {
|
||||
status: "wallitems not found",
|
||||
};
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
return {
|
||||
status: "Success",
|
||||
data: findValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get wallitems:", error);
|
||||
res.status(500).json({ error: "Failed to get wallitems" });
|
||||
}
|
||||
}
|
||||
static async deleteWallItems(req: Request, res: Response) {
|
||||
static async deleteWallItems(data: IWallDelete): Promise<IWallItemResult> {
|
||||
try {
|
||||
const { modelUuid, modelName, organization } = req.body;
|
||||
const { modelUuid, modelName, organization, userId, projectId, role } =
|
||||
data;
|
||||
|
||||
const findValue = await wallItemModel(organization).findOneAndDelete({
|
||||
modelUuid: modelUuid,
|
||||
modelName: modelName,
|
||||
projectId: projectId,
|
||||
});
|
||||
if (!findValue) {
|
||||
res.status(200).json("user not found");
|
||||
return {
|
||||
status: "model not found",
|
||||
};
|
||||
} else {
|
||||
res.status(201).json(findValue);
|
||||
return {
|
||||
status: "Success",
|
||||
data: findValue,
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
return {
|
||||
status: error.message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
status: "An unexpected error occurred",
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get wallitems:", error);
|
||||
res.status(500).json({ error: "Failed to get wallitems" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user