File tree Expand file tree Collapse file tree 10 files changed +1289
-170
lines changed
Expand file tree Collapse file tree 10 files changed +1289
-170
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import {
1010 Patch ,
1111 Post ,
1212 Query ,
13- Res ,
1413} from '@nestjs/common' ;
1514import {
1615 ApiCreatedResponse ,
@@ -19,8 +18,8 @@ import {
1918 ApiOperation ,
2019 ApiTags ,
2120} from '@nestjs/swagger' ;
22- import { Response } from 'express' ;
2321
22+ import { CountResult } from 'src/common' ;
2423import { ErrorCodes } from 'src/constants' ;
2524
2625import { CaptchaService } from './captcha.service' ;
@@ -62,11 +61,22 @@ export class CaptchaController {
6261 type : [ Captcha ] ,
6362 } )
6463 @Get ( )
65- async list ( @Query ( ) query : ListCaptchasQuery , @Res ( ) res : Response ) : Promise < CaptchaDocument [ ] > {
64+ list ( @Query ( ) query : ListCaptchasQuery ) : Promise < CaptchaDocument [ ] > {
65+ return this . captchaService . list ( query ) ;
66+ }
67+
68+ /**
69+ * Count captchas
70+ */
71+ @ApiOperation ( { operationId : 'countCaptchas' } )
72+ @ApiOkResponse ( {
73+ description : 'The count of captchas.' ,
74+ type : CountResult ,
75+ } )
76+ @Post ( '@count' )
77+ async count ( @Query ( ) query : ListCaptchasQuery ) : Promise < CountResult > {
6678 const count = await this . captchaService . count ( query ) ;
67- const data = await this . captchaService . list ( query ) ;
68- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
69- return data ;
79+ return { count } ;
7080 }
7181
7282 /**
Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ import {
1010 Patch ,
1111 Post ,
1212 Query ,
13- Req ,
14- Res ,
1513} from '@nestjs/common' ;
1614import {
1715 ApiCreatedResponse ,
@@ -22,8 +20,8 @@ import {
2220 ApiSecurity ,
2321 ApiTags ,
2422} from '@nestjs/swagger' ;
25- import { Request , Response } from 'express' ;
2623
24+ import { CountResult } from 'src/common' ;
2725import { ErrorCodes } from 'src/constants' ;
2826
2927import { CreateEmailRecordDto } from './dto/create-email-record.dto' ;
@@ -60,11 +58,22 @@ export class EmailRecordController {
6058 type : [ EmailRecord ] ,
6159 } )
6260 @Get ( )
63- async list ( @Req ( ) req : Request , @Query ( ) query : ListEmailRecordsQuery , @Res ( ) res : Response ) {
61+ list ( @Query ( ) query : ListEmailRecordsQuery ) {
62+ return this . emailRecordService . list ( query ) ;
63+ }
64+
65+ /**
66+ * Count email records
67+ */
68+ @ApiOperation ( { operationId : 'countEmailRecords' } )
69+ @ApiOkResponse ( {
70+ description : 'The count of email records.' ,
71+ type : CountResult ,
72+ } )
73+ @Post ( '@count' )
74+ async count ( @Query ( ) query : ListEmailRecordsQuery ) : Promise < CountResult > {
6475 const count = await this . emailRecordService . count ( query ) ;
65- const data = await this . emailRecordService . list ( query ) ;
66- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
67- return data ;
76+ return { count } ;
6877 }
6978
7079 /**
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import {
1111 Patch ,
1212 Post ,
1313 Query ,
14- Res ,
1514} from '@nestjs/common' ;
1615import {
1716 ApiBearerAuth ,
@@ -22,8 +21,8 @@ import {
2221 ApiParam ,
2322 ApiTags ,
2423} from '@nestjs/swagger' ;
25- import { Response } from 'express' ;
2624
25+ import { CountResult } from 'src/common/entities/count.entity' ;
2726import { ErrorCodes } from 'src/constants' ;
2827import { NamespaceService } from 'src/namespace' ;
2928
@@ -74,11 +73,22 @@ export class GroupController {
7473 type : [ Group ] ,
7574 } )
7675 @Get ( )
77- async list ( @Query ( ) query : ListGroupsQuery , @Res ( ) res : Response ) : Promise < GroupDocument [ ] > {
76+ list ( @Query ( ) query : ListGroupsQuery ) : Promise < GroupDocument [ ] > {
77+ return this . groupService . list ( query ) ;
78+ }
79+
80+ /**
81+ * Count groups
82+ */
83+ @ApiOperation ( { operationId : 'countGroups' } )
84+ @ApiOkResponse ( {
85+ description : 'The result of count groups.' ,
86+ type : CountResult ,
87+ } )
88+ @Post ( '@count' )
89+ async count ( @Query ( ) query : ListGroupsQuery ) : Promise < CountResult > {
7890 const count = await this . groupService . count ( query ) ;
79- const data = await this . groupService . list ( query ) ;
80- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
81- return data ;
91+ return { count } ;
8292 }
8393
8494 /**
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import {
1212 Patch ,
1313 Post ,
1414 Query ,
15- Res ,
1615 UseInterceptors ,
1716} from '@nestjs/common' ;
1817import {
@@ -24,9 +23,8 @@ import {
2423 ApiSecurity ,
2524 ApiTags ,
2625} from '@nestjs/swagger' ;
27- import { Response } from 'express' ;
2826
29- import { SetCacheInterceptor , UnsetCacheInterceptor } from 'src/common' ;
27+ import { CountResult , SetCacheInterceptor , UnsetCacheInterceptor } from 'src/common' ;
3028import { ErrorCodes } from 'src/constants' ;
3129
3230import { CreateNamespaceDto } from './dto/create-namespace.dto' ;
@@ -97,14 +95,22 @@ export class NamespaceController {
9795 type : [ Namespace ] ,
9896 } )
9997 @Get ( )
100- async list (
101- @Query ( ) query : ListNamespacesQuery ,
102- @Res ( ) res : Response
103- ) : Promise < NamespaceDocument [ ] > {
98+ list ( @Query ( ) query : ListNamespacesQuery ) : Promise < NamespaceDocument [ ] > {
99+ return this . namespaceService . list ( query ) ;
100+ }
101+
102+ /**
103+ * Count namespaces
104+ */
105+ @ApiOperation ( { operationId : 'countNamespaces' } )
106+ @ApiOkResponse ( {
107+ description : 'The result of count namespaces.' ,
108+ type : CountResult ,
109+ } )
110+ @Post ( '@count' )
111+ async count ( @Query ( ) query : ListNamespacesQuery ) : Promise < CountResult > {
104112 const count = await this . namespaceService . count ( query ) ;
105- const data = await this . namespaceService . list ( query ) ;
106- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
107- return data ;
113+ return { count } ;
108114 }
109115
110116 /**
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import {
1111 Patch ,
1212 Post ,
1313 Query ,
14- Res ,
1514} from '@nestjs/common' ;
1615import {
1716 ApiCreatedResponse ,
@@ -22,8 +21,8 @@ import {
2221 ApiSecurity ,
2322 ApiTags ,
2423} from '@nestjs/swagger' ;
25- import { Response } from 'express' ;
2624
25+ import { CountResult } from 'src/common/entities/count.entity' ;
2726import { ErrorCodes } from 'src/constants' ;
2827
2928import { CreateRoleDto } from './dto/create-role.dto' ;
@@ -70,11 +69,22 @@ export class RoleController {
7069 type : [ Role ] ,
7170 } )
7271 @Get ( )
73- async list ( @Query ( ) query : ListRolesQuery , @Res ( ) res : Response ) : Promise < RoleDocument [ ] > {
72+ list ( @Query ( ) query : ListRolesQuery ) : Promise < RoleDocument [ ] > {
73+ return this . roleService . list ( query ) ;
74+ }
75+
76+ /**
77+ * Count roles
78+ */
79+ @ApiOperation ( { operationId : 'countRoles' } )
80+ @ApiOkResponse ( {
81+ description : 'The result of count roles.' ,
82+ type : CountResult ,
83+ } )
84+ @Post ( '@count' )
85+ async count ( @Query ( ) query : ListRolesQuery ) : Promise < CountResult > {
7486 const count = await this . roleService . count ( query ) ;
75- const data = await this . roleService . list ( query ) ;
76- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
77- return data ;
87+ return { count } ;
7888 }
7989
8090 /**
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import {
1010 Patch ,
1111 Post ,
1212 Query ,
13- Res ,
1413} from '@nestjs/common' ;
1514import { JwtService } from '@nestjs/jwt' ;
1615import {
@@ -21,8 +20,8 @@ import {
2120 ApiSecurity ,
2221 ApiTags ,
2322} from '@nestjs/swagger' ;
24- import { Response } from 'express' ;
2523
24+ import { CountResult } from 'src/common' ;
2625import { ErrorCodes } from 'src/constants' ;
2726
2827import { CreateSessionDto } from './dto/create-session.dto' ;
@@ -62,11 +61,22 @@ export class SessionController {
6261 type : [ Session ] ,
6362 } )
6463 @Get ( )
65- async list ( @Query ( ) query : ListSessionsQuery , @Res ( ) res : Response ) : Promise < Session [ ] > {
64+ list ( @Query ( ) query : ListSessionsQuery ) : Promise < Session [ ] > {
65+ return this . sessionService . list ( query ) ;
66+ }
67+
68+ /**
69+ * Count sessions
70+ */
71+ @ApiOperation ( { operationId : 'countSessions' } )
72+ @ApiOkResponse ( {
73+ description : 'The count of sessions.' ,
74+ type : CountResult ,
75+ } )
76+ @Post ( '@count' )
77+ async count ( @Query ( ) query : ListSessionsQuery ) : Promise < CountResult > {
6678 const count = await this . sessionService . count ( query ) ;
67- const data = await this . sessionService . list ( query ) ;
68- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
69- return data ;
79+ return { count } ;
7080 }
7181
7282 /**
Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import {
1010 Patch ,
1111 Post ,
1212 Query ,
13- Res ,
1413} from '@nestjs/common' ;
1514import {
1615 ApiCreatedResponse ,
@@ -21,8 +20,8 @@ import {
2120 ApiSecurity ,
2221 ApiTags ,
2322} from '@nestjs/swagger' ;
24- import { Response } from 'express' ;
2523
24+ import { CountResult } from 'src/common/entities/count.entity' ;
2625import { ErrorCodes } from 'src/constants' ;
2726
2827import { CreateSmsRecordDto } from './dto/create-sms-record.dto' ;
@@ -59,11 +58,22 @@ export class SmsRecordController {
5958 type : [ SmsRecord ] ,
6059 } )
6160 @Get ( )
62- async list ( @Query ( ) query : ListSmsRecordsQuery , @Res ( ) res : Response ) {
61+ list ( @Query ( ) query : ListSmsRecordsQuery ) {
62+ return this . smsRecordService . list ( query ) ;
63+ }
64+
65+ /**
66+ * Count sms records
67+ */
68+ @ApiOperation ( { operationId : 'countSmsRecords' } )
69+ @ApiOkResponse ( {
70+ description : 'The count of sms records.' ,
71+ type : CountResult ,
72+ } )
73+ @Post ( '@count' )
74+ async count ( @Query ( ) query : ListSmsRecordsQuery ) : Promise < CountResult > {
6375 const count = await this . smsRecordService . count ( query ) ;
64- const data = await this . smsRecordService . list ( query ) ;
65- res . set ( { 'X-Total-Count' : count . toString ( ) } ) . json ( data ) ;
66- return data ;
76+ return { count } ;
6777 }
6878
6979 /**
Original file line number Diff line number Diff line change @@ -8,11 +8,10 @@ import {
88 Patch ,
99 Post ,
1010 Query ,
11- Res ,
1211} from '@nestjs/common' ;
1312import { ApiCreatedResponse , ApiOperation , ApiTags } from '@nestjs/swagger' ;
14- import { Response } from 'express' ;
1513
14+ import { CountResult } from 'src/common' ;
1615import { ErrorCodes } from 'src/constants' ;
1716import { UserService } from 'src/user' ;
1817
@@ -53,14 +52,22 @@ export class ThirdPartyController {
5352 type : [ ThirdParty ] ,
5453 } )
5554 @Get ( )
56- async list (
57- @Query ( ) query : ListThirdPartyQuery ,
58- @Res ( ) res : Response
59- ) : Promise < ThirdPartyDocument [ ] > {
55+ list ( @Query ( ) query : ListThirdPartyQuery ) : Promise < ThirdPartyDocument [ ] > {
56+ return this . thirdPartyService . list ( query ) ;
57+ }
58+
59+ /**
60+ * Count third party
61+ */
62+ @ApiOperation ( { operationId : 'countThirdParty' } )
63+ @ApiCreatedResponse ( {
64+ description : 'The third party record count.' ,
65+ type : CountResult ,
66+ } )
67+ @Post ( '@count' )
68+ async count ( @Query ( ) query : ListThirdPartyQuery ) : Promise < CountResult > {
6069 const count = await this . thirdPartyService . count ( query ) ;
61- const data = await this . thirdPartyService . list ( query ) ;
62- res . set ( 'X-Total-Count' , count . toString ( ) ) . json ( data ) ;
63- return data ;
70+ return { count } ;
6471 }
6572
6673 /**
You can’t perform that action at this time.
0 commit comments