Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] 익명댓글 기능 추가 #186

Merged
merged 26 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c28cc9d
feat : isChecked 필드 추가
Daae-Kim Nov 26, 2024
4015d7e
feat : isChecked 필드 추가
Daae-Kim Nov 26, 2024
7217fbd
Merge branch 'develop' of https://github.com/JNU-econovation/EEOS-BE …
Daae-Kim Nov 26, 2024
95fafc8
feat : 익명 필드 추가
Daae-Kim Nov 28, 2024
2986e5b
feat : writer name 저장 로직 변경
Daae-Kim Nov 28, 2024
ad1b196
faet : isAnanymous 필드 추가
Daae-Kim Nov 28, 2024
aa8d18e
feat : Converter 필드 추가
Daae-Kim Nov 28, 2024
dc3695a
faet : commentService 추가
Daae-Kim Nov 28, 2024
fd39c14
feat : isAnanymous 필드 추가
Daae-Kim Nov 28, 2024
aed35b2
feat : isAnaymous 필드 추가
Daae-Kim Nov 28, 2024
be2a734
refactor: request.isAnonymous 로 수정
Nov 28, 2024
4bc357d
refactor: 코멘트 글자수 제한 삭제
Nov 28, 2024
6b11164
refactor: isAnonymous로 이름 변경
Nov 28, 2024
3f2457e
feat : 익명 상수화
Daae-Kim Nov 28, 2024
321976f
refactor : 변수명 수정
Daae-Kim Nov 28, 2024
2ca7e34
refactor : 변수명 수정
Daae-Kim Nov 28, 2024
0e34223
refactor : isAnonymous 변수명 수정
Daae-Kim Nov 28, 2024
4913448
Merge branch 'DD/feat/#179/anonymityComment' of https://github.com/JN…
Daae-Kim Nov 28, 2024
e54e342
refacotr: commentType enum 생성
Daae-Kim Nov 30, 2024
69957c9
refactor : createCommentRequest 필드명 변경
Daae-Kim Nov 30, 2024
463b769
refactor : 변수명 변경
Daae-Kim Nov 30, 2024
c5b0cb7
refactor : 필드명 변경
Daae-Kim Nov 30, 2024
5d41e95
refactor : 변수명 변경
Daae-Kim Nov 30, 2024
b04e751
refactor : 필드명 변경
Daae-Kim Nov 30, 2024
8fa41ba
refactor : 변수명 변경
Daae-Kim Nov 30, 2024
362ba46
chore : spotless 적용
Daae-Kim Nov 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.blackcompany.eeos.comment.application.dto;

import com.blackcompany.eeos.comment.application.model.CommentType;
import com.blackcompany.eeos.common.support.dto.AbstractRequestDto;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
Expand All @@ -17,4 +18,5 @@ public class CreateCommentRequest implements AbstractRequestDto {
private @NotNull Long teamId;
private @NotNull Long parentsCommentId;
private @NotNull String content;
private @NotNull CommentType commentType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.blackcompany.eeos.comment.application.dto.QueryCommentsResponse;
import com.blackcompany.eeos.comment.application.exception.NotConvertedCommentException;
import com.blackcompany.eeos.comment.application.model.CommentModel;
import com.blackcompany.eeos.comment.application.model.CommentType;
import com.blackcompany.eeos.member.application.exception.NotFoundMemberException;
import com.blackcompany.eeos.member.persistence.MemberRepository;
import java.time.format.DateTimeFormatter;
Expand All @@ -19,6 +20,7 @@
public class CommentResponseConverter {

private final MemberRepository memberRepository;
private final String ANONYMOUS_USER_NAME = "익명";

public CommandCommentResponse from(CommentModel source) {
return CommandCommentResponse.builder().commentId(source.getId()).build();
Expand All @@ -38,7 +40,7 @@ public QueryCommentResponse from(Long memberId, CommentModel source, List<Commen
.time(getCreateTimeString(source))
.content(source.getContent())
.teamId(source.getPresentingTeam())
.writer(findMemberName(source.getWriter()))
.writer(findMemberName(source.getWriter(), source))
.commentId(source.getId())
.accessRight(source.getAccessRight(memberId))
.answers(answersResponse)
Expand All @@ -51,14 +53,19 @@ private QueryAnswerResponse from(CommentModel source, Long memberId) {
QueryAnswerResponse.builder()
.commentId(source.getId())
.content(source.getContent())
.writer(findMemberName(source.getWriter()))
.writer(findMemberName(source.getWriter(), source))
.time(getCreateTimeString(source))
.accessRight(source.getAccessRight(memberId))
.build();
return response;
}

private String findMemberName(Long memberId) {
private String findMemberName(Long memberId, CommentModel source) {
System.out.println("writer : " + source.getWriter());
System.out.println("check : " + source.getCommentType());
if (source.getCommentType().equals(CommentType.ANONYMOUS)) {
return ANONYMOUS_USER_NAME;
}
return memberRepository.findById(memberId).orElseThrow(NotFoundMemberException::new).getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CommentModel implements AbstractModel {
private Timestamp updatedDate;
private String content;
private Long writer;
private CommentType commentType;

public String getAccessRight(Long memberId) {
if (isEdit(memberId)) return AccessRights.EDIT.getAccessRight();
Expand Down Expand Up @@ -59,7 +60,7 @@ private boolean isEdit(Long memberId) {
}

private boolean isExceedLengthLimit() {
return getContentLength() > contentLimitLength;
return false; // 코멘트 길이 수는 제한이 없다
}

private long getContentLength() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.blackcompany.eeos.comment.application.model;

public enum CommentType {
ANONYMOUS,
NON_ANONYMOUS,
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ public CommentModel from(CreateCommentRequest request) {
.superCommentId(request.getParentsCommentId())
.content(request.getContent())
.presentingTeam(request.getTeamId())
.commentType(request.getCommentType())
.build();
}

/*public CommentModel from(Long memberId,CreateCommentRequest request){
CommentModel model = from(request);
if(Boolean.TRUE.equals(model.getIsChecked())){
return model.toBuilder().writer(-1L).build();
}else{
return model.toBuilder().writer(memberId).build();
}
}*/

public CommentModel from(Long memberId, CreateCommentRequest request) {
return from(request).toBuilder().writer(memberId).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.blackcompany.eeos.comment.persistence;

import com.blackcompany.eeos.comment.application.model.CommentType;
import com.blackcompany.eeos.common.persistence.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
Expand Down Expand Up @@ -48,4 +51,8 @@ public class CommentEntity extends BaseEntity {

@Column(name = ENTITY_PREFIX + "_super_comment_id", nullable = false)
private Long superCommentId;

@Column(name = ENTITY_PREFIX + "_commentType", nullable = false)
@Enumerated(EnumType.STRING)
private CommentType commentType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public CommentEntity toEntity(CommentModel model) {
.writer(model.getWriter())
.presentingTeamId(model.getPresentingTeam())
.content(model.getContent())
.commentType(model.getCommentType())
.build();
}

@Override
public CommentModel from(CommentEntity entity) {

return CommentModel.builder()
.id(entity.getId())
.programId(entity.getProgramId())
Expand All @@ -31,6 +33,7 @@ public CommentModel from(CommentEntity entity) {
.updatedDate(entity.getUpdatedDate())
.content(entity.getContent())
.superCommentId(entity.getSuperCommentId())
.commentType(entity.getCommentType())
.build();
}
}
Loading