From bd465c952fd2de2f7a3e722cd0bd650e2acf62bc Mon Sep 17 00:00:00 2001 From: NguyenTrongQuan <112452601+hapo-quannt@users.noreply.github.com> Date: Sun, 2 Apr 2023 23:17:09 +0700 Subject: [PATCH] make question-type --- src/app.module.ts | 2 ++ .../question-type.controller.spec.ts | 18 ++++++++++++++++++ .../question-type/question-type.controller.ts | 16 ++++++++++++++++ .../question-type/question-type.module.ts | 12 ++++++++++++ .../question-type.service.spec.ts | 18 ++++++++++++++++++ .../question-type/question-type.service.ts | 4 ++++ src/components/users/users.controller.ts | 1 - src/entities/index.ts | 3 ++- src/entities/question-type.ts | 14 ++++++++++++++ 9 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/components/question-type/question-type.controller.spec.ts create mode 100644 src/components/question-type/question-type.controller.ts create mode 100644 src/components/question-type/question-type.module.ts create mode 100644 src/components/question-type/question-type.service.spec.ts create mode 100644 src/components/question-type/question-type.service.ts create mode 100644 src/entities/question-type.ts diff --git a/src/app.module.ts b/src/app.module.ts index c52856d..ca63dd6 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -13,6 +13,7 @@ import { ProfileModule } from './components/profile/profile.module'; import { MailerModule } from '@nest-modules/mailer'; import config from './config'; import { HandlebarsAdapter } from '@nest-modules/mailer'; +import { QuestionTypeModule } from './components/question-type/question-type.module'; @Module({ imports: [ AdminModule, @@ -27,6 +28,7 @@ import { HandlebarsAdapter } from '@nest-modules/mailer'; MulterModule.register({ dest: './files/upload', }), + QuestionTypeModule, ], }) export class AppModule {} diff --git a/src/components/question-type/question-type.controller.spec.ts b/src/components/question-type/question-type.controller.spec.ts new file mode 100644 index 0000000..a41c326 --- /dev/null +++ b/src/components/question-type/question-type.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { QuestionTypeController } from './question-type.controller'; + +describe('QuestionTypeController', () => { + let controller: QuestionTypeController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [QuestionTypeController], + }).compile(); + + controller = module.get(QuestionTypeController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/src/components/question-type/question-type.controller.ts b/src/components/question-type/question-type.controller.ts new file mode 100644 index 0000000..6d0d9ad --- /dev/null +++ b/src/components/question-type/question-type.controller.ts @@ -0,0 +1,16 @@ +import { Controller, Post } from '@nestjs/common'; +import { ApiTags } from '@nestjs/swagger'; +import { QuestionTypeService } from './question-type.service'; + +@ApiTags('question-type') +@Controller('api/question-type') +export class QuestionTypeController { + constructor( + private readonly questionTypeService: QuestionTypeService + ) {}; + + @Post() + async create() { + return 1; + } +} diff --git a/src/components/question-type/question-type.module.ts b/src/components/question-type/question-type.module.ts new file mode 100644 index 0000000..28dc8ae --- /dev/null +++ b/src/components/question-type/question-type.module.ts @@ -0,0 +1,12 @@ +import { Module } from '@nestjs/common'; +import { QuestionTypeController } from './question-type.controller'; +import { QuestionTypeService } from './question-type.service'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { QuestionType } from 'src/entities'; + +@Module({ + imports: [TypeOrmModule.forFeature([QuestionType])], + controllers: [QuestionTypeController], + providers: [QuestionTypeService] +}) +export class QuestionTypeModule {} diff --git a/src/components/question-type/question-type.service.spec.ts b/src/components/question-type/question-type.service.spec.ts new file mode 100644 index 0000000..9ee09ec --- /dev/null +++ b/src/components/question-type/question-type.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { QuestionTypeService } from './question-type.service'; + +describe('QuestionTypeService', () => { + let service: QuestionTypeService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [QuestionTypeService], + }).compile(); + + service = module.get(QuestionTypeService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/components/question-type/question-type.service.ts b/src/components/question-type/question-type.service.ts new file mode 100644 index 0000000..b4bbcd1 --- /dev/null +++ b/src/components/question-type/question-type.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class QuestionTypeService {} diff --git a/src/components/users/users.controller.ts b/src/components/users/users.controller.ts index 0e6f14c..54118b6 100644 --- a/src/components/users/users.controller.ts +++ b/src/components/users/users.controller.ts @@ -73,7 +73,6 @@ export class UsersController { return this.userService.updatePassword(Number(id), body.password, authUser); } - @ApiBearerAuth() @Post() create(@Body() body: CreateNewUser) { return this.userService.create(body); diff --git a/src/entities/index.ts b/src/entities/index.ts index 0190cfb..40cc11a 100644 --- a/src/entities/index.ts +++ b/src/entities/index.ts @@ -1,2 +1,3 @@ export * from './user.entity'; -export * from './profile.entity'; \ No newline at end of file +export * from './profile.entity'; +export * from './question-type'; \ No newline at end of file diff --git a/src/entities/question-type.ts b/src/entities/question-type.ts new file mode 100644 index 0000000..3f4ba98 --- /dev/null +++ b/src/entities/question-type.ts @@ -0,0 +1,14 @@ +import { Entity, PrimaryGeneratedColumn } from "typeorm"; +import { ColumnDate, ColumnPhone, ColumnString, ColumnText, ColumnTinyInt } from "./columns"; + +@Entity('question-type') +export class QuestionType { + @PrimaryGeneratedColumn() + id: number; + + @ColumnString() + name: string; + + @ColumnText() + description: string; +}