-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dev-callgent <dev@callgent.com>
- Loading branch information
1 parent
1822b22
commit bff6ed9
Showing
16 changed files
with
191 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { CallgentHubController } from './callgent-hub.controller'; | ||
|
||
describe('CallgentHubController', () => { | ||
let controller: CallgentHubController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [CallgentHubController], | ||
}).compile(); | ||
|
||
controller = module.get<CallgentHubController>(CallgentHubController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Controller, Get, Query } from '@nestjs/common'; | ||
import { | ||
ApiOkResponse, | ||
ApiQuery, | ||
ApiTags, | ||
getSchemaPath, | ||
} from '@nestjs/swagger'; | ||
import { CallgentsService } from '../../callgents/callgents.service'; | ||
import { CallgentDto } from '../../callgents/dto/callgent.dto'; | ||
import { RestApiResponse } from '../../restapi/response.interface'; | ||
|
||
@ApiTags('Hub') | ||
@Controller('hub') | ||
export class CallgentHubController { | ||
constructor(private readonly callgentService: CallgentsService) {} | ||
|
||
@ApiQuery({ name: 'query', required: false, type: String }) | ||
@ApiQuery({ name: 'page', required: false, type: Number }) | ||
@ApiQuery({ name: 'perPage', required: false, type: Number }) | ||
@ApiOkResponse({ | ||
schema: { | ||
anyOf: [ | ||
{ $ref: getSchemaPath(RestApiResponse) }, | ||
{ | ||
properties: { | ||
data: { | ||
type: 'array', | ||
items: { $ref: getSchemaPath(CallgentDto) }, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}) | ||
@Get('callgents') | ||
async findAll( | ||
@Query() | ||
query: { | ||
queryString?: string; | ||
page?: 1; | ||
perPage?: 10; | ||
// TODO orderBy?: string; | ||
}, | ||
) { | ||
const where = query.queryString | ||
? { | ||
name: { contains: query.queryString }, | ||
} | ||
: undefined; | ||
const list = await this.callgentService.findAllInHub({ | ||
page: query.page, | ||
perPage: query.perPage, | ||
where, | ||
// orderBy, | ||
}); | ||
list.data?.forEach((item: any) => (item.children = [])); | ||
return list; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { CallgentsModule } from '../../callgents/callgents.module'; | ||
import { CallgentHubController } from './callgent-hub.controller'; | ||
|
||
@Module({ | ||
imports: [CallgentsModule], | ||
controllers: [CallgentHubController], | ||
}) | ||
export class CallgentHubModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters