Skip to content

Commit

Permalink
feat: 알림 관련 기능 구현
Browse files Browse the repository at this point in the history
* feat: MongoDB 연동 및 초기 클래스 추가

* fix: owne -> owner

* feat: 알림에서 사용할 Enum 타입 구현

* feat: Notification 관련 예외 처리 추가

* feat: 알림 엔티티 구현

* fix: 알림 도메인 수정, 하위 알림 추가

* feat: 예외 메시지 및 에러코드 추가

* feat: 몽고DB 관련 config 추가

* chore: 몽고DB Q도메인 생성 옵션 추가

* fix: 몽고DB config 트랜잭션 옵션 추가

* feat: 사용자 알림 목록 조회 구현

* feat: 알림 저장하는 공통 서비스 구현

* feat: 게시글에 댓글이 달렸을 때 알림 구현

* fix: 날짜 format 수정

* refactor: 알림 호출 이벤트 기반으로 변경

* fix: message enum으로 관리하도록 수정

* feat: 대댓글이 달렸을 때 알림 전송 구현

* fix: 알림 데이터 구조 변경

* feat: 알림 Object id -> Auto Increasement의 Long 타입 id로 수정

* feat: createAt 현재시간으로 저장되도록 수정

* refactor: NotificationSequence -> AutoIncrementSequence

* fix: 알림 조회 Cursor 기반 페이지네이션으로 변경

* test: 알림 조회 Controller 테스트 구현

* feat: 새로운 알림이 왔는지 확인하는 기능 구현

* fix: 새로운 알림 확인 결과 dto로 감싸서 응답

* test: 새로운 알림 확인 Controller 테스트 구현

* docs: API 문서 알림 반영

* docs: API 문서 최신화 v2

* refactor: 알림 이벤트 호출 로직 분리

* fix: 불필요한 쿼리문 삭제
  • Loading branch information
jjuny0310 authored Nov 14, 2023
1 parent f9d4ec3 commit d899f62
Show file tree
Hide file tree
Showing 35 changed files with 1,838 additions and 864 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ dependencies {
//restAssured
testImplementation 'io.rest-assured:rest-assured:4.4.0'
testImplementation 'io.rest-assured:spring-mock-mvc:4.4.0'

// Mongodb 의존성 추가
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
}

task prepareDirs {
Expand Down Expand Up @@ -194,6 +197,7 @@ bootJar {
querydsl {
jpa = true
querydslSourcesDir = querydslDir
springDataMongo = true
}

// build시 사용할 sourceSet 추가 설정
Expand Down
109 changes: 55 additions & 54 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,59 @@
:sectnums:
:docinfo: shared-head

[[overview]]
= Overview

[[overview_http_verbs]]
== HTTP Method

RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its
use of HTTP verbs.

|===
| Verb | Usage

| `GET`
| Used to retrieve a resource

| `POST`
| Used to create a new resource

| `PUT`
| PUT 설명

| `PATCH`
| Used to update an existing resource, including partial updates

| `DELETE`
| Used to delete an existing resource
|===

[[overview_http_status_codes]]
== HTTP status codes

RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its
use of HTTP status codes.

|===
| Status code | Usage

| `200 OK`
| The request completed successfully

| `201 Created`
| A new resource has been created successfully. The resource's URI is available from the response's
`Location` header

| `204 No Content`
| An update to an existing resource has been applied successfully

| `400 Bad Request`
| The request was malformed. The response body will include an error providing further information

| `404 Not Found`
| The requested resource did not exist
|===
// [[overview]]
// = Overview
//
// [[overview_http_verbs]]
// == HTTP Method
//
// RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its
// use of HTTP verbs.

// |===
// | Verb | Usage
//
// | `GET`
// | Used to retrieve a resource
//
// | `POST`
// | Used to create a new resource
//
// | `PUT`
// | PUT 설명
//
// | `PATCH`
// | Used to update an existing resource, including partial updates
//
// | `DELETE`
// | Used to delete an existing resource
// |===

// [[overview_http_status_codes]]
// == HTTP status codes
//
// RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its
// use of HTTP status codes.

// |===
// | Status code | Usage
//
// | `200 OK`
// | The request completed successfully
//
// | `201 Created`
// | A new resource has been created successfully. The resource's URI is available from the response's
// `Location` header
//
// | `204 No Content`
// | An update to an existing resource has been applied successfully
//
// | `400 Bad Request`
// | The request was malformed. The response body will include an error providing further information
//
// | `404 Not Found`
// | The requested resource did not exist
// |===

include::board.adoc[]
include::post.adoc[]
Expand All @@ -74,4 +74,5 @@ include::recruit.adoc[]
include::recruitApplication.adoc[]
include::recruitComment.adoc[]
include::storage.adoc[]
include::report.adoc[]
include::report.adoc[]
include::notification.adoc[]
7 changes: 7 additions & 0 deletions src/docs/asciidoc/notification.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== 알림

=== 알림 목록 조회
operation::notification/get-notifications-by-cursor[snippets='http-request,http-response,cookie,response-fields']

=== 새로운 알림 확인
operation::notification/check-notification[snippets='http-request,http-response,cookie,response-fields']
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.ssafy.ssafsound.domain.comment.domain;

import com.ssafy.ssafsound.domain.BaseTimeEntity;
import com.ssafy.ssafsound.domain.comment.dto.PostCommentWriteReqDto;
import com.ssafy.ssafsound.domain.member.domain.Member;
import com.ssafy.ssafsound.domain.post.domain.Post;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -65,4 +64,20 @@ public void updateComment(String content, Boolean anonymity) {
this.content = content;
this.anonymity = anonymity;
}

public Boolean isMine(Member member) {
return this.getMember().getId().equals(member.getId());
}

public Long getAuthorId() {
return this.getMember().getId();
}

public Boolean isAssociatedWithPost(Post post) {
return this.post.getId().equals(post.getId());
}

public Boolean isParent() {
return this.getId().equals(this.commentGroup.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ public enum CommentErrorInfo {
NOT_FOUND_COMMENT_NUMBER("806", "익명 번호를 찾을 수 없습니다."),
NOT_FOUND_COMMENT("807", "댓글을 찾을 수 없습니다."),
UNAUTHORIZED_UPDATE_COMMENT("808", "댓글을 수정할 권한이 없습니다"),
UNAUTHORIZED_DELETE_COMMENT("809", "댓글을 삭제할 권한이 없습니다");
UNAUTHORIZED_DELETE_COMMENT("809", "댓글을 삭제할 권한이 없습니다"),
NOT_ASSOCIATED_WITH_POST("810", "댓글과 게시글이 일치하지 않습니다."),
FORBIDDEN_REPLY_SUB_COMMENT("811", "대댓글에는 답변을 작성할 수 없습니다.");

private final String code;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ssafy.ssafsound.domain.comment.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
Expand All @@ -26,4 +27,10 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
+ "where comment_id = :id", nativeQuery = true)
void updateByCommentGroup(@Param("id") Long id);

@Query(value = "select c " +
"from comment c " +
"join fetch c.member " +
"join fetch c.commentGroup " +
"where c.id = :id")
Optional<Comment> findByIdWithMemberAndCommentGroup(Long id);
}
Loading

0 comments on commit d899f62

Please sign in to comment.