float and zone Api updated
This commit is contained in:
@@ -254,7 +254,7 @@ export const GetFloatController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { projectId, zoneUuid,versionId } = req.params;
|
const { projectId, zoneUuid, versionId } = req.params;
|
||||||
if (!userId || !organization || !projectId || !zoneUuid) {
|
if (!userId || !organization || !projectId || !zoneUuid) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
@@ -262,7 +262,8 @@ export const GetFloatController = async (
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const result = await GetFloatWidget({
|
const result = await GetFloatWidget({
|
||||||
organization,versionId,
|
organization,
|
||||||
|
versionId,
|
||||||
zoneUuid,
|
zoneUuid,
|
||||||
projectId,
|
projectId,
|
||||||
userId,
|
userId,
|
||||||
@@ -313,8 +314,14 @@ export const SingleFloatController = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
const { userId, organization } = req.user || {};
|
const { userId, organization } = req.user || {};
|
||||||
const { floatWidgetID } = req.params;
|
const { projectId, versionId, floatWidgetID } = req.params;
|
||||||
if (!userId || !organization || !floatWidgetID) {
|
if (
|
||||||
|
!userId ||
|
||||||
|
!organization ||
|
||||||
|
!floatWidgetID ||
|
||||||
|
!projectId ||
|
||||||
|
!versionId
|
||||||
|
) {
|
||||||
res.status(400).json({
|
res.status(400).json({
|
||||||
message: "All fields are required",
|
message: "All fields are required",
|
||||||
});
|
});
|
||||||
@@ -324,6 +331,8 @@ export const SingleFloatController = async (
|
|||||||
organization,
|
organization,
|
||||||
floatWidgetID,
|
floatWidgetID,
|
||||||
userId,
|
userId,
|
||||||
|
projectId,
|
||||||
|
versionId,
|
||||||
});
|
});
|
||||||
switch (result.status) {
|
switch (result.status) {
|
||||||
case "User not found":
|
case "User not found":
|
||||||
@@ -331,6 +340,16 @@ export const SingleFloatController = async (
|
|||||||
message: "User not found",
|
message: "User not found",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case "Project not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Project not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Version Data not found":
|
||||||
|
res.status(404).json({
|
||||||
|
message: "Version Data not found",
|
||||||
|
});
|
||||||
|
break;
|
||||||
case "Widget not found":
|
case "Widget not found":
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
message: "Widget not found",
|
message: "Widget not found",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ V1Zone.get(
|
|||||||
);
|
);
|
||||||
|
|
||||||
V1Zone.get(
|
V1Zone.get(
|
||||||
"/zones/:projectId/:zoneUuid/:versionId",
|
"/zone/:projectId/:zoneUuid/:versionId",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
ZoneDataController
|
ZoneDataController
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ import {
|
|||||||
|
|
||||||
const V1FloatWidget = express.Router();
|
const V1FloatWidget = express.Router();
|
||||||
|
|
||||||
V1FloatWidget.post(
|
V1FloatWidget.post("/floatWidget/save", tokenValidator, FloatAddController);
|
||||||
"/floatWidget/save",
|
|
||||||
tokenValidator,
|
|
||||||
FloatAddController
|
|
||||||
);
|
|
||||||
V1FloatWidget.patch(
|
V1FloatWidget.patch(
|
||||||
"/floatWidget/delete",
|
"/floatWidget/delete",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
@@ -26,7 +22,7 @@ V1FloatWidget.get(
|
|||||||
GetFloatController
|
GetFloatController
|
||||||
);
|
);
|
||||||
V1FloatWidget.get(
|
V1FloatWidget.get(
|
||||||
"/floatWidget/:floatWidgetId",
|
"/floatWidget/:projectId/:versionId/:floatWidgetID",
|
||||||
tokenValidator,
|
tokenValidator,
|
||||||
SingleFloatController
|
SingleFloatController
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ interface ISingleFloat {
|
|||||||
userId: string;
|
userId: string;
|
||||||
organization: string;
|
organization: string;
|
||||||
floatWidgetID: string;
|
floatWidgetID: string;
|
||||||
|
projectId: string;
|
||||||
|
versionId: string;
|
||||||
}
|
}
|
||||||
interface IGetZoneFloat {
|
interface IGetZoneFloat {
|
||||||
userId: string;
|
userId: string;
|
||||||
@@ -407,7 +409,7 @@ export const DuplicateFloat = async (
|
|||||||
|
|
||||||
export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
export const GetFloatWidget = async (data: IGetZoneFloat): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, zoneUuid, projectId, userId,versionId } = data;
|
const { organization, zoneUuid, projectId, userId, versionId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) {
|
if (!UserExists) {
|
||||||
return { status: "User not found" };
|
return { status: "User not found" };
|
||||||
@@ -478,16 +480,35 @@ export const SingleFloatWidget = async (
|
|||||||
data: ISingleFloat
|
data: ISingleFloat
|
||||||
): Promise<IResult> => {
|
): Promise<IResult> => {
|
||||||
try {
|
try {
|
||||||
const { organization, floatWidgetID, userId } = data;
|
const { organization, floatWidgetID, userId, projectId, versionId } = data;
|
||||||
const UserExists = await existingUser(userId, organization);
|
const UserExists = await existingUser(userId, organization);
|
||||||
if (!UserExists) return { status: "User not found" };
|
if (!UserExists) {
|
||||||
|
return { status: "User not found" };
|
||||||
|
}
|
||||||
|
const LivingProject = await existingProjectById(
|
||||||
|
projectId,
|
||||||
|
organization,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
if (!LivingProject) {
|
||||||
|
return { status: "Project not found" };
|
||||||
|
}
|
||||||
|
const VersionGetId = versionId ? versionId : LivingProject.Present_version;
|
||||||
|
const ExistingVersion = await LivingCurrentVersion(
|
||||||
|
organization,
|
||||||
|
LivingProject._id,
|
||||||
|
VersionGetId
|
||||||
|
);
|
||||||
|
if (!ExistingVersion) return { status: "Version Data not found" };
|
||||||
|
|
||||||
const widgetData = await floatWidgetModel(organization)
|
const widgetData = await floatWidgetModel(organization)
|
||||||
.findOne({
|
.findOne({
|
||||||
floatWidgetID: floatWidgetID,
|
floatWidgetID: floatWidgetID,
|
||||||
|
projectId: projectId,
|
||||||
|
versionId: versionId,
|
||||||
isArchive: false,
|
isArchive: false,
|
||||||
})
|
})
|
||||||
.select("-_id -zoneUuid -createdAt -updatedAt -__v");
|
.select("-_id -zoneUuid -createdAt -updatedAt -__v -isArchive");
|
||||||
if (!widgetData || widgetData.length === 0) {
|
if (!widgetData || widgetData.length === 0) {
|
||||||
return { status: "Widget not found" };
|
return { status: "Widget not found" };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user