Skip to content

Commit

Permalink
list apply
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh000526 committed Jun 24, 2024
1 parent 4c528ff commit fc57f20
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/example/just/Service/CommentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public Comment createComment(Long postId, Long member_id, CommentDto commentDto)
Member member = memberRepository.findById(member_id).orElseGet(() -> new Member());
//댓글 객체 생성
Comment comment = new Comment();
List<String> list = new ArrayList<>();
list.add(commentDto.getComment_content().strip());
//비식별화 진행
List<String> content = getConvertString(commentDto.getComment_content().strip());
List<String> content = getConvertString(list);
comment.setComment_content(content.get(0));
comment.setPost(post);
comment.setMember(member);
Expand Down Expand Up @@ -326,12 +328,17 @@ public List<Comment> getAllComments() {
return commentRepository.findAll();
}

public List<String> getConvertString(String str) { // 문자열 변환
public List<String> getConvertString(List<String> str) { // 문자열 변환
RestTemplate restTemplate = new RestTemplate();

String requestBody = "{\"content\": [";

requestBody += "\"" + str+"\", ";
for(int i=0;i<str.size();i++){
requestBody += "\"" + str.get(i)+"\"";
if(i==str.size()){
requestBody += ", ";
}
}
requestBody += "]}";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Expand Down

0 comments on commit fc57f20

Please sign in to comment.