@@ -9,7 +9,12 @@ import {
99 Query ,
1010 UseGuards ,
1111} from '@nestjs/common' ;
12- import { ApiTags , ApiOperation , ApiBearerAuth } from '@nestjs/swagger' ;
12+ import {
13+ ApiTags ,
14+ ApiOperation ,
15+ ApiBearerAuth ,
16+ ApiResponse ,
17+ } from '@nestjs/swagger' ;
1318import { AssetsService } from './assets.service' ;
1419import { BulkStatusDto } from './dto/bulk-status.dto' ;
1520import { BulkAssignDto } from './dto/bulk-assign.dto' ;
@@ -21,12 +26,14 @@ import { GetUser } from '../auth/decorators/get-user.decorator';
2126import { User } from '../users/entities/user.entity' ;
2227
2328@ApiTags ( 'assets' )
29+ @ApiBearerAuth ( 'JWT-auth' )
2430@Controller ( 'assets' )
2531export class AssetsController {
2632 constructor ( private readonly assetsService : AssetsService ) { }
2733
2834 @Get ( )
2935 @ApiOperation ( { summary : 'List all assets (paginated, filterable)' } )
36+ @ApiResponse ( { status : 200 , description : 'Paginated list of assets' } )
3037 findAll (
3138 @Query ( 'search' ) search ?: string ,
3239 @Query ( 'categoryId' ) categoryId ?: string ,
@@ -36,54 +43,68 @@ export class AssetsController {
3643 @Query ( 'page' ) page ?: number ,
3744 @Query ( 'limit' ) limit ?: number ,
3845 ) {
39- return this . assetsService . findAll ( { search, categoryId, departmentId, locationId, status, page, limit } ) ;
46+ return this . assetsService . findAll ( {
47+ search,
48+ categoryId,
49+ departmentId,
50+ locationId,
51+ status,
52+ page,
53+ limit,
54+ } ) ;
4055 }
4156
4257 @Post ( )
4358 @ApiOperation ( { summary : 'Create an asset' } )
59+ @ApiResponse ( { status : 201 , description : 'Asset created' } )
4460 create ( @Body ( ) dto : any ) {
4561 return this . assetsService . create ( dto ) ;
4662 }
4763
4864 @Get ( ':id' )
4965 @ApiOperation ( { summary : 'Get asset details' } )
66+ @ApiResponse ( { status : 200 , description : 'Asset details' } )
67+ @ApiResponse ( { status : 404 , description : 'Asset not found' } )
5068 findOne ( @Param ( 'id' ) id : string ) {
5169 return this . assetsService . findById ( id ) ;
5270 }
5371
5472 @Patch ( ':id' )
5573 @ApiOperation ( { summary : 'Update an asset' } )
74+ @ApiResponse ( { status : 200 , description : 'Asset updated' } )
5675 update ( @Param ( 'id' ) id : string , @Body ( ) dto : any ) {
5776 return this . assetsService . update ( id , dto ) ;
5877 }
5978
6079 @Delete ( ':id' )
6180 @ApiOperation ( { summary : 'Soft delete an asset' } )
81+ @ApiResponse ( { status : 200 , description : 'Asset deleted' } )
6282 delete ( @Param ( 'id' ) id : string ) {
6383 return this . assetsService . delete ( id ) ;
6484 }
6585
6686 @Patch ( 'bulk/status' )
6787 @UseGuards ( JwtAuthGuard )
68- @ApiBearerAuth ( )
6988 @ApiOperation ( { summary : 'Bulk update asset status' } )
89+ @ApiResponse ( { status : 200 , description : 'Bulk status update result' } )
7090 bulkStatus ( @Body ( ) dto : BulkStatusDto , @GetUser ( ) user : User ) {
7191 return this . assetsService . bulkStatus ( dto , user . id ) ;
7292 }
7393
7494 @Patch ( 'bulk/assign' )
7595 @UseGuards ( JwtAuthGuard )
76- @ApiBearerAuth ( )
7796 @ApiOperation ( { summary : 'Bulk assign assets to user or department' } )
97+ @ApiResponse ( { status : 200 , description : 'Bulk assignment result' } )
7898 bulkAssign ( @Body ( ) dto : BulkAssignDto , @GetUser ( ) user : User ) {
7999 return this . assetsService . bulkAssign ( dto , user . id ) ;
80100 }
81101
82102 @Delete ( 'bulk' )
83103 @UseGuards ( JwtAuthGuard , RolesGuard )
84104 @Roles ( 'ADMIN' )
85- @ApiBearerAuth ( )
86105 @ApiOperation ( { summary : 'Bulk soft delete assets (ADMIN only)' } )
106+ @ApiResponse ( { status : 200 , description : 'Bulk delete result' } )
107+ @ApiResponse ( { status : 403 , description : 'Forbidden — requires ADMIN role' } )
87108 bulkDelete ( @Body ( ) dto : BulkDeleteDto , @GetUser ( ) user : User ) {
88109 return this . assetsService . bulkDelete ( dto , user . id ) ;
89110 }
0 commit comments