Skip to content

Commit

Permalink
Merge pull request #57 from kau-qj/user
Browse files Browse the repository at this point in the history
add board, comment nickName
  • Loading branch information
ckzer authored Dec 6, 2023
2 parents 8dd9936 + 87d2093 commit ba63bd0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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 ba63bd0

Please sign in to comment.