Skip to content

Commit

Permalink
Merge pull request #32 from lemoncloud-capstone/BE_day
Browse files Browse the repository at this point in the history
chore: fix updateStatus requestBody form
  • Loading branch information
Yeeun411 authored May 19, 2024
2 parents daad864 + fd25a5b commit 29297c1
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions apps/server/src/services/img.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ export class ImgService {
}
}

static async updateStatus(title: string, imgURL: string, status: any, labelPoints: any) {
static async updateStatus(title: string, imgURL: string, status: any, labelPoint: any) {
try {
return await imgRepository.updateImageStatus(title, imgURL, status, labelPoints);
const formattedLabelPoints = this.formatLabelPoints(labelPoint);
return await imgRepository.updateImageStatus(title, imgURL, status, formattedLabelPoints);
} catch (error) {
throw new Error('Failed to update image status');
throw new Error(error);
}
}
private static formatLabelPoints(labelPoints: any[]): any {
const formatted = {};
for (const point of labelPoints) {
const label = point.label;
if (!formatted[label]) {
formatted[label] = [];
}
formatted[label].push({
leftTop: { x: String(point.leftTop[0]), y: String(point.leftTop[1]) },
rightTop: { x: String(point.rightTop[0]), y: String(point.rightTop[1]) },
leftBottom: { x: String(point.leftBottom[0]), y: String(point.leftBottom[1]) },
rightBottom: { x: String(point.rightBottom[0]), y: String(point.rightBottom[1]) },
});
}
return formatted;
}
}

0 comments on commit 29297c1

Please sign in to comment.