Compare commits
No commits in common. "221410dfb0f1942089d64a8b9ec82b1526c52333" and "e03d16bdb4b6fa274f599bd0954504f03617085b" have entirely different histories.
221410dfb0
...
e03d16bdb4
@ -1,22 +1,14 @@
|
||||
import { Controller, DefaultValuePipe, Get, Param, ParseIntPipe, Post, Query, StreamableFile } from '@nestjs/common';
|
||||
import { Controller, Get, Param, Post, StreamableFile } from '@nestjs/common';
|
||||
import { FilesService } from "./files.service";
|
||||
|
||||
@Controller("files")
|
||||
export class FilesController {
|
||||
constructor(private readonly filesService: FilesService) {}
|
||||
|
||||
//TODO POST FILE
|
||||
@Post('new')
|
||||
async saveFile() {
|
||||
|
||||
}
|
||||
|
||||
@Get('find')
|
||||
async findMany(
|
||||
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||
@Query("search", new DefaultValuePipe("")) search: string,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@Get(':fileId')
|
||||
|
@ -1,19 +0,0 @@
|
||||
import { IsUUID, MaxLength, MinLength } from 'class-validator';
|
||||
import { DefaultValuePipe } from '@nestjs/common';
|
||||
|
||||
|
||||
export class CreateFilesDto {
|
||||
@MaxLength(128)
|
||||
@MinLength(4)
|
||||
fileName: string;
|
||||
|
||||
@MaxLength(64)
|
||||
@MinLength(2)
|
||||
uploadedBy: string;
|
||||
|
||||
isDocumentation?: boolean;
|
||||
isRestricted?: boolean;
|
||||
|
||||
@IsUUID()
|
||||
groupId: string;
|
||||
}
|
@ -2,7 +2,7 @@ import { Injectable, NotFoundException, StreamableFile } from '@nestjs/common';
|
||||
import { DbService } from 'apps/backend/src/app/db/db.service';
|
||||
import { FilesTable } from 'apps/backend/src/app/db/schema';
|
||||
import { StorageService } from 'apps/backend/src/app/storage/storage.service';
|
||||
import { eq, ilike } from 'drizzle-orm';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
|
||||
@Injectable()
|
||||
@ -55,20 +55,10 @@ export class FilesService {
|
||||
});
|
||||
}
|
||||
|
||||
public async search(limit: number, offset: number, searchField: string) {
|
||||
return await this.database
|
||||
.use()
|
||||
.select()
|
||||
.from(FilesTable)
|
||||
.where(ilike(FilesTable.fileName, String(searchField)))
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.prepare("searchFiles")
|
||||
.execute();
|
||||
}
|
||||
//TODO list the files
|
||||
|
||||
//TODO save a file
|
||||
public async save() {
|
||||
public async set() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,24 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { DbService } from 'apps/backend/src/app/db/db.service';
|
||||
import { FilesGroupTable } from 'apps/backend/src/app/db/schema';
|
||||
import { ilike } from 'drizzle-orm';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class GroupsService {
|
||||
constructor(private readonly database: DbService) {}
|
||||
|
||||
//TODO a method to fetch groups in the database by a specific search with limit, offset and a search field (can be blank)
|
||||
async getGroupsByName(limit: number, offset: number, search: string) {
|
||||
return await this.database.use()
|
||||
const result = await this.database.use()
|
||||
.select()
|
||||
.from(FilesGroupTable)
|
||||
.where(ilike(FilesGroupTable.groupName, search))
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.prepare("getGroupsByName")
|
||||
.execute();
|
||||
.execute()
|
||||
console.log(`Found ${result.length} groups for search :\n > "${search}"`)
|
||||
return result;
|
||||
}
|
||||
|
||||
//TODO The method to create a group
|
||||
|
Loading…
x
Reference in New Issue
Block a user