Skip to content

Commit

Permalink
feat: 컨트롤러 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
JangAJang committed Nov 20, 2023
1 parent 3bdc6d9 commit 9685bb8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
28 changes: 27 additions & 1 deletion BE/src/question/controller/question.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Body, Controller, Post, Req, UseGuards } from '@nestjs/common';
import {
Body,
Controller,
Get,
Post,
Query,
Req,
UseGuards,
} from '@nestjs/common';
import { QuestionService } from '../service/question.service';
import { CreateQuestionRequest } from '../dto/createQuestionRequest';
import { Request } from 'express';
Expand All @@ -13,6 +21,7 @@ import {
import { createApiResponseOption } from '../../util/swagger.util';
import { QuestionResponse } from '../dto/questionResponse';
import { Member } from '../../member/entity/member';
import { QuestionResponseList } from '../dto/questionResponseList';

@ApiTags('question')
@Controller('/api/question')
Expand All @@ -38,4 +47,21 @@ export class QuestionController {
req.user as Member,
);
}

@Get()
@ApiOperation({
summary: '카테고리별 질문 리스트 조회',
})
@ApiResponse(
createApiResponseOption(
200,
'QuestionResponse 리스트',
QuestionResponseList,
),
)
async findCategoryQuestions(@Query('category') categoryId: number) {
const questionResponses =
await this.questionService.findAllByCategory(categoryId);
return QuestionResponseList.of(questionResponses);
}
}
13 changes: 13 additions & 0 deletions BE/src/question/dto/questionResponseList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { QuestionResponse } from './questionResponse';

export class QuestionResponseList {
questionResponses: QuestionResponse[];

constructor(questionResponses: QuestionResponse[]) {
this.questionResponses = questionResponses;
}

static of(questionResponses: QuestionResponse[]) {
return new QuestionResponseList(questionResponses);
}
}

0 comments on commit 9685bb8

Please sign in to comment.