Add CRUD endpoints for GroupsController
Implemented GET, POST, and DELETE endpoints in GroupsController to manage groups and associated files with pagination and optional search functionality. Created an ISearchQuery interface to standardize query parameters across methods.
This commit is contained in:
parent
6a759bd693
commit
1881a7e6c4
@ -1,7 +1,43 @@
|
|||||||
import { Controller } from '@nestjs/common';
|
import { Controller, DefaultValuePipe, Delete, Get, Param, ParseIntPipe, Post, Query } from '@nestjs/common';
|
||||||
import { GroupsService } from './groups.service';
|
import { GroupsService } from './groups.service';
|
||||||
|
import { ISearchQuery } from 'apps/backend/src/app/groups/groups.types';
|
||||||
|
|
||||||
@Controller('groups')
|
@Controller('groups')
|
||||||
export class GroupsController {
|
export class GroupsController {
|
||||||
constructor(private readonly groupsService: GroupsService) {}
|
constructor(private readonly groupsService: GroupsService) {}
|
||||||
|
|
||||||
|
//GET all groups with limit and offset + optional search
|
||||||
|
@Get()
|
||||||
|
async findMany(
|
||||||
|
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||||
|
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||||
|
@Query("search", new DefaultValuePipe("")) search: string
|
||||||
|
) {
|
||||||
|
const query = {limit, offset, search}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//POST a new group
|
||||||
|
@Post("new")
|
||||||
|
async newGroup() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//DELETE a group
|
||||||
|
@Delete(":groupId")
|
||||||
|
async deleteGroup(@Param('groupId') groupId: string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET files associated to group with limit and offset
|
||||||
|
@Get(":groupId")
|
||||||
|
async getForGroup(
|
||||||
|
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||||
|
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||||
|
@Query("search", new DefaultValuePipe("")) search: string,
|
||||||
|
@Param('groupId') groupId: string
|
||||||
|
) {
|
||||||
|
const query = {limit, offset, search}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
0
apps/backend/src/app/groups/groups.dto.ts
Normal file
0
apps/backend/src/app/groups/groups.dto.ts
Normal file
5
apps/backend/src/app/groups/groups.types.ts
Normal file
5
apps/backend/src/app/groups/groups.types.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface ISearchQuery {
|
||||||
|
limit: number;
|
||||||
|
offset: number;
|
||||||
|
search?: string;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user