Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/kau-qj/backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ParkJunGyu26 committed Dec 10, 2023
2 parents 8d81c2d + 42e7b84 commit 49b676d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/config/swagger/board.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ tags:
result:
{
"userId": "csb",
"nickName": "슈빈",
"Title": "삼성전자 채용 언제 하나요?",
"mainText": "안녕하세요! 2024년 상반기 공채 언제 열리는지 아시는 분 계시나요?",
"createAt": "2023-12-02T09:46:00.000Z",
Expand All @@ -92,6 +93,7 @@ tags:
"CommentIdx": 15,
"PostIdx": 24,
"userId": "csb",
"nickName": "슈빈",
"contents": "1월 8일 입니다!",
"createAt": "2023-12-02T09:51:31.000Z",
},
Expand Down
4 changes: 3 additions & 1 deletion src/controller/boardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ exports.getPost = async function (req, res) {

// 게시글 조회
const post = await boardProvider.retrievePost(PostIdx);
// 게시글 작성자, 제목, 내용, 작성 시간, 댓글 가져오기
// 게시글 작성자, 작성자 닉네임, 제목, 내용, 작성 시간, 댓글 가져오기
const postDetails = {
userId: post[0].userId,
nickName: post[0].nickName,
Title: post[0].Title,
mainText: post[0].mainText,
createAt: post[0].createAt,
Expand All @@ -56,6 +57,7 @@ exports.getPost = async function (req, res) {
return res.send(response(baseResponse.SUCCESS, postDetails));
};


// 게시글 수정
exports.updatePost = async function (req, res) {
const {PostIdx} = req.params;
Expand Down
11 changes: 7 additions & 4 deletions src/dao/boardDao.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ async function selectPosts(connection, postType) {
// 게시글 상세보기
async function getPost(connection, PostIdx) {
const getPostQuery = `
SELECT userId, Title, mainText, createAt
SELECT Board.userId, User.nickName, Board.Title, Board.mainText, Board.createAt
FROM Board
WHERE PostIdx = ?;
INNER JOIN User ON Board.userId = User.userId
WHERE Board.PostIdx = ?;
`;
const [postRow] = await connection.query(getPostQuery, PostIdx);
return postRow;
Expand All @@ -37,14 +38,16 @@ async function getPost(connection, PostIdx) {
// 게시글에 대한 댓글 조회
async function selectComments(connection, PostIdx) {
const selectCommentsQuery = `
SELECT CommentIdx, PostIdx, userId, contents, createAt
SELECT Comment.CommentIdx, Comment.PostIdx, Comment.userId, User.nickName, Comment.contents, Comment.createAt
FROM Comment
WHERE PostIdx = ?;
INNER JOIN User ON Comment.userId = User.userId
WHERE Comment.PostIdx = ?;
`;
const [commentsRows] = await connection.query(selectCommentsQuery, PostIdx);
return commentsRows;
}


// 게시글 작성자 조회
async function selectPostUserId(connection, postIdx) {
const selectPostUserIdQuery = `
Expand Down

0 comments on commit 49b676d

Please sign in to comment.