Skip to content

Commit

Permalink
Merge pull request #386 from tukcomCD2024/develop_back_notification
Browse files Browse the repository at this point in the history
feat : develop_back_notification -> develop_back
  • Loading branch information
seokho-1116 authored May 2, 2024
2 parents 7d173b3 + 30f3696 commit f3e965f
Show file tree
Hide file tree
Showing 25 changed files with 763 additions and 102 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/notification-application-ci-cd-flow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ jobs:

- name: Add Github Actions IP to Security group
run: |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_EC2_NOTIFICATION_SG_ID }} --group-name ${{secrets.AWS_EC2_NOTIFICATION_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_EC2_CORE_SG_ID }} --group-name ${{secrets.AWS_EC2_CORE_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- name: Connect ec2 and Run Docker Container
uses: appleboy/[email protected]
env:
AWS_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
with:
host: ${{ secrets.SSH_NOTIFICATION_HOST }}
host: ${{ secrets.SSH_CORE_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_CORE_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
Expand All @@ -134,12 +134,12 @@ jobs:
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
docker image prune -f
docker pull ${{ steps.meta.outputs.tags }}
docker run -d -p 8080:8080 --name notification --network test_backend ${{ steps.meta.outputs.tags }}
docker run -d -p 8081:8081 -e ENVIRONMENT=dev --name notification --network test_backend ${{ steps.meta.outputs.tags }}
- name: Remove Github Actions IP from security group
if: always()
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_NOTIFICATION_SG_ID }} --group-name ${{secrets.AWS_EC2_NOTIFICATION_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_CORE_SG_ID }} --group-name ${{secrets.AWS_EC2_CORE_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
- uses: sarisia/actions-status-discord@v1
if: success()
Expand Down
2 changes: 1 addition & 1 deletion backend/notification/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./
COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./
COPY --from=build ${EXTRACTED}/application/ ./

ENTRYPOINT ["java","-Dspring.profiles.active=dev","org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT java -Dspring.profiles.active=$ENVIRONMENT org.springframework.boot.loader.JarLauncher
5 changes: 2 additions & 3 deletions backend/notification/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ dependencies {
//s3
implementation 'software.amazon.awssdk:s3:2.21.46'

//flyway
implementation 'org.flywaydb:flyway-core:9.5.1'
implementation 'org.flywaydb:flyway-mysql:9.5.1'
//RabbitMQ
implementation 'org.springframework.boot:spring-boot-starter-amqp'

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package site.timecapsulearchive.notification.data.dto;

import lombok.Builder;
import site.timecapsulearchive.notification.entity.Notification;
import site.timecapsulearchive.notification.entity.NotificationCategory;
import site.timecapsulearchive.notification.entity.NotificationStatus;

@Builder
Expand All @@ -14,4 +16,14 @@ public record CapsuleSkinNotificationSendDto(
String skinUrl
) {

public Notification toNotification(NotificationCategory notificationCategory) {
return Notification.builder()
.memberId(memberId)
.title(title)
.text(text)
.imageUrl(skinUrl)
.notificationCategory(notificationCategory)
.status(status)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package site.timecapsulearchive.notification.data.dto;

import java.util.Objects;
import lombok.Builder;
import site.timecapsulearchive.notification.entity.Notification;
import site.timecapsulearchive.notification.entity.NotificationCategory;
import site.timecapsulearchive.notification.entity.NotificationStatus;

@Builder
public record FriendNotificationDto(
Long targetId,
NotificationStatus notificationStatus,
String text,
String title
) {

public FriendNotificationDto {
Objects.requireNonNull(targetId);
Objects.requireNonNull(notificationStatus);
Objects.requireNonNull(text);
Objects.requireNonNull(title);
}

public Notification toNotification(final NotificationCategory notificationCategory) {
return Notification.builder()
.memberId(targetId)
.title(title)
.text(text)
.status(notificationStatus)
.notificationCategory(notificationCategory)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package site.timecapsulearchive.notification.data.dto;

import java.util.List;
import site.timecapsulearchive.notification.entity.Notification;
import site.timecapsulearchive.notification.entity.NotificationCategory;
import site.timecapsulearchive.notification.entity.NotificationStatus;

public record FriendNotificationsDto(
String profileUrl,
NotificationStatus notificationStatus,
String title,
String text,
List<Long> targetIds
) {

public List<Notification> toNotification(NotificationCategory notificationCategory) {
return targetIds.stream()
.map(id -> Notification.builder()
.memberId(id)
.notificationCategory(notificationCategory)
.status(notificationStatus)
.imageUrl(profileUrl)
.title(title)
.text(text)
.build()
)
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package site.timecapsulearchive.notification.data.dto;

import java.util.List;
import site.timecapsulearchive.notification.entity.Notification;
import site.timecapsulearchive.notification.entity.NotificationCategory;
import site.timecapsulearchive.notification.entity.NotificationStatus;

public record GroupInviteNotificationDto (
NotificationStatus notificationStatus,
String groupProfileUrl,
String title,
String text,
List<Long> targetIds
){
public List<Notification> toNotification(NotificationCategory notificationCategory) {
return targetIds.stream()
.map(id -> Notification.builder()
.notificationCategory(notificationCategory)
.memberId(id)
.status(notificationStatus)
.imageUrl(groupProfileUrl)
.title(title)
.text(text)
.build()
)
.toList();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

public record CapsuleSkinNotificationSendRequest(

@NotNull
@NotNull(message = "멤버 아이디는 필수 입니다.")
Long memberId,

@NotNull
@NotNull(message = "알림 상태는 필수 입니다.")
NotificationStatus status,

@NotBlank
@NotBlank(message = "스킨 이름은 필수 입니다.")
String skinName,

@NotBlank
@NotBlank(message = "알림 내용은 필수 입니다.")
String title,

@NotBlank
@NotBlank(message = "알림 내용은 필수 입니다.")
String text,

@NotBlank
@NotBlank(message = "스킨 URL은 필수 입니다.")
String skinUrl
) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package site.timecapsulearchive.notification.data.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import site.timecapsulearchive.notification.entity.NotificationStatus;

public record FriendNotificationRequest(

@NotNull(message = "멤버 아이디는 필수 입니다.")
Long targetId,

@NotNull(message = "알림 상태는 필수 입니다.")
NotificationStatus status,

@NotBlank(message = "알림 제목은 필수 입니다.")
String text,

@NotBlank(message = "알림 내용은 필수 입니다.")
String title
) {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package site.timecapsulearchive.notification.entity;

public enum CategoryName {
CAPSULE_SKIN
CAPSULE_SKIN, FRIEND_REQUEST, FRIEND_ACCEPT, GROUP_INVITE
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private Notification(String title, String text, String imageUrl, Long memberId,
this.text = text;
this.imageUrl = imageUrl;
this.memberId = memberId;
this.status = status;
this.notificationCategory = notificationCategory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package site.timecapsulearchive.notification.global.config;

import java.util.Arrays;
import lombok.Getter;

@Getter
public enum RabbitmqComponentConstants {

CAPSULE_SKIN_QUEUE("notification.createCapsuleSkin.queue", "fail.notification.createCapsuleSkin.queue"),
CAPSULE_SKIN_EXCHANGE("notification.createCapsuleSkin.exchange", "fail.notification.createCapsuleSkin.exchange"),
FRIEND_REQUEST_NOTIFICATION_QUEUE("notification.friendRequest.queue", "fail.notification.friendRequest.queue"),
FRIEND_REQUEST_NOTIFICATION_EXCHANGE("notification.friendRequest.exchange", "fail.notification.friendRequest.exchange"),
FRIEND_REQUESTS_NOTIFICATION_QUEUE("notification.friendRequests.queue", "fail.notification.friendRequests.queue"),
FRIEND_REQUESTS_NOTIFICATION_EXCHANGE("notification.friendRequests.exchange", "fail.notification.friendRequests.exchange"),
FRIEND_ACCEPT_NOTIFICATION_QUEUE("notification.friendAccept.queue", "fail.notification.friendAccept.queue"),
FRIEND_ACCEPT_NOTIFICATION_EXCHANGE("notification.friendAccept.exchange", "fail.notification.friendAccept.exchange"),
GROUP_INVITE_QUEUE("notification.groupInvite.queue", "fail.notification.groupInvite.queue"),
GROUP_INVITE_EXCHANGE("notification.groupInvite.exchange", "fail.notification.groupInvite.exchange");

private final String successComponent;
private final String failComponent;

RabbitmqComponentConstants(String successComponent, String failComponent) {
this.successComponent = successComponent;
this.failComponent = failComponent;
}

public static String getFailComponent(String successComponent) {
return Arrays.stream(RabbitmqComponentConstants.values())
.filter(constants -> constants.getSuccessComponent().equals(successComponent))
.map(RabbitmqComponentConstants::getFailComponent)
.toList()
.get(0);
}
}
Loading

0 comments on commit f3e965f

Please sign in to comment.