@@ -20,13 +20,16 @@ import { Messages } from '../../exceptions/text/messages.js';
2020import { ConnectionEditGuard } from '../../guards/connection-edit.guard.js' ;
2121import { ConnectionReadGuard } from '../../guards/connection-read.guard.js' ;
2222import { SentryInterceptor } from '../../interceptors/index.js' ;
23- import { FindAllRowsWithBodyFiltersDto } from '../table/dto/find-rows-with-body-filters.dto.js' ;
24- import { CreateTableFiltersDto } from './application/data-structures/create-table-filters.ds.js' ;
25- import { FindTableFiltersDs } from './application/data-structures/find-table-filters.ds.js' ;
26- import { CreatedTableFiltersRO } from './application/response-objects/created-table-filters.ro.js' ;
23+ import { SuccessResponse } from '../../microservices/saas-microservice/data-structures/common-responce.ds.js' ;
24+ import { CreateTableFilterDs } from './application/data-structures/create-table-filters.ds.js' ;
25+ import { FindTableFilterByIdDs , FindTableFiltersDs } from './application/data-structures/find-table-filters.ds.js' ;
26+ import { CreateTableFilterDto } from './application/response-objects/create-table-filters.dto.js' ;
27+ import { CreatedTableFilterRO } from './application/response-objects/created-table-filters.ro.js' ;
2728import {
2829 ICreateTableFilters ,
30+ IDeleteTableFilterById ,
2931 IDeleteTableFilters ,
32+ IFindTableFilterById ,
3033 IFindTableFilters ,
3134} from './use-cases/table-filters-use-cases.interface.js' ;
3235
@@ -43,55 +46,61 @@ export class TableFiltersController {
4346 private readonly findTableFiltersUseCase : IFindTableFilters ,
4447 @Inject ( UseCaseType . DELETE_TABLE_FILTERS )
4548 private readonly deleteTableFiltersUseCase : IDeleteTableFilters ,
49+ @Inject ( UseCaseType . FIND_TABLE_FILTER_BY_ID )
50+ private readonly findTableFilterByIdUseCase : IFindTableFilterById ,
51+ @Inject ( UseCaseType . DELETE_TABLE_FILTER_BY_ID )
52+ private readonly deleteTableFilterByIdUseCase : IDeleteTableFilterById ,
4653 ) { }
4754
48- @ApiOperation ( { summary : 'Add new table filters' } )
49- @ApiBody ( { type : FindAllRowsWithBodyFiltersDto } )
55+ @ApiOperation ( { summary : 'Add new table filters object ' } )
56+ @ApiBody ( { type : CreateTableFilterDto } )
5057 @ApiResponse ( {
5158 status : 201 ,
5259 description : 'Table filters created.' ,
53- type : CreatedTableFiltersRO ,
60+ type : CreatedTableFilterRO ,
5461 } )
5562 @ApiQuery ( { name : 'tableName' , required : true } )
5663 @ApiParam ( { name : 'connectionId' , required : true } )
5764 @UseGuards ( ConnectionEditGuard )
5865 @Post ( '/:connectionId' )
5966 async addTableFilters (
6067 @QueryTableName ( ) tableName : string ,
61- @Body ( ) body : FindAllRowsWithBodyFiltersDto ,
68+ @Body ( ) body : CreateTableFilterDto ,
6269 @SlugUuid ( 'connectionId' ) connectionId : string ,
6370 @MasterPassword ( ) masterPwd : string ,
64- ) : Promise < CreatedTableFiltersRO > {
71+ ) : Promise < CreatedTableFilterRO > {
6572 if ( ! tableName ) {
6673 throw new BadRequestException ( Messages . TABLE_NAME_MISSING ) ;
6774 }
6875 if ( ! body . filters ) {
6976 throw new BadRequestException ( Messages . FILTERS_MISSING ) ;
7077 }
71- const inputData : CreateTableFiltersDto = {
78+ const inputData : CreateTableFilterDs = {
7279 table_name : tableName ,
7380 connection_id : connectionId ,
7481 filters : body . filters ,
7582 masterPwd : masterPwd ,
83+ filter_name : body . name ,
84+ dynamic_filtered_column : body . dynamic_column ?? null ,
7685 } ;
7786 return await this . createTableFiltersUseCase . execute ( inputData , InTransactionEnum . ON ) ;
7887 }
7988
80- @ApiOperation ( { summary : 'Find table filters' } )
81- @ApiBody ( { type : FindAllRowsWithBodyFiltersDto } )
89+ @ApiOperation ( { summary : 'Find all table filters' } )
8290 @ApiResponse ( {
8391 status : 200 ,
8492 description : 'Table filters found.' ,
85- type : CreatedTableFiltersRO ,
93+ type : CreatedTableFilterRO ,
94+ isArray : true ,
8695 } )
8796 @ApiQuery ( { name : 'tableName' , required : true } )
8897 @ApiParam ( { name : 'connectionId' , required : true } )
8998 @UseGuards ( ConnectionReadGuard )
90- @Get ( '/:connectionId' )
99+ @Get ( '/:connectionId/all ' )
91100 async findTableFilters (
92101 @QueryTableName ( ) tableName : string ,
93102 @SlugUuid ( 'connectionId' ) connectionId : string ,
94- ) : Promise < CreatedTableFiltersRO > {
103+ ) : Promise < Array < CreatedTableFilterRO > > {
95104 if ( ! tableName ) {
96105 throw new BadRequestException ( Messages . TABLE_NAME_MISSING ) ;
97106 }
@@ -102,21 +111,42 @@ export class TableFiltersController {
102111 return await this . findTableFiltersUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
103112 }
104113
105- @ApiOperation ( { summary : 'Delete table filters' } )
106- @ApiBody ( { type : FindAllRowsWithBodyFiltersDto } )
114+ @ApiOperation ( { summary : 'Find table filter set by id' } )
107115 @ApiResponse ( {
108116 status : 200 ,
109- description : 'Table filters Deleted.' ,
110- type : CreatedTableFiltersRO ,
117+ description : 'Table filter found.' ,
118+ type : CreatedTableFilterRO ,
119+ isArray : true ,
120+ } )
121+ @ApiParam ( { name : 'connectionId' , required : true } )
122+ @ApiParam ( { name : 'filterId' , required : true } )
123+ @UseGuards ( ConnectionReadGuard )
124+ @Get ( '/:connectionId/:filterId' )
125+ async findTableFilterById (
126+ @SlugUuid ( 'connectionId' ) connectionId : string ,
127+ @SlugUuid ( 'filterId' ) filterId : string ,
128+ ) : Promise < CreatedTableFilterRO > {
129+ const inputData : FindTableFilterByIdDs = {
130+ filter_id : filterId ,
131+ connection_id : connectionId ,
132+ } ;
133+ return await this . findTableFilterByIdUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
134+ }
135+
136+ @ApiOperation ( { summary : 'Delete table all filters for table' } )
137+ @ApiResponse ( {
138+ status : 200 ,
139+ description : 'All table filters deleted.' ,
140+ type : SuccessResponse ,
111141 } )
112142 @ApiQuery ( { name : 'tableName' , required : true } )
113143 @ApiParam ( { name : 'connectionId' , required : true } )
114144 @UseGuards ( ConnectionEditGuard )
115- @Delete ( '/:connectionId' )
145+ @Delete ( '/:connectionId/all ' )
116146 async deleteTableFilters (
117147 @QueryTableName ( ) tableName : string ,
118148 @SlugUuid ( 'connectionId' ) connectionId : string ,
119- ) : Promise < CreatedTableFiltersRO > {
149+ ) : Promise < SuccessResponse > {
120150 if ( ! tableName ) {
121151 throw new BadRequestException ( Messages . TABLE_NAME_MISSING ) ;
122152 }
@@ -126,4 +156,25 @@ export class TableFiltersController {
126156 } ;
127157 return await this . deleteTableFiltersUseCase . execute ( inputData , InTransactionEnum . OFF ) ;
128158 }
159+
160+ @ApiOperation ( { summary : 'Delete filter set by id' } )
161+ @ApiResponse ( {
162+ status : 200 ,
163+ description : 'Table filter set deleted.' ,
164+ type : SuccessResponse ,
165+ } )
166+ @ApiParam ( { name : 'connectionId' , required : true } )
167+ @ApiParam ( { name : 'filterId' , required : true } )
168+ @UseGuards ( ConnectionEditGuard )
169+ @Delete ( '/:connectionId/:filterId' )
170+ async deleteTableFiltersById (
171+ @SlugUuid ( 'connectionId' ) connectionId : string ,
172+ @SlugUuid ( 'filterId' ) filterId : string ,
173+ ) : Promise < SuccessResponse > {
174+ const inputData : FindTableFilterByIdDs = {
175+ filter_id : filterId ,
176+ connection_id : connectionId ,
177+ } ;
178+ return await this . deleteTableFilterByIdUseCase . execute ( inputData , InTransactionEnum . ON ) ;
179+ }
129180}
0 commit comments