Skip to content

Commit

Permalink
Merge pull request #41 from TEAM-ITERVIEW/#40
Browse files Browse the repository at this point in the history
[feat] 면접 질문 스크랩 API
  • Loading branch information
cha2y0ung authored Mar 29, 2024
2 parents 6f781f3 + 1d650de commit 7fc25e6
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/controller/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as interviewController } from './interviewController';
export { default as userController } from './userController';
export { default as historyController } from './historyController';
export { default as historyController } from './historyController';
export { default as questionController } from './questionController';
22 changes: 22 additions & 0 deletions src/controller/questionController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Request, Response, NextFunction } from 'express';
import { message, statusCode } from '../module/constant';
import { success } from '../module/constant/utils';
import { questionService } from '../service';

const addPin = async (req: Request, res: Response, next: NextFunction) => {
const {interveiwQuestionId} = req.params;

try {
const data = await questionService.addPin(+interveiwQuestionId);

return res
.status(statusCode.CREATED)
.send(success(statusCode.CREATED, message.ADD_PIN_SUCCESS, data));
} catch (error) {
next(error);
}
};

export default {
addPin,
};
1 change: 1 addition & 0 deletions src/module/constant/responseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export default {
GET_INTERVIEWLIST_SUCCESS: "면접 기록 리스트 조회 성공",
GET_INTERVIEWDETAIL_SUCCESS: "면접 기록 상세 조회 성공",
DELETE_INTERVIEW_SUCCESS: "면접 기록 삭제 성공",
ADD_PIN_SUCCESS: "질문 스크랩 성공",
};
2 changes: 2 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { Router } from "express";
import interviewRouter from './interviewRouter';
import userRouter from "./userRouter";
import historyRouter from "./historyRouter";
import questionRouter from "./questionRouter";

const router: Router = Router();

router.use('/interview', interviewRouter);
router.use('/accounts', userRouter);
router.use('/history', historyRouter);
router.use('/question', questionRouter);

export default router;
17 changes: 17 additions & 0 deletions src/router/questionRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Router } from 'express';
import { body, header, param } from 'express-validator';
import { questionController } from '../controller';
import errorValidator from '../middleware/error/errorValidator';

const router: Router = Router();

router.patch(
'/:interviewQuestionId',
[
param('interveiwQuestionId').notEmpty(),
],
errorValidator,
questionController.addPin,
);

export default router;
3 changes: 2 additions & 1 deletion src/service/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as interviewService } from './interviewService';
export { default as userService } from './userService';
export { default as historyService } from './historyService';
export { default as historyService } from './historyService';
export { default as questionService } from './questionService';
24 changes: 24 additions & 0 deletions src/service/questionService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { PrismaClient } from '@prisma/client';
import errorGenerator from '../middleware/error/errorGenerator';
import { message, statusCode } from '../module/constant';
const prisma = new PrismaClient();

const addPin = async (interveiwQuestionId: number) => {
try {
const pin = await prisma.interviewQuestion.update({
where: {
id: interveiwQuestionId
},
data: {
pin: true,
}
});
return pin
} catch(error) {
throw error;
}
};

export default {
addPin,
};

0 comments on commit 7fc25e6

Please sign in to comment.