Add missing semicolons and format code for consistency
Updated the controllers and services by adding missing semicolons to ensure code consistency and prevent potential runtime errors. Reformatted the import statements to enhance readability and maintain a uniform style across the codebase.
This commit is contained in:
parent
04cc2daf43
commit
1c78912f99
@ -25,18 +25,18 @@ export class GroupsController {
|
||||
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||
@Query("search", new DefaultValuePipe("")) search: string,
|
||||
) {
|
||||
return await this.groupsService.getGroupsByName(limit, offset, search)
|
||||
return await this.groupsService.getGroupsByName(limit, offset, search);
|
||||
}
|
||||
|
||||
@Post("new")
|
||||
async newGroup(@Body() body: CreateGroupDto) {
|
||||
return await this.groupsService.newGroup(body.groupName)
|
||||
return await this.groupsService.newGroup(body.groupName);
|
||||
}
|
||||
|
||||
@UseGuards(AdminGuard)
|
||||
@Delete(":groupId")
|
||||
async deleteGroup(@Param("groupId") groupId: string) {
|
||||
return await this.groupsService.deleteGroup(groupId)
|
||||
return await this.groupsService.deleteGroup(groupId);
|
||||
}
|
||||
|
||||
//TODO Patch
|
||||
@ -48,6 +48,11 @@ export class GroupsController {
|
||||
@Query("search", new DefaultValuePipe("")) search: string,
|
||||
@Param("groupId") groupId: string,
|
||||
) {
|
||||
return await this.groupsService.findFilesForGroup(limit, offset, search, groupId)
|
||||
return await this.groupsService.findFilesForGroup(
|
||||
limit,
|
||||
offset,
|
||||
search,
|
||||
groupId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
import { Injectable, InternalServerErrorException, NotFoundException } from '@nestjs/common';
|
||||
import {
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
NotFoundException,
|
||||
} from "@nestjs/common";
|
||||
import { DbService } from "apps/backend/src/app/db/db.service";
|
||||
import { FilesGroupTable, FilesTable } from 'apps/backend/src/app/db/schema';
|
||||
import { and, eq, ilike } from 'drizzle-orm';
|
||||
import { FilesGroupTable, FilesTable } from "apps/backend/src/app/db/schema";
|
||||
import { and, eq, ilike } from "drizzle-orm";
|
||||
|
||||
@Injectable()
|
||||
export class GroupsService {
|
||||
@ -19,7 +23,6 @@ export class GroupsService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
//TODO The method to create a group
|
||||
async newGroup(groupName: string) {
|
||||
return await this.database
|
||||
.use()
|
||||
@ -32,9 +35,9 @@ export class GroupsService {
|
||||
.execute();
|
||||
}
|
||||
|
||||
//TODO a method to delete a group and place the associated file at a null group reference
|
||||
async deleteGroup(groupId: string) {
|
||||
const groupInDb = await this.database.use()
|
||||
const groupInDb = await this.database
|
||||
.use()
|
||||
.select()
|
||||
.from(FilesGroupTable)
|
||||
.where(eq(FilesGroupTable.uuid, groupId))
|
||||
@ -43,24 +46,24 @@ export class GroupsService {
|
||||
if (groupInDb.length === 0) throw new NotFoundException("Group not found");
|
||||
// Replace entry by null
|
||||
await this.database
|
||||
.use()
|
||||
.update(FilesTable)
|
||||
// @ts-ignore
|
||||
.set({ groupId: null })
|
||||
.where(eq(FilesTable.groupId, groupId))
|
||||
.prepare("updateFilesGroupReference")
|
||||
.execute();
|
||||
.use()
|
||||
.update(FilesTable)
|
||||
// @ts-ignore
|
||||
.set({ groupId: null })
|
||||
.where(eq(FilesTable.groupId, groupId))
|
||||
.prepare("updateFilesGroupReference")
|
||||
.execute();
|
||||
try {
|
||||
await this.database
|
||||
.use()
|
||||
.delete(FilesGroupTable)
|
||||
.where(eq(FilesGroupTable.uuid, groupId))
|
||||
return true
|
||||
.where(eq(FilesGroupTable.uuid, groupId));
|
||||
return true;
|
||||
} catch (e) {
|
||||
throw new InternalServerErrorException("Error while deleting group");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async findFilesForGroup(
|
||||
limit: number,
|
||||
offset: number,
|
||||
@ -71,10 +74,15 @@ export class GroupsService {
|
||||
.use()
|
||||
.select()
|
||||
.from(FilesTable)
|
||||
.where(and(eq(FilesTable.groupId, groupId), ilike(FilesTable.fileName, String(`%${searchField}%`)) ) )
|
||||
.where(
|
||||
and(
|
||||
eq(FilesTable.groupId, groupId),
|
||||
ilike(FilesTable.fileName, String(`%${searchField}%`)),
|
||||
),
|
||||
)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.prepare('findFilesInGroup')
|
||||
.prepare("findFilesInGroup")
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user