-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 댓글 목록 #12
- Loading branch information
DESKTOP-I633S8U\user
committed
Mar 29, 2023
1 parent
4f01669
commit 647b507
Showing
7 changed files
with
112 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 27 additions & 2 deletions
29
src/main/java/com/hsp/hoicegram/post/comment/bo/CommentBO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,49 @@ | ||
package com.hsp.hoicegram.post.comment.bo; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.hsp.hoicegram.post.comment.dao.CommentDAO; | ||
import com.hsp.hoicegram.post.comment.model.Comment; | ||
import com.hsp.hoicegram.post.comment.model.CommentDetail; | ||
import com.hsp.hoicegram.user.bo.UserBO; | ||
import com.hsp.hoicegram.user.model.User; | ||
|
||
@Service | ||
public class CommentBO { | ||
|
||
@Autowired | ||
private CommentDAO commentDAO; | ||
|
||
@Autowired | ||
private UserBO userBO; | ||
|
||
public int addComment(int userId, int postId, String content) { | ||
return commentDAO.insertComment(userId, postId, content); | ||
} | ||
|
||
public Comment getComment(int userId, int postId) { | ||
return commentDAO.selectComment(userId, postId); | ||
public List<CommentDetail> getCommentList(int postId) { | ||
|
||
List<Comment> commentList = commentDAO.selectCommentList(postId); | ||
List<CommentDetail> commentDetailList = new ArrayList<>(); | ||
|
||
|
||
for(Comment comment:commentList) { | ||
|
||
User user = userBO.getUserById(comment.getUserId()); | ||
|
||
CommentDetail commentDetail = new CommentDetail(); | ||
commentDetail.setId(comment.getId()); | ||
commentDetail.setUserNickname(user.getNickname()); | ||
commentDetail.setContent(comment.getContent()); | ||
commentDetailList.add(commentDetail); | ||
} | ||
|
||
return commentDetailList; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/hsp/hoicegram/post/comment/model/CommentDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.hsp.hoicegram.post.comment.model; | ||
|
||
public class CommentDetail { // comment에 없는 필요한 변수들 가져오기 | ||
|
||
private int id; | ||
private int userId; | ||
private String userNickname; | ||
private String content; | ||
|
||
|
||
public int getId() { | ||
return id; | ||
} | ||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
public int getUserId() { | ||
return userId; | ||
} | ||
public void setUserId(int userId) { | ||
this.userId = userId; | ||
} | ||
public String getUserNickname() { | ||
return userNickname; | ||
} | ||
public void setUserNickname(String userNickname) { | ||
this.userNickname = userNickname; | ||
} | ||
public String getContent() { | ||
return content; | ||
} | ||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
|
||
|
||
} |
23 changes: 15 additions & 8 deletions
23
src/main/java/com/hsp/hoicegram/post/model/PostDetail.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters