From a3114804fd26a07c9c7119170954f25f6f388364 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:14:56 +0900 Subject: [PATCH 01/16] =?UTF-8?q?[feat]=20#39=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=AC=BC=20=EC=8B=A0=EA=B3=A0=20entity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/report/entity/PostReport.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/entity/PostReport.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/entity/PostReport.java b/src/main/java/org/gachon/checkmate/domain/report/entity/PostReport.java new file mode 100644 index 0000000..8e2d012 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/entity/PostReport.java @@ -0,0 +1,36 @@ +package org.gachon.checkmate.domain.report.entity; + + +import jakarta.persistence.*; +import lombok.*; +import org.gachon.checkmate.domain.member.entity.User; +import org.gachon.checkmate.domain.post.entity.Post; +import org.gachon.checkmate.global.common.BaseTimeEntity; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Builder(access = AccessLevel.PRIVATE) +@Getter +@Entity +public class PostReport extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "post_report_id") + private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id") + private Post post; + @Column(name = "reason") + private String reason; + + public static PostReport createPostReport(User user, Post post, String reason) { + return PostReport.builder() + .user(user) + .post(post) + .reason(reason) + .build(); + } +} From 7e42e336857c3ebac2e94b83ddacbd3d3f4a81ca Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:15:05 +0900 Subject: [PATCH 02/16] =?UTF-8?q?[feat]=20#39=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=AC=BC=20=EC=8B=A0=EA=B3=A0=20repository=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/repository/PostReportRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/repository/PostReportRepository.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/repository/PostReportRepository.java b/src/main/java/org/gachon/checkmate/domain/report/repository/PostReportRepository.java new file mode 100644 index 0000000..8808e66 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/repository/PostReportRepository.java @@ -0,0 +1,11 @@ +package org.gachon.checkmate.domain.report.repository; + +import org.gachon.checkmate.domain.report.entity.PostReport; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface PostReportRepository extends JpaRepository { + + Boolean existsPostReportByUserIdAndPostId(Long userId, Long postId); +} From 573b6bb6ffe3a49ab7069fb6aefe2241610e0c7e Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:15:30 +0900 Subject: [PATCH 03/16] =?UTF-8?q?[feat]=20#39=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=AC=BC=20=EC=8B=A0=EA=B3=A0=20API=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC,=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/controller/ReportController.java | 27 +++++++++ .../domain/report/service/ReportService.java | 55 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java create mode 100644 src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java new file mode 100644 index 0000000..28cc302 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java @@ -0,0 +1,27 @@ +package org.gachon.checkmate.domain.report.controller; + + +import lombok.RequiredArgsConstructor; +import org.gachon.checkmate.domain.report.dto.request.PostReportRequestDto; +import org.gachon.checkmate.domain.report.service.ReportService; +import org.gachon.checkmate.global.common.SuccessResponse; +import org.gachon.checkmate.global.config.auth.UserId; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RequestMapping("/api/report") +@RestController +public class ReportController { + private final ReportService reportService; + + @PostMapping("/post") + public ResponseEntity> reportPost(@UserId Long userId, + @RequestBody PostReportRequestDto requestDto) { + reportService.reportPost(userId, requestDto); + return SuccessResponse.created(null); + } +} diff --git a/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java b/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java new file mode 100644 index 0000000..9784b72 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java @@ -0,0 +1,55 @@ +package org.gachon.checkmate.domain.report.service; + +import lombok.RequiredArgsConstructor; +import org.gachon.checkmate.domain.chat.entity.ChatRoom; +import org.gachon.checkmate.domain.chat.repository.ChatRoomRepository; +import org.gachon.checkmate.domain.member.entity.User; +import org.gachon.checkmate.domain.member.repository.UserRepository; +import org.gachon.checkmate.domain.post.entity.Post; +import org.gachon.checkmate.domain.post.repository.PostRepository; +import org.gachon.checkmate.domain.report.dto.request.PostReportRequestDto; +import org.gachon.checkmate.domain.report.entity.PostReport; +import org.gachon.checkmate.domain.report.repository.ChatRoomReportRepository; +import org.gachon.checkmate.domain.report.repository.PostReportRepository; +import org.gachon.checkmate.global.error.exception.ConflictException; +import org.gachon.checkmate.global.error.exception.EntityNotFoundException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static org.gachon.checkmate.domain.report.entity.PostReport.*; +import static org.gachon.checkmate.global.error.ErrorCode.*; + +@RequiredArgsConstructor +@Transactional +@Service +public class ReportService { + + private final PostReportRepository postReportRepository; + private final UserRepository userRepository; + private final PostRepository postRepository; + + public void reportPost(Long userId, PostReportRequestDto requestDto) { + User user = getUserOrThrow(userId); + Post post = getPostOrThrow(requestDto.postId()); + validateUserAlreadyReportPost(user.getId(), post.getId()); + PostReport postReport = createPostReport(user, post, requestDto.reason()); + postReportRepository.save(postReport); + } + + private void validateUserAlreadyReportPost(Long userId, Long postId) { + if(postReportRepository.existsPostReportByUserIdAndPostId(userId, postId)) { + throw new ConflictException(DUPLICATE_POST_REPORT); + } + } + + private User getUserOrThrow(Long userId) { + return userRepository.findById(userId) + .orElseThrow(() -> new EntityNotFoundException(USER_NOT_FOUND)); + } + + private Post getPostOrThrow(Long postId) { + return postRepository.findById(postId) + .orElseThrow(() -> new EntityNotFoundException(POST_NOT_FOUND)); + } + +} From bb28d8ef2df546a3171fa71d52f64ad01759384a Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:15:49 +0900 Subject: [PATCH 04/16] =?UTF-8?q?[feat]=20#39=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=AC=BC=20=EC=8B=A0=EA=B3=A0=20API=20=EC=9A=94=EC=B2=AD=20dto?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/report/dto/request/PostReportRequestDto.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java b/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java new file mode 100644 index 0000000..e9686f5 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java @@ -0,0 +1,7 @@ +package org.gachon.checkmate.domain.report.dto.request; + +public record PostReportRequestDto ( + Long postId, + String reason +) { +} From 72ce1a3ac9f4a202e033098b9c9f3f1c2195b47a Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:16:03 +0900 Subject: [PATCH 05/16] =?UTF-8?q?[feat]=20#39=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EB=AC=BC=20=EC=A4=91=EB=B3=B5=EC=8B=A0=EA=B3=A0=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/gachon/checkmate/global/error/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index 3dabc65..1fc66f1 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -57,6 +57,7 @@ public enum ErrorCode { CONFLICT(HttpStatus.CONFLICT, "이미 존재하는 리소스입니다."), DUPLICATE_EMAIL(HttpStatus.CONFLICT, "이미 가입된 이메일입니다."), DUPLICATE_CHECK_LIST(HttpStatus.CONFLICT, "체크리스트가 이미 존재합니다."), + DUPLICATE_POST_REPORT(HttpStatus.CONFLICT, "이전에 신고했던 게시물입니다."), /** * 500 Internal Server Error From c0b7eb740a9bb8325a5b2eda22a0e7cd30068613 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:40:19 +0900 Subject: [PATCH 06/16] =?UTF-8?q?[feat]=20#39=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EC=8B=A0=EA=B3=A0=20entity=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/report/entity/ChatRoomReport.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/entity/ChatRoomReport.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/entity/ChatRoomReport.java b/src/main/java/org/gachon/checkmate/domain/report/entity/ChatRoomReport.java new file mode 100644 index 0000000..ca2b97e --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/entity/ChatRoomReport.java @@ -0,0 +1,37 @@ +package org.gachon.checkmate.domain.report.entity; + +import jakarta.persistence.*; +import lombok.*; +import org.gachon.checkmate.domain.chat.entity.ChatRoom; +import org.gachon.checkmate.domain.member.entity.User; +import org.gachon.checkmate.domain.post.entity.Post; +import org.gachon.checkmate.domain.scrap.entity.Scrap; +import org.gachon.checkmate.global.common.BaseTimeEntity; + +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Builder(access = AccessLevel.PRIVATE) +@Getter +@Entity +public class ChatRoomReport extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "chat_room_report_id") + private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "chat_room_id") + private ChatRoom chatRoom; + @Column(name = "reason") + private String reason; + + public static ChatRoomReport createChatRoomReport(User user, ChatRoom chatRoom, String reason) { + return ChatRoomReport.builder() + .user(user) + .chatRoom(chatRoom) + .reason(reason) + .build(); + } +} From 6e8730028e6455e0aa9db31f60725abc97e3467a Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:40:30 +0900 Subject: [PATCH 07/16] =?UTF-8?q?[feat]=20#39=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EC=8B=A0=EA=B3=A0=20repository=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/repository/ChatRoomReportRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/repository/ChatRoomReportRepository.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/repository/ChatRoomReportRepository.java b/src/main/java/org/gachon/checkmate/domain/report/repository/ChatRoomReportRepository.java new file mode 100644 index 0000000..e1b2d8a --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/repository/ChatRoomReportRepository.java @@ -0,0 +1,9 @@ +package org.gachon.checkmate.domain.report.repository; + +import org.gachon.checkmate.domain.report.entity.ChatRoomReport; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ChatRoomReportRepository extends JpaRepository { + + Boolean existsChatRoomReportByUserIdAndChatRoomId(Long userId, String chatRoomId); +} From 0e20294e2d562891b4453babe795c01e35aa0cc6 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:40:55 +0900 Subject: [PATCH 08/16] =?UTF-8?q?[feat]=20#39=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EC=8B=A0=EA=B3=A0=20api=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC,=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/controller/ReportController.java | 11 +++++- .../domain/report/service/ReportService.java | 39 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java index 28cc302..39584cb 100644 --- a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java +++ b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java @@ -1,7 +1,9 @@ package org.gachon.checkmate.domain.report.controller; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import org.gachon.checkmate.domain.report.dto.request.ChatRoomReportRequestDto; import org.gachon.checkmate.domain.report.dto.request.PostReportRequestDto; import org.gachon.checkmate.domain.report.service.ReportService; import org.gachon.checkmate.global.common.SuccessResponse; @@ -20,8 +22,15 @@ public class ReportController { @PostMapping("/post") public ResponseEntity> reportPost(@UserId Long userId, - @RequestBody PostReportRequestDto requestDto) { + @RequestBody @Valid PostReportRequestDto requestDto) { reportService.reportPost(userId, requestDto); return SuccessResponse.created(null); } + + @PostMapping("/chat-room") + public ResponseEntity> reportChatRoom(@UserId Long userId, + @RequestBody @Valid ChatRoomReportRequestDto requestDto) { + reportService.reportChatRoom(userId, requestDto); + return SuccessResponse.created(null); + } } diff --git a/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java b/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java index 9784b72..2ea0a71 100644 --- a/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java +++ b/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java @@ -7,15 +7,19 @@ import org.gachon.checkmate.domain.member.repository.UserRepository; import org.gachon.checkmate.domain.post.entity.Post; import org.gachon.checkmate.domain.post.repository.PostRepository; +import org.gachon.checkmate.domain.report.dto.request.ChatRoomReportRequestDto; import org.gachon.checkmate.domain.report.dto.request.PostReportRequestDto; +import org.gachon.checkmate.domain.report.entity.ChatRoomReport; import org.gachon.checkmate.domain.report.entity.PostReport; import org.gachon.checkmate.domain.report.repository.ChatRoomReportRepository; import org.gachon.checkmate.domain.report.repository.PostReportRepository; import org.gachon.checkmate.global.error.exception.ConflictException; import org.gachon.checkmate.global.error.exception.EntityNotFoundException; +import org.gachon.checkmate.global.error.exception.ForbiddenException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import static org.gachon.checkmate.domain.report.entity.ChatRoomReport.*; import static org.gachon.checkmate.domain.report.entity.PostReport.*; import static org.gachon.checkmate.global.error.ErrorCode.*; @@ -25,19 +29,43 @@ public class ReportService { private final PostReportRepository postReportRepository; + private final ChatRoomReportRepository chatRoomReportRepository; private final UserRepository userRepository; private final PostRepository postRepository; + private final ChatRoomRepository chatRoomRepository; public void reportPost(Long userId, PostReportRequestDto requestDto) { User user = getUserOrThrow(userId); Post post = getPostOrThrow(requestDto.postId()); - validateUserAlreadyReportPost(user.getId(), post.getId()); + validateUserAlreadyReportPost(user, post); PostReport postReport = createPostReport(user, post, requestDto.reason()); postReportRepository.save(postReport); } - private void validateUserAlreadyReportPost(Long userId, Long postId) { - if(postReportRepository.existsPostReportByUserIdAndPostId(userId, postId)) { + public void reportChatRoom(Long userId, ChatRoomReportRequestDto requestDto) { + User user = getUserOrThrow(userId); + ChatRoom chatRoom = getChatRoomOrThrow(requestDto.chatRoomId()); + validateUserChatRoomMember(user, chatRoom); + validateUserAlreadyReportChatRoom(user, chatRoom); + ChatRoomReport chatRoomReport = createChatRoomReport(user, chatRoom, requestDto.reason()); + chatRoomReportRepository.save(chatRoomReport); + } + + private void validateUserChatRoomMember(User user, ChatRoom chatRoom) { + if(!chatRoom.getFirstMemberId().equals(user.getId()) && + !chatRoom.getSecondMemberId().equals(user.getId())) { + throw new ForbiddenException(NOT_CHATROOM_USER); + } + } + + private void validateUserAlreadyReportChatRoom(User user, ChatRoom chatRoom) { + if(chatRoomReportRepository.existsChatRoomReportByUserIdAndChatRoomId(user.getId(), chatRoom.getId())) { + throw new ConflictException(DUPLICATE_POST_REPORT); + } + } + + private void validateUserAlreadyReportPost(User user, Post post) { + if(postReportRepository.existsPostReportByUserIdAndPostId(user.getId(), post.getId())) { throw new ConflictException(DUPLICATE_POST_REPORT); } } @@ -52,4 +80,9 @@ private Post getPostOrThrow(Long postId) { .orElseThrow(() -> new EntityNotFoundException(POST_NOT_FOUND)); } + private ChatRoom getChatRoomOrThrow(String chatRoomId) { + return chatRoomRepository.findById(chatRoomId) + .orElseThrow(() -> new EntityNotFoundException(CHATROOM_NOT_FOUND)); + } + } From 8b6a1301a7d25a4acd14235ba5ee9e01064157ce Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:41:08 +0900 Subject: [PATCH 09/16] =?UTF-8?q?[feat]=20#39=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EC=8B=A0=EA=B3=A0=20api=20=EC=9A=94=EC=B2=AD=20dto?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/dto/request/ChatRoomReportRequestDto.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/org/gachon/checkmate/domain/report/dto/request/ChatRoomReportRequestDto.java diff --git a/src/main/java/org/gachon/checkmate/domain/report/dto/request/ChatRoomReportRequestDto.java b/src/main/java/org/gachon/checkmate/domain/report/dto/request/ChatRoomReportRequestDto.java new file mode 100644 index 0000000..4ce6e65 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/report/dto/request/ChatRoomReportRequestDto.java @@ -0,0 +1,7 @@ +package org.gachon.checkmate.domain.report.dto.request; + +public record ChatRoomReportRequestDto( + String chatRoomId, + String reason +) { +} From e8a9a0eea4f3b55cba355171e1739d52a64d8418 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:41:27 +0900 Subject: [PATCH 10/16] =?UTF-8?q?[feat]=20#39=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EA=B4=80=EB=A0=A8=20errorcode=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/gachon/checkmate/global/error/ErrorCode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index 1fc66f1..fa5ef00 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -36,6 +36,7 @@ public enum ErrorCode { */ FORBIDDEN(HttpStatus.FORBIDDEN, "리소스 접근 권한이 없습니다."), NOT_POST_WRITER(HttpStatus.FORBIDDEN, "게시물을 수정할 권한이 없습니다. 작성자만이 게시물을 수정할 수 있습니다."), + NOT_CHATROOM_USER(HttpStatus.BAD_REQUEST, "채팅방에 속한 유저가 아닙니다."), /** * 404 Not Found @@ -44,6 +45,7 @@ public enum ErrorCode { CHECK_LIST_NOT_FOUND(HttpStatus.NOT_FOUND, "체크리스트를 찾을 수 없습니다."), USER_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 유저를 찾을 수 없습니다."), POST_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 게시글을 찾을 수 없습니다."), + CHATROOM_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 채팅방을 찾을 수 없습니다."), REFRESH_TOKEN_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 리프레시 토큰을 찾을 수 없습니다. 다시 로그인해 주세요."), /** From bd9d219f7d40375b4fd55309083596a1223de7fa Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:41:57 +0900 Subject: [PATCH 11/16] =?UTF-8?q?[feat]=20#39=20=EA=B2=8C=EC=8B=9C?= =?UTF-8?q?=EA=B8=80=20=EC=8B=A0=EA=B3=A0=20api=20=EC=9A=94=EC=B2=AD=20dto?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/report/dto/request/PostReportRequestDto.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java b/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java index e9686f5..09d4ed6 100644 --- a/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java +++ b/src/main/java/org/gachon/checkmate/domain/report/dto/request/PostReportRequestDto.java @@ -1,7 +1,10 @@ package org.gachon.checkmate.domain.report.dto.request; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; + public record PostReportRequestDto ( - Long postId, - String reason + @NotNull(message = "신고할 게시물의 ID를 입력해주세요.") Long postId, + @NotEmpty(message = "신고할 이유를 입력해주세요") String reason ) { } From 08ca90a14736941b69d10f07209227b4822da846 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:51:01 +0900 Subject: [PATCH 12/16] =?UTF-8?q?[feat]=20#39=20=EC=B1=84=ED=8C=85?= =?UTF-8?q?=EB=B0=A9=20=EC=A4=91=EB=B3=B5=EC=8B=A0=EA=B3=A0=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20ErrorCode=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/gachon/checkmate/global/error/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index fa5ef00..c9ac3de 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -60,6 +60,7 @@ public enum ErrorCode { DUPLICATE_EMAIL(HttpStatus.CONFLICT, "이미 가입된 이메일입니다."), DUPLICATE_CHECK_LIST(HttpStatus.CONFLICT, "체크리스트가 이미 존재합니다."), DUPLICATE_POST_REPORT(HttpStatus.CONFLICT, "이전에 신고했던 게시물입니다."), + DUPLICATE_CHATROOM_REPORT(HttpStatus.CONFLICT, "이전에 신고했던 채팅방입니다."), /** * 500 Internal Server Error From f635bbeca8675bfc04082be361c95b40496d36ba Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:51:11 +0900 Subject: [PATCH 13/16] =?UTF-8?q?[fix]=20#39=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EC=A4=91=EB=B3=B5=EC=8B=A0=EA=B3=A0=20=ED=99=95=EC=9D=B8=20?= =?UTF-8?q?ErrorCode=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gachon/checkmate/domain/report/service/ReportService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java b/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java index 2ea0a71..ce201f3 100644 --- a/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java +++ b/src/main/java/org/gachon/checkmate/domain/report/service/ReportService.java @@ -60,7 +60,7 @@ private void validateUserChatRoomMember(User user, ChatRoom chatRoom) { private void validateUserAlreadyReportChatRoom(User user, ChatRoom chatRoom) { if(chatRoomReportRepository.existsChatRoomReportByUserIdAndChatRoomId(user.getId(), chatRoom.getId())) { - throw new ConflictException(DUPLICATE_POST_REPORT); + throw new ConflictException(DUPLICATE_CHATROOM_REPORT); } } From ac483e4d3106ce66c24f974e4438aa3d1e3a77c5 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 16:54:01 +0900 Subject: [PATCH 14/16] =?UTF-8?q?[fix]=20#39=20NOT=5FCHATROOM=5FUSER=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/gachon/checkmate/global/error/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java index c9ac3de..b85f233 100644 --- a/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java +++ b/src/main/java/org/gachon/checkmate/global/error/ErrorCode.java @@ -36,7 +36,7 @@ public enum ErrorCode { */ FORBIDDEN(HttpStatus.FORBIDDEN, "리소스 접근 권한이 없습니다."), NOT_POST_WRITER(HttpStatus.FORBIDDEN, "게시물을 수정할 권한이 없습니다. 작성자만이 게시물을 수정할 수 있습니다."), - NOT_CHATROOM_USER(HttpStatus.BAD_REQUEST, "채팅방에 속한 유저가 아닙니다."), + NOT_CHATROOM_USER(HttpStatus.FORBIDDEN, "채팅방에 속한 유저가 아닙니다."), /** * 404 Not Found From 54571fdc5f8dc8ee398e5cbd0621627905d57a67 Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sat, 13 Jan 2024 17:36:16 +0900 Subject: [PATCH 15/16] =?UTF-8?q?[feat]=20#39=20=EC=8B=A0=EA=B3=A0=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=9A=94=EC=B2=AD=20fin?= =?UTF-8?q?al=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/report/controller/ReportController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java index 39584cb..1b77445 100644 --- a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java +++ b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java @@ -21,15 +21,15 @@ public class ReportController { private final ReportService reportService; @PostMapping("/post") - public ResponseEntity> reportPost(@UserId Long userId, - @RequestBody @Valid PostReportRequestDto requestDto) { + public ResponseEntity> reportPost(@UserId final Long userId, + @RequestBody @Valid final PostReportRequestDto requestDto) { reportService.reportPost(userId, requestDto); return SuccessResponse.created(null); } @PostMapping("/chat-room") - public ResponseEntity> reportChatRoom(@UserId Long userId, - @RequestBody @Valid ChatRoomReportRequestDto requestDto) { + public ResponseEntity> reportChatRoom(@UserId final Long userId, + @RequestBody @Valid final ChatRoomReportRequestDto requestDto) { reportService.reportChatRoom(userId, requestDto); return SuccessResponse.created(null); } From 0fee7f93c24c452884c0c54d3dc604398b5c21ed Mon Sep 17 00:00:00 2001 From: OJOJIN Date: Sun, 14 Jan 2024 00:13:41 +0900 Subject: [PATCH 16/16] =?UTF-8?q?[feat]=20#42=20ReportController=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../checkmate/domain/report/controller/ReportController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java index 1b77445..6992b69 100644 --- a/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java +++ b/src/main/java/org/gachon/checkmate/domain/report/controller/ReportController.java @@ -18,6 +18,7 @@ @RequestMapping("/api/report") @RestController public class ReportController { + private final ReportService reportService; @PostMapping("/post") @@ -29,7 +30,7 @@ public ResponseEntity> reportPost(@UserId final Long userId, @PostMapping("/chat-room") public ResponseEntity> reportChatRoom(@UserId final Long userId, - @RequestBody @Valid final ChatRoomReportRequestDto requestDto) { + @RequestBody @Valid final ChatRoomReportRequestDto requestDto) { reportService.reportChatRoom(userId, requestDto); return SuccessResponse.created(null); }