Notification API

알림은 댓글 저장시 자동 저장,
무한 스크롤 형태로 구현해 요청시 page번호가 아닌 id값을 입력해야함

1. 알림 조회

Request
GET /api/v1/notifications?read=false&id= HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0X2pob3VzZV9jb20iLCJleHAiOjE3MTEzNzA0NjYsImF1dGgiOiJVU0VSIiwidHlwZSI6Ik5PTkUifQ.cyBkj9RV1WrsyDwlGb2J-JgHptTcH9VigLPKIqfXaVdcLzAfCgc9yMPaqkEBKneWS3i3DyNFoesWDzIQ2AFpnw
Host: localhost:8080
Request Params
Parameter Description

read

알림 읽음 필터링, null - 전부, false - 읽지 않음, true - 읽음

id

초기요청시 null 입력 후, 이후 요청 부턴 응답의 nextId 기입

Response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 2045

{
  "code" : "SUCCESS",
  "message" : "성공",
  "data" : {
    "nextId" : 36765,
    "notifications" : {
      "content" : [ {
        "nick_name" : "테스트유저1",
        "board_id" : 1524,
        "board_title" : "짱구는 못말려",
        "status" : false,
        "comment" : "짱구야, 공부 하자.",
        "comment_user" : "테스트유저2",
        "notification_id" : 36773
      }, {
        "nick_name" : "테스트유저1",
        "board_id" : 1524,
        "board_title" : "짱구는 못말려",
        "status" : false,
        "comment" : "짱구야, 공부 하자.",
        "comment_user" : "테스트유저2",
        "notification_id" : 36771
      }, {
        "nick_name" : "테스트유저1",
        "board_id" : 1524,
        "board_title" : "짱구는 못말려",
        "status" : false,
        "comment" : "짱구야, 공부 하자.",
        "comment_user" : "테스트유저2",
        "notification_id" : 36769
      }, {
        "nick_name" : "테스트유저1",
        "board_id" : 1524,
        "board_title" : "짱구는 못말려",
        "status" : false,
        "comment" : "짱구야, 공부 하자.",
        "comment_user" : "테스트유저2",
        "notification_id" : 36767
      }, {
        "nick_name" : "테스트유저1",
        "board_id" : 1524,
        "board_title" : "짱구는 못말려",
        "status" : false,
        "comment" : "짱구야, 공부 하자.",
        "comment_user" : "테스트유저2",
        "notification_id" : 36765
      } ],
      "pageable" : {
        "sort" : {
          "empty" : true,
          "unsorted" : true,
          "sorted" : false
        },
        "offset" : 0,
        "pageSize" : 5,
        "pageNumber" : 0,
        "paged" : true,
        "unpaged" : false
      },
      "first" : true,
      "last" : false,
      "size" : 5,
      "number" : 0,
      "sort" : {
        "empty" : true,
        "unsorted" : true,
        "sorted" : false
      },
      "numberOfElements" : 5,
      "empty" : false
    }
  }
}
Path Type Description

code

String

결과 코드

message

String

응답 메세지

data.nextId

Number

다음 알림 아이디

data.notifications.content[].nick_name

String

닉네임

data.notifications.content[].board_id

Number

게시글 아이디

data.notifications.content[].board_title

String

게시글 제목

data.notifications.content[].status

Boolean

알림 읽음 상태, false - 읽지 않음, true - 읽음

data.notifications.content[].comment

String

댓글 내용

data.notifications.content[].comment_user

String

댓글 작성자 닉네임

data.notifications.content[].notification_id

Number

알림 아이디

data.notifications.pageable.sort.empty

Boolean

data.notifications.pageable.sort.unsorted

Boolean

data.notifications.pageable.sort.sorted

Boolean

data.notifications.pageable.offset

Number

data.notifications.pageable.pageSize

Number

data.notifications.pageable.pageNumber

Number

data.notifications.pageable.paged

Boolean

data.notifications.pageable.unpaged

Boolean

data.notifications.last

Boolean

마지막 페이지 여부

data.notifications.first

Boolean

data.notifications.size

Number

data.notifications.number

Number

data.notifications.sort.empty

Boolean

data.notifications.sort.unsorted

Boolean

data.notifications.sort.sorted

Boolean

data.notifications.numberOfElements

Number

data.notifications.empty

Boolean

2. 알림 읽음 처리

Request
PUT /api/v1/notifications/36721 HTTP/1.1
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0X2pob3VzZV9jb20iLCJleHAiOjE3MTEzNzA0NjYsImF1dGgiOiJVU0VSIiwidHlwZSI6Ik5PTkUifQ.cyBkj9RV1WrsyDwlGb2J-JgHptTcH9VigLPKIqfXaVdcLzAfCgc9yMPaqkEBKneWS3i3DyNFoesWDzIQ2AFpnw
Host: localhost:8080
Path Params
Table 1. /api/v1/notifications/{id}
Parameter Description

id

알림 아이디

Response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/json;charset=UTF-8
Content-Length: 66

{
  "code" : "SUCCESS",
  "message" : "성공",
  "data" : 36721
}