Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
332846a
refactor: ์•Œ๋ฆผ ์ƒํƒœ ์ถ”๊ฐ€
Dev-lemongrab Sep 21, 2025
95fb72d
feat : ์ฐธ์—ฌ ์•Œ๋ฆผ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
Dev-lemongrab Sep 21, 2025
5d39d9c
test : ์ฐธ์—ฌ์•Œ๋ฆผ test ์ถ”๊ฐ€
Dev-lemongrab Sep 21, 2025
c7f94e4
Merge branch 'develop' of https://github.com/SWYP-team-2th/server intโ€ฆ
Dev-lemongrab Sep 21, 2025
99518b0
refactor : ๊ธฐ๋ณธ ๊ตฌ์กฐ ๋ฆฌํŒฉํ† ๋ง
Dev-lemongrab Sep 23, 2025
dc67d8f
Merge branch 'develop' of https://github.com/SWYP-team-2th/server intโ€ฆ
Dev-lemongrab Sep 24, 2025
0b85245
fix : ์•Œ๋ฆผ ์กฐํšŒ ๋ฐ ๊ธฐํƒ€ ์ˆ˜์ •
Dev-lemongrab Sep 25, 2025
9999e75
Merge branch 'develop' of https://github.com/SWYP-team-2th/server intโ€ฆ
Dev-lemongrab Sep 27, 2025
34e7a61
refactor : ์•Œ๋ฆผ ์กฐํšŒ ์ˆ˜์ •
Dev-lemongrab Sep 27, 2025
851d958
refactor : ๋Œ“๊ธ€ ์ข‹์•„์š” ์•Œ๋ฆผ ์ƒ์„ฑ ๊ธฐ๋Šฅ ์ˆ˜์ •
Dev-lemongrab Sep 27, 2025
26f157c
test : ์•Œ๋ฆผ test ์ฝ”๋“œ ์ˆ˜์ •
Dev-lemongrab Sep 27, 2025
304da41
refactor : ํŒจํ‚ค์ง€ ๊ตฌ์กฐ ์ •๋ฆฌ
Dev-lemongrab Sep 27, 2025
44061c8
feat : ๋‚ด๊ฒŒ์‹œ๋ฌผ ๋งˆ๊ฐ, ํˆฌํ‘œ ์ฐธ์—ฌ ๊ฐœ๋ฐœ
Dev-lemongrab Sep 28, 2025
d0683c7
test : ๋‚ด๊ฒŒ์‹œ๋ฌผ ๋งˆ๊ฐ ์•Œ๋ฆผ test, ํˆฌํ‘œ ์ฐธ์—ฌ test
Dev-lemongrab Sep 28, 2025
dc536e9
feat : ๋‚ด๊ฐ€ ์ฐธ์—ฌํ•œ ํˆฌํ‘œ ๋งˆ๊ฐ ์•Œ๋ฆผ
Dev-lemongrab Sep 28, 2025
c25829b
test : ์ฐธ์—ฌํ•œ ๊ฒŒ์‹œ๋ฌผ ๋งˆ๊ฐ ์•Œ๋ฆผ ํ…Œ์ŠคํŠธ
Dev-lemongrab Sep 28, 2025
d89a921
feat : ์•Œ๋ฆผ ์ฝ์Œ, ์•Œ๋ฆผ ์ƒํƒœํ™•์ธ api ์ถ”๊ฐ€
Dev-lemongrab Sep 28, 2025
7c6791d
test : ์•Œ๋ฆผ ์ƒํƒœ ํ™•์ธ ๋ฐ ์•Œ๋ฆผ ์กฐํšŒ test ์ถ”๊ฐ€
Dev-lemongrab Sep 28, 2025
afa780e
refactor : ์—ฌ๋Ÿฌ ์‚ฌ์šฉ์ž ์•Œ๋ฆผ ์„œ๋น„์Šค ์ˆ˜์ •
Dev-lemongrab Sep 29, 2025
a6981fb
test : ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ผ๋ถ€ ์ˆ˜์ •
Dev-lemongrab Sep 29, 2025
c0bfbe1
docs : restdocs ์•Œ๋ฆผ ๋ฐ˜์˜
Dev-lemongrab Sep 29, 2025
014a04c
test: ํ…Œ์ŠคํŠธ ์˜ค๋ฅ˜ ์ˆ˜์ •
Dev-lemongrab Sep 29, 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
12 changes: 11 additions & 1 deletion src/docs/asciidoc/notifications.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
[[์•Œ๋ฆผ-์กฐํšŒ]]
=== `GET` ์•Œ๋ฆผ ์กฐํšŒ

operation::notification-controller-test/find-notifications[snippets='http-request,curl-request,path-parameters,request-headers,query-parameters,http-response,response-fields']
operation::notification-controller-test/find-notifications[snippets='http-request,curl-request,path-parameters,request-headers,query-parameters,http-response,response-fields']

[[์•Œ๋ฆผ-์ฝ๊ธฐ]]
=== `PATCH` ์•Œ๋ฆผ ์ฝ๊ธฐ

operation::notification-controller-test/mark-read[snippets='http-request,curl-request,path-parameters,request-headers']

[[์•Œ๋ฆผ-์ƒํƒœ-ํ™•์ธ]]
=== `GET` ์•Œ๋ฆผ ์ƒํƒœ ํ™•์ธ

operation::notification-controller-test/find-notifications[snippets='http-request,curl-request,path-parameters,request-headers,http-response,response-fields']
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.chooz.common.event.EventPublisher;
import com.chooz.common.exception.BadRequestException;
import com.chooz.common.exception.ErrorCode;
import com.chooz.notification.domain.event.CommentLikedEvent;
import com.chooz.commentLike.domain.event.CommentLikedNotificationEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -29,7 +29,7 @@ public CommentLikeIdResponse createCommentLike(Long commentId, Long userId) {
}
CommentLike commentLike = commentLikeRepository.save(CommentLike.create(commentId, userId));

eventPublisher.publish(new CommentLikedEvent(
eventPublisher.publish(new CommentLikedNotificationEvent(
commentId,
commentLike.getId(),
userId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.chooz.notification.domain.event;
package com.chooz.commentLike.domain.event;

import java.time.LocalDateTime;

public record CommentLikedEvent(
public record CommentLikedNotificationEvent(
Long commentId,
Long commentLikeId,
Long likerId,
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/chooz/common/exception/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum ErrorCode {
ONLY_SELF_CAN_CLOSE("์ž‘์„ฑ์ž ๋งˆ๊ฐ์˜ ๊ฒฝ์šฐ, SELF ๋งˆ๊ฐ ๋ฐฉ์‹๋งŒ์ด ๋งˆ๊ฐ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."),
INVALID_ONBOARDING_STEP("์œ ํšจํ•˜์ง€ ์•Š์€ ์˜จ๋ณด๋”ฉ ๋‹จ๊ณ„."),
NICKNAME_LENGTH_EXCEEDED("๋‹‰๋„ค์ž„ ๊ธธ์ด ์ดˆ๊ณผ"),
NOTIFICATION_NOT_FOUND("์กด์žฌํ•˜์ง€ ์•Š๋Š” ์•Œ๋ฆผ ์ž…๋‹ˆ๋‹ค."),

//401
EXPIRED_TOKEN("ํ† ํฐ์ด ๋งŒ๋ฃŒ๋์Šต๋‹ˆ๋‹ค."),
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,49 +1,96 @@
package com.chooz.notification.application;

import com.chooz.common.exception.BadRequestException;
import com.chooz.common.exception.ErrorCode;
import com.chooz.notification.application.dto.CommentLikedContent;
import com.chooz.notification.application.dto.NotificationContent;
import com.chooz.notification.application.dto.TargetPostDto;
import com.chooz.notification.application.dto.TargetUserDto;
import com.chooz.notification.domain.NotificationQueryRepository;
import com.chooz.notification.domain.NotificationType;
import com.chooz.notification.domain.Target;
import com.chooz.notification.domain.TargetType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class NotificationContentAssembler {

private final NotificationQueryRepository notificationQueryDslRepository;

public CommentLikedContent forCommentLiked(Long commentId, Long likerId) {
TargetUserDto targetUserDto = notificationQueryDslRepository.getUser(likerId)
.orElseThrow(() -> new BadRequestException(ErrorCode.USER_NOT_FOUND));
TargetUserDto commentAuthorDto = notificationQueryDslRepository.getUserByCommentId(commentId)
.orElseThrow(() -> new BadRequestException(ErrorCode.USER_NOT_FOUND));
TargetPostDto targetPostDto = notificationQueryDslRepository.getPost(commentId)
.orElseThrow(() -> new BadRequestException(ErrorCode.POST_NOT_FOUND));
private final NotificationService notificationService;
private final NotificationMessageRenderer renderer;

return new CommentLikedContent(
targetUserDto.nickname(),
public NotificationContent forCommentLiked(Long commentId, Long likerId) {
TargetUserDto commentAuthorDto = notificationService.findUserByCommentId(commentId);
TargetUserDto targetUserDto = notificationService.findUserById(likerId);
TargetPostDto targetPostDto = notificationService.findPostByCommentId(commentId);
var vars = Map.<String, Object>of("actorName", targetUserDto.nickname());
var renderedMessage = renderer.render(NotificationType.COMMENT_LIKED.code(), vars);
return new NotificationContent(
commentAuthorDto.id(),
targetUserDto.id(),
renderedMessage.title(),
renderedMessage.content(),
targetUserDto.profileUrl(),
targetPostDto.imageUrl(),
commentAuthorDto.id(),
commentAuthorDto.nickname()
List.of(Target.of(targetPostDto.id(), TargetType.POST),
Target.of(commentId, TargetType.COMMENT)
)
);
}

// public NotificationContent forVoteClosed(Long postId) {
// String title = postPort.getPostTitle(postId).orElse("ํˆฌํ‘œ ๋งˆ๊ฐ");
// String body = "์ฐธ์—ฌํ•œ ํˆฌํ‘œ๊ฐ€ ๋งˆ๊ฐ๋˜์—ˆ์–ด์š”.";
// String thumbnail = postPort.getPostThumbnailUrl(postId).orElse(null);
// return new NotificationContent(title, body, thumbnail);
// }
//
// public NotificationContent forPostParticipated(Long postId, Long voterId) {
// String title = postPort.getPostTitle(postId).orElse("์ƒˆ๋กœ์šด ์ฐธ์—ฌ");
// String voter = userPort.getDisplayName(voterId).orElse("๋ˆ„๊ตฐ๊ฐ€");
// String body = voter + "๋‹˜์ด ๋‚ด ํˆฌํ‘œ์— ์ฐธ์—ฌํ–ˆ์–ด์š”.";
// String thumbnail = userPort.getAvatarUrl(voterId).orElse(null);
// return new NotificationContent(title, body, thumbnail);
// }
public NotificationContent forVoted(Long postId, Long voterId) {
TargetUserDto postAuthorDto = notificationService.findUserByPostId(postId);
TargetUserDto targetUserDto = notificationService.findUserById(voterId);
TargetPostDto targetPostDto = notificationService.findPostById(postId);
var vars = Map.<String, Object>of(
"actorName", targetUserDto.nickname(),
"postTitle", targetPostDto.title()
);
var renderedMessage = renderer.render(NotificationType.POST_VOTED.code(), vars);
return new NotificationContent(
postAuthorDto.id(),
targetUserDto.id(),
renderedMessage.title(),
renderedMessage.content(),
targetUserDto.profileUrl(),
targetPostDto.imageUrl(),
List.of(Target.of(targetPostDto.id(), TargetType.POST))
);
}
public NotificationContent forMyPostClosed(Long postId, Long userId) {
TargetUserDto postAuthorDto = notificationService.findUserById(userId);
TargetPostDto targetPostDto = notificationService.findPostById(postId);
var vars = Map.<String, Object>of(
"postTitle", targetPostDto.title()
);
var renderedMessage = renderer.render(NotificationType.MY_POST_CLOSED.code(), vars);
return new NotificationContent(
postAuthorDto.id(),
postAuthorDto.id(),
renderedMessage.title(),
renderedMessage.content(),
postAuthorDto.profileUrl(),
targetPostDto.imageUrl(),
List.of(Target.of(targetPostDto.id(), TargetType.POST))
);
}
public List<NotificationContent> forPostClosed(Long postId, Long userId) {
TargetUserDto postAuthorDto = notificationService.findUserById(userId);
List<TargetUserDto> receiverUserDtos = notificationService.findVoteUsersByPostId(postId);
TargetPostDto targetPostDto = notificationService.findPostById(postId);
var vars = Map.<String, Object>of(
"postTitle", targetPostDto.title()
);
var renderedMessage = renderer.render(NotificationType.POST_CLOSED.code(), vars);
return receiverUserDtos.stream().map(receiver ->
new NotificationContent(
receiver.id(),
postAuthorDto.id(),
renderedMessage.title(),
renderedMessage.content(),
postAuthorDto.profileUrl(),
targetPostDto.imageUrl(),
List.of(Target.of(targetPostDto.id(), TargetType.POST))
)).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.chooz.notification.application;

import com.chooz.notification.application.dto.RenderedMessage;

import java.util.Map;

public interface NotificationMessageRenderer {
RenderedMessage render(String type, Map<String, Object> vars);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.chooz.notification.application;

import com.chooz.common.dto.CursorBasePaginatedResponse;
import com.chooz.notification.application.dto.TargetPostDto;
import com.chooz.notification.application.dto.TargetUserDto;
import com.chooz.notification.application.service.NotificationCommandService;
import com.chooz.notification.application.service.NotificationQueryService;
import com.chooz.notification.domain.Notification;
import com.chooz.notification.presentation.dto.NotificationPresentResponse;
import com.chooz.notification.presentation.dto.NotificationResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class NotificationService {

private final NotificationQueryService notificationQueryService;
private final NotificationCommandService notificationCommandService;

public CursorBasePaginatedResponse<NotificationResponse> findNotifications(Long userId, Long cursor, int size) {
return notificationQueryService.findNotifications(userId, cursor, size);
}
public TargetUserDto findUserByCommentId(Long commentId) {
return notificationQueryService.findUserByCommentId(commentId);
}
public TargetUserDto findUserById(Long userId) {
return notificationQueryService.findUserById(userId);
}
public TargetPostDto findPostByCommentId(Long commentId) {
return notificationQueryService.findPostByCommentId(commentId);
}
public TargetUserDto findUserByPostId(Long postId) {
return notificationQueryService.findUserByPostId(postId);
}
public TargetPostDto findPostById(Long postId) {
return notificationQueryService.findPostById(postId);
}
public Notification create(Notification notification) {
return notificationCommandService.create(notification);
}
public void createAll(List<Notification> notifications) {
notificationCommandService.createAll(notifications);
}
public List<TargetUserDto> findVoteUsersByPostId(Long postId) {
return notificationQueryService.findVoteUsersByPostId(postId);
}
public void markRead(Long notificationId) {
notificationCommandService.markRead(notificationId);
}
public NotificationPresentResponse present(Long userId) {
return notificationQueryService.present(userId);
}
}

This file was deleted.

Loading