Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FEAT] 질문 모델에 태그 추가 #215

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/controllers/mind23Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import statusCode from '../modules/statusCode';
import util from '../modules/util';
import { Mind23Service } from '../services';
import { Types } from 'mongoose';
import { QuestionDto } from '../intefaces/mind23/QuestionDto';
import { QuestionResponseDto } from '../intefaces/mind23/QuestionResponseDto';
import { TypedRequest } from '../types/TypedRequest';

Expand Down Expand Up @@ -64,7 +63,7 @@ const getCommentList = async (
* @access Public
*/
const createComment = async (
req: Request,
req: TypedRequest<{ content: string }, any, { questionId: string }>,
res: Response,
next: NextFunction
) => {
Expand All @@ -89,13 +88,13 @@ const createComment = async (
* @access Public
*/
const createPrizeEntry = async (
req: Request,
req: TypedRequest<{ prizeEntryStatus: boolean }>,
res: Response,
next: NextFunction
) => {
try {
const userId: Types.ObjectId | undefined = req.user?.id;
const prizeEntryStatus: Boolean = req.body.prizeEntryStatus;
const prizeEntryStatus: boolean = req.body.prizeEntryStatus;
await Mind23Service.createPrizeEntry(userId, prizeEntryStatus);
return res
.status(statusCode.OK)
Expand Down
4 changes: 2 additions & 2 deletions src/models/mind23/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import IDocument from '../interface/Document';

interface IQuestion {
content: string;
essential: Boolean;
tags: string[];
}

type QuestionDocument = IQuestion & IDocument;

const questionSchema = new Schema<QuestionDocument>({
content: String,
essential: Boolean
tags: [String]
});

const Question = model<QuestionDocument>('Question', questionSchema);
Expand Down
7 changes: 3 additions & 4 deletions src/services/mind23Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const createCardResponse = (
return {
_id: question._id,
content: question.content,
tags: [],
tags: question.tags,
category: [],
filter: [],
isBookmark: false
Expand All @@ -33,7 +33,7 @@ const createCardResponse = (
const checkCommentStatus = (
authorId: Types.ObjectId,
userId?: Types.ObjectId
): Boolean => {
): boolean => {
if (!userId) {
return false;
}
Expand Down Expand Up @@ -101,12 +101,11 @@ const createComment = async (

const createPrizeEntry = async (
userId?: Types.ObjectId,
prizeEntryStatus?: Boolean
prizeEntryStatus?: boolean
) => {
if (!userId) {
throw new IllegalArgumentException('해당하는 아이디의 유저가 없습니다.');
}
console.log(prizeEntryStatus);
const prizeEntry = new PrizeEntry({
user: userId,
prizeEntryStatus: prizeEntryStatus
Expand Down
4 changes: 2 additions & 2 deletions src/types/TypedRequest.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request } from 'express';

export type TypedRequest<ReqB = any, ReqQ = any> = Request<
any,
export type TypedRequest<ReqB = any, ReqQ = any, P = any> = Request<
P,
any,
ReqB,
ReqQ
Expand Down