@@ -124,6 +124,15 @@ export class DecksController {
|
||||
return this.drizzleService.updateImage(data, user);
|
||||
}
|
||||
|
||||
@Put('image/:bildid/rename')
|
||||
async renameImage(@Request() req, @Param('bildid') bildid: string, @Body() data: { newImageName: string }) {
|
||||
if (!data.newImageName) {
|
||||
throw new HttpException('New image name is required', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
const user: User = req['user'];
|
||||
return this.drizzleService.renameImage(bildid, data.newImageName, user);
|
||||
}
|
||||
|
||||
@Delete('image/:bildid')
|
||||
async deleteImagesByBildId(@Request() req, @Param('bildid') bildid: string) {
|
||||
const user: User = req['user'];
|
||||
|
||||
@@ -216,7 +216,32 @@ export class DrizzleService {
|
||||
|
||||
return { status: 'success', moved_entries: existingImages.length };
|
||||
}
|
||||
/**
|
||||
* Methode zum Umbenennen eines Decks
|
||||
*/
|
||||
async renameImage(bildId: string, newImagename: string, user: User) {
|
||||
const existingImages = this.db
|
||||
.select()
|
||||
.from(Deck)
|
||||
.where(and(eq(Deck.bildid, bildId), eq(Deck.user, user.email)));
|
||||
if (existingImages.length === 0) {
|
||||
throw new HttpException('Deck not found', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
// const existingNewDeck = await this.getDeckByName(newDeckname, user);
|
||||
// if (existingNewDeck.length > 0) {
|
||||
// throw new HttpException('Deck with the new name already exists', HttpStatus.CONFLICT);
|
||||
// }
|
||||
|
||||
await this.db
|
||||
.update(Deck)
|
||||
.set({
|
||||
bildname: newImagename,
|
||||
updated: sql`CURRENT_TIMESTAMP`, // Setze 'updated' auf CURRENT_TIMESTAMP
|
||||
})
|
||||
.where(and(eq(Deck.bildid, bildId), eq(Deck.user, user.email)));
|
||||
return { status: 'success', message: 'Image Entries renamed successfully' };
|
||||
}
|
||||
/**
|
||||
* Methode zum Aktualisieren einer Box
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user