Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ccfd040
CLAP-177 feat: 댓글 작성 기능 구현(첨부 파일이 아닌 일반 댓글)
starboxxxx Jan 30, 2025
54842f2
CLAP-177 fix: rebase하며 발생한 오류 해결
starboxxxx Jan 30, 2025
64772a2
CLAP-177 feat: 댓글 작성 기능 구현(첨부 파일)
starboxxxx Jan 30, 2025
a6cb457
CLAP-177 feat: 댓글 작성시 taskHistory에 해당 내용 추가
starboxxxx Jan 30, 2025
9147284
CLAP-177 feat: 댓글 작성시 taskHistory에 해당 내용 추가2
starboxxxx Jan 30, 2025
ef44e6e
CLAP-177 feat: 댓글 작성 기능 구현(첨부 파일이 아닌 일반 댓글)
starboxxxx Jan 30, 2025
39c3893
CLAP-177 fix: rebase하며 발생한 오류 해결
starboxxxx Jan 30, 2025
fa35371
CLAP-177 feat: 댓글 작성 기능 구현(첨부 파일)
starboxxxx Jan 30, 2025
bdae98d
CLAP-177 feat: 댓글 작성시 taskHistory에 해당 내용 추가
starboxxxx Jan 30, 2025
69c86d2
CLAP-177 feat: 댓글 작성시 taskHistory에 해당 내용 추가2
starboxxxx Jan 30, 2025
fa2bcc3
CLAP-172 Feat: 웹훅 및 이메일 알림 설정에 대한 필드 추가
joowojr Jan 29, 2025
83cf3ba
CLAP-172 Fix: port를 호출하도록 수정
joowojr Jan 30, 2025
3f046b1
CLAP-172 Feat: 회원 정보 수정 API 구현
joowojr Jan 30, 2025
d2abfa5
CLAP-172 Feat: 첨부파일에 관한 에러코드 클래스명 수정
joowojr Jan 30, 2025
58d7fad
CLAP-172 Feat: 이미지가 null 또는 empty일 때 예외처리
joowojr Jan 30, 2025
2bc0139
CLAP-172 Feat: merge conflict slove
joowojr Jan 30, 2025
a9abb75
CLAP-172 Remove: 불필요한 코드 제거
joowojr Jan 30, 2025
8169c60
Update MemberErrorCode.java
starboxxxx Jan 30, 2025
d700fc4
CLAP-181 feat: 일반 댓글 수정 API 구현
starboxxxx Jan 30, 2025
1173db5
CLAP-181 feat: 댓글 삭제 API 구현
starboxxxx Jan 30, 2025
ca5a1df
CLAP-181 feat: 댓글 삭제 API 구현
starboxxxx Jan 30, 2025
2d08773
CLAP-181 fix: build 에러 해결
starboxxxx Jan 30, 2025
84d3a50
CLAP-172 Remove: 알림 설정 엔티티 삭제
joowojr Jan 29, 2025
a8703ca
CLAP-172 Feat: 웹훅 및 이메일 알림 설정에 대한 필드 추가
joowojr Jan 29, 2025
11d1eae
CLAP-172 Refactor: usecase 세분화
joowojr Jan 30, 2025
d3f6ffc
CLAP-172 Config: apache tika 의존성 추가
joowojr Jan 30, 2025
65aabf7
CLAP-172 Config: 이미지 파일인지 검증하는 유틸 클래스 생성
joowojr Jan 30, 2025
d614fea
CLAP-172 Feat: 회원 정보 상세 조회 API 구현
joowojr Jan 30, 2025
6d9bbc5
CLAP-172 Feat: 관리자 회원 정보 수정 메서드 이름 변경
joowojr Jan 30, 2025
be08762
CLAP-172 Rename: 클래스명 수정
joowojr Jan 30, 2025
331175e
CLAP-172 Feat: 회원 정보 수정 API 구현
joowojr Jan 30, 2025
429cca2
CLAP-172 Feat: 첨부파일에 관한 에러코드 클래스명 수정
joowojr Jan 30, 2025
f43888f
CLAP-172 Rename: 클래스명 수정
joowojr Jan 30, 2025
dc91f9a
CLAP-172 Feat: 회원 등록과정에 알림 설정 로직 추가
joowojr Jan 30, 2025
d22d735
CLAP-172 Fix: 오타 수정
joowojr Jan 30, 2025
aae1239
CLAP-172 Rename: dto명 수정
joowojr Jan 30, 2025
add9ac7
CLAP-172 Feat: 이미지가 null 또는 empty일 때 예외처리
joowojr Jan 30, 2025
3bab8e4
CLAP-172 Feat: 파일을 선택적으로 받도록 수정
joowojr Jan 30, 2025
750e89a
CLAP-172 Feat: 회원 정보 수정 API 구현
joowojr Jan 30, 2025
a7e55d1
CLAP-172 Remove: 불필요한 코드 제거
joowojr Jan 30, 2025
b05b202
CLAP-156 Config: dev db 설정 수정
joowojr Jan 30, 2025
4175984
CLAP-156 Style: 컬럼 수정
joowojr Jan 30, 2025
5fdfac9
CLAP-156 Style: 컬럼 네이밍 수정으로 인한 변경 사항
joowojr Jan 30, 2025
d8fb01d
CLAP-156 Style: API Path 통일
joowojr Jan 30, 2025
54e4b1a
CLAP-172 Feat: 웹훅 및 이메일 알림 설정에 대한 필드 추가
joowojr Jan 29, 2025
656538d
CLAP-172 Fix: port를 호출하도록 수정
joowojr Jan 30, 2025
0aac98d
CLAP-172 Feat: 회원 정보 수정 API 구현
joowojr Jan 30, 2025
eea79c7
CLAP-172 Feat: 첨부파일에 관한 에러코드 클래스명 수정
joowojr Jan 30, 2025
082d7a6
CLAP-172 Feat: 이미지가 null 또는 empty일 때 예외처리
joowojr Jan 30, 2025
9fbd809
CLAP-172 Feat: merge conflict slove
joowojr Jan 30, 2025
526cbbe
CLAP-172 Remove: 불필요한 코드 제거
joowojr Jan 30, 2025
22486ce
Update MemberErrorCode.java
starboxxxx Jan 30, 2025
f8022cf
CLAP-181 feat: 일반 댓글 수정 API 구현
starboxxxx Jan 30, 2025
c3d1e60
CLAP-181 feat: 댓글 삭제 API 구현
starboxxxx Jan 30, 2025
ae6fd23
CLAP-181 feat: 댓글 삭제 API 구현
starboxxxx Jan 30, 2025
44a611a
CLAP-181 fix: build 에러 해결
starboxxxx Jan 30, 2025
64a0dd1
CLAP-181 fix: build 에러 해결2
starboxxxx Jan 30, 2025
723dc42
Merge remote-tracking branch 'origin/CLAP-181' into CLAP-181
starboxxxx Jan 30, 2025
e12a11f
CLAP-181 fix: build 에러 해결3
starboxxxx Jan 30, 2025
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
@@ -0,0 +1,48 @@
package clap.server.adapter.inbound.web.comment;

import clap.server.adapter.inbound.security.SecurityUserDetails;
import clap.server.adapter.inbound.web.dto.task.DeleteCommentRequest;
import clap.server.adapter.inbound.web.dto.task.PostAndEditCommentRequest;
import clap.server.application.port.inbound.comment.CommandCommentUsecase;
import clap.server.common.annotation.architecture.WebAdapter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@Tag(name = "02. Task", description = "작업 생성/수정 API")
@WebAdapter
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/comment")
public class CommandCommentController {

private final CommandCommentUsecase commandCommentUsecase;

@Operation(summary = "댓글 수정")
@Parameter(name = "commentId", description = "수정할 댓글 고유 ID", required = true, in = ParameterIn.PATH)
@PatchMapping("/{commentId}")
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void editComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
@PathVariable Long commentId,
@RequestBody PostAndEditCommentRequest request) {
commandCommentUsecase.updateComment(userInfo.getUserId(), commentId, request);
}

@Operation(summary = "댓글 삭제", description = "첨부파일 댓글일 경우 request body에 삭제할 파일 ID를 리스트로 전달")
@Parameter(name = "commentId", description = "수정할 댓글 고유 ID", required = true, in = ParameterIn.PATH)
@DeleteMapping("/{commentId}")
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void deleteComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
@PathVariable Long commentId,
@RequestBody DeleteCommentRequest request) {
commandCommentUsecase.deleteComment(userInfo.getUserId(), commentId, request);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package clap.server.adapter.inbound.web.comment;

import clap.server.adapter.inbound.security.SecurityUserDetails;
import clap.server.adapter.inbound.web.dto.task.PostAndEditCommentRequest;
import clap.server.application.port.inbound.comment.PostCommentUsecase;
import clap.server.common.annotation.architecture.WebAdapter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Tag(name = "02. Task", description = "작업 생성/수정 API")
@WebAdapter
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/comment")
public class PostCommentController {

private final PostCommentUsecase postCommentUsecase;

@Operation(summary = "댓글 작성")
@Parameter(name = "taskId", description = "댓글 작성할 작업 고유 ID", required = true, in = ParameterIn.PATH)
@PostMapping("/{taskId}")
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void createComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
@PathVariable Long taskId,
@RequestBody(required = true) PostAndEditCommentRequest request){
postCommentUsecase.save(userInfo.getUserId(), taskId, request);
}

@Operation(summary = "댓글 작성(첨부 파일)")
@Parameter(name = "taskId", description = "댓글 작성할 작업 고유 ID", required = true, in = ParameterIn.PATH)
@PostMapping("/attachment/{taskId}")
@Secured({"ROLE_MANAGER", "ROLE_USER"})
public void createAttachmentComment(
@AuthenticationPrincipal SecurityUserDetails userInfo,
@PathVariable Long taskId,
@RequestPart(name = "attachment") @NotNull List<MultipartFile> attachments) {
postCommentUsecase.saveCommentAttachment(userInfo.getUserId(), taskId, attachments);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package clap.server.adapter.inbound.web.dto.task;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

import java.util.List;

public record DeleteCommentRequest(
@Schema(description = "삭제할 파일 ID 목록, 없을 경우 emptylist 전송")
@NotNull
List<Long> attachmentsToDelete
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package clap.server.adapter.inbound.web.dto.task;


import io.swagger.v3.oas.annotations.media.Schema;

public record PostAndEditCommentRequest(
@Schema(description = "댓글 내용")
String content
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public List<Attachment> findAllByTaskIdAndCommentIsNullAndAttachmentId(final Lon
.collect(Collectors.toList());
}

@Override
public List<Attachment> findAllyByTaskIdAndCommentIdAndAttachmentId(Long taskId, Long commentId, List<Long> attachmentIds) {
List<AttachmentEntity> attachmentEntities = attachmentRepository.findActiveAttachmentsByTask_TaskIdAndComment_CommentIdAndAttachmentIdIn(taskId, commentId, attachmentIds);
return attachmentEntities.stream()
.map(attachmentPersistenceMapper::toDomain)
.collect(Collectors.toList());
}

@Override
public List<Attachment> findAllByTaskIdAndCommentIsNotNull(final Long taskId) {
List<AttachmentEntity> attachmentEntities = attachmentRepository.findAllByTask_TaskIdAndCommentIsNotNullAndIsDeletedIsFalse(taskId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
package clap.server.adapter.outbound.persistense;

import clap.server.application.port.outbound.taskhistory.LoadCommentPort;
import clap.server.adapter.outbound.persistense.entity.task.CommentEntity;
import clap.server.adapter.outbound.persistense.mapper.CommentPersistenceMapper;
import clap.server.adapter.outbound.persistense.repository.task.CommentRepository;
import clap.server.application.port.outbound.task.CommandCommentPort;
import clap.server.application.port.outbound.task.LoadCommentPort;
import clap.server.common.annotation.architecture.PersistenceAdapter;
import clap.server.domain.model.task.Comment;
import lombok.RequiredArgsConstructor;

import java.util.Optional;

public class CommentPersistenceAdapter implements LoadCommentPort {
@PersistenceAdapter
@RequiredArgsConstructor
public class CommentPersistenceAdapter implements LoadCommentPort, CommandCommentPort {

private final CommentRepository commentRepository;
private final CommentPersistenceMapper commentPersistenceMapper;

@Override
public Optional<Comment> findById(Long commentId) {
Optional<CommentEntity> commentEntity = commentRepository.findById(commentId);
return commentEntity.map(commentPersistenceMapper::toDomain);
}

@Override
public Optional<Comment> findById(Long id) {
return Optional.empty();
public Comment saveComment(Comment comment) {
CommentEntity commentEntity = commentRepository.save(commentPersistenceMapper.toEntity(comment));
return commentPersistenceMapper.toDomain(commentEntity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,15 @@ public class MemberEntity extends BaseTimeEntity {
@Column(nullable = false)
private MemberStatus status;

// TODO: spring security 적용 예정
@Column(nullable = false)
private String password;

@Column
private String imageUrl;

@Column
private Boolean kakaoworkNotificationEnabled;
@Column
private Boolean agitNotificationEnabled;
@Column
private Boolean emailNotificationEnabled;
private Boolean notificationEnabled;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "admin_id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ public class CommentEntity extends BaseTimeEntity {

@Column(name = "is_modified", nullable = false)
private boolean isModified;

@Column(name="is_deleted", nullable = false)
private boolean isDeleted;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public interface CommentPersistenceMapper extends PersistenceMapper<CommentEnti

@Override
@Mapping(source = "modified", target = "isModified")
@Mapping(source = "deleted", target = "isDeleted")
Comment toDomain(final CommentEntity entity);

@Override
@Mapping(source = "modified", target = "isModified")
@Mapping(source = "deleted", target = "isDeleted")
CommentEntity toEntity(final Comment domain);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
public interface AttachmentRepository extends JpaRepository<AttachmentEntity, Long> {
List<AttachmentEntity> findAllByTask_TaskIdAndCommentIsNullAndIsDeletedIsFalse(Long taskId);
List<AttachmentEntity> findAllByTask_TaskIdAndCommentIsNullAndIsDeletedIsFalseAndAttachmentIdIn(Long task_taskId, List<Long> attachmentId);
List<AttachmentEntity> findActiveAttachmentsByTask_TaskIdAndComment_CommentIdAndAttachmentIdIn(Long task_taskId, Long comment_commentId, List<Long> attachmentIds);
List<AttachmentEntity> findAllByTask_TaskIdAndCommentIsNotNullAndIsDeletedIsFalse(Long taskId);
}
15 changes: 15 additions & 0 deletions src/main/java/clap/server/application/mapper/AttachmentMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import clap.server.adapter.inbound.web.dto.task.AttachmentResponse;
import clap.server.domain.model.task.Attachment;
import clap.server.domain.model.task.Comment;
import clap.server.domain.model.task.Task;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.stream.IntStream;

import static clap.server.domain.model.task.Attachment.createAttachment;
import static clap.server.domain.model.task.Attachment.createCommentAttachment;

public class AttachmentMapper {
private AttachmentMapper() {
Expand All @@ -26,6 +28,19 @@ public static List<Attachment> toTaskAttachments(Task task, List<MultipartFile>
.toList();
}

public static List<Attachment> toCommentAttachments(Task task, Comment comment, List<MultipartFile> files, List<String> fileUrls) {
return IntStream.range(0, files.size())
.mapToObj(i -> createCommentAttachment(
task,
comment,
files.get(i).getOriginalFilename(),
fileUrls.get(i),
files.get(i).getSize()
))
.toList();
}


public static List<AttachmentResponse> toAttachmentResponseList(List<Attachment> attachments) {
return attachments.stream()
.map(attachment -> new AttachmentResponse(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package clap.server.application.port.inbound.comment;

import clap.server.adapter.inbound.web.dto.task.DeleteCommentRequest;
import clap.server.adapter.inbound.web.dto.task.PostAndEditCommentRequest;

import java.util.List;

public interface CommandCommentUsecase {

void updateComment(Long userId, Long commentId, PostAndEditCommentRequest request);

void deleteComment(Long userId, Long commentId, DeleteCommentRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package clap.server.application.port.inbound.comment;

import clap.server.adapter.inbound.web.dto.task.PostAndEditCommentRequest;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public interface PostCommentUsecase {

void save(Long userId, Long taskId, PostAndEditCommentRequest request);

void saveCommentAttachment(Long userId, Long taskId, List<MultipartFile> files);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package clap.server.application.port.outbound.task;

import clap.server.domain.model.task.Comment;

public interface CommandCommentPort {

Comment saveComment(Comment comment);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
public interface LoadAttachmentPort {
List<Attachment> findAllByTaskIdAndCommentIsNull(Long taskId);
List<Attachment> findAllByTaskIdAndCommentIsNullAndAttachmentId(Long taskId, List<Long> attachmentIds);
List<Attachment> findAllyByTaskIdAndCommentIdAndAttachmentId(Long taskId, Long commentId, List<Long> attachmentIds);
List<Attachment> findAllByTaskIdAndCommentIsNotNull(Long taskId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package clap.server.application.port.outbound.task;

import clap.server.domain.model.task.Comment;

import java.util.Optional;

public interface LoadCommentPort {
Optional<Comment> findById(Long commentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import java.util.Optional;

public interface CommandCommentPort {
Optional<Comment> save(Comment comment);
void save(Comment comment);
}
Loading
Loading