From 39229be1e90719c7fa287dee15ea7110e8b0d7b7 Mon Sep 17 00:00:00 2001 From: yang Date: Wed, 3 Apr 2024 23:21:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?RAC-335=20refactor=20:=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=8A=AC=EB=9E=99=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EB=82=B4=EC=9A=A9=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/slack/SlackPaymentMessage.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/postgraduate/global/slack/SlackPaymentMessage.java b/src/main/java/com/postgraduate/global/slack/SlackPaymentMessage.java index e0c105ed..4518e69f 100644 --- a/src/main/java/com/postgraduate/global/slack/SlackPaymentMessage.java +++ b/src/main/java/com/postgraduate/global/slack/SlackPaymentMessage.java @@ -1,11 +1,6 @@ package com.postgraduate.global.slack; import com.postgraduate.domain.payment.domain.entity.Payment; -import com.postgraduate.domain.senior.domain.entity.Info; -import com.postgraduate.domain.senior.domain.entity.Senior; -import com.postgraduate.domain.user.domain.entity.User; -import com.postgraduate.domain.wish.domain.entity.Wish; -import com.postgraduate.domain.wish.domain.entity.constant.Status; import com.slack.api.Slack; import com.slack.api.model.Attachment; import com.slack.api.webhook.Payload; @@ -15,9 +10,9 @@ import org.springframework.stereotype.Component; import java.io.IOException; +import java.time.LocalDateTime; import java.util.List; -import static com.postgraduate.domain.wish.domain.entity.constant.Status.REJECTED; import static com.postgraduate.global.slack.SlackUtils.generateSlackField; @Component @@ -29,6 +24,7 @@ public class SlackPaymentMessage { @Value("${slack.pay_url}") private String paymentUrl; + public void sendPayment(Payment payment) { try { slackClient.send(paymentUrl, Payload.builder() @@ -42,18 +38,18 @@ public void sendPayment(Payment payment) { } } - //attach 생성 -> Field를 리스트로 담자 private Attachment generatePaymentAttachment(Payment payment) { - User user = payment.getUser(); - Senior senior = payment.getSenior(); - User seniorUser = senior.getUser(); + LocalDateTime createdAt = payment.getPaidAt(); return Attachment.builder() .color("2FC4B2") .title("결제정보") .fields(List.of( - generateSlackField("결제 금액 : ", String.valueOf(payment.getPay())), - generateSlackField("후배 닉네임 : ", user.getNickName()), - generateSlackField("선배 닉네임 : ", seniorUser.getNickName()) + generateSlackField("결제 시간 : " + + createdAt.getMonth().getValue() + "월 " + + createdAt.getDayOfMonth() + "일 " + + createdAt.getHour() + "시 " + + createdAt.getMinute() + "분 " + + createdAt.getSecond() + "초", null) )) .build(); } From 9cb789fedec78744af7c19f45428da9541157f66 Mon Sep 17 00:00:00 2001 From: yang Date: Wed, 3 Apr 2024 23:21:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?RAC-335=20refactor=20:=20=EA=B2=B0=EC=A0=9C?= =?UTF-8?q?=20=EC=8A=AC=EB=9E=99=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=82=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/slack/SlackSignUpMessage.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/postgraduate/global/slack/SlackSignUpMessage.java b/src/main/java/com/postgraduate/global/slack/SlackSignUpMessage.java index 46918e4b..75ae29ab 100644 --- a/src/main/java/com/postgraduate/global/slack/SlackSignUpMessage.java +++ b/src/main/java/com/postgraduate/global/slack/SlackSignUpMessage.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; import java.io.IOException; +import java.time.LocalDateTime; import java.util.List; import static com.postgraduate.domain.wish.domain.entity.constant.Status.REJECTED; @@ -56,37 +57,45 @@ public void sendSeniorSignUp(Senior senior) { } } - //attach 생성 -> Field를 리스트로 담자 private Attachment generateJuniorSignUpAttachment(User user, Wish wish) { + LocalDateTime createdAt = user.getCreatedAt(); Status status = wish.getStatus(); String wantMatching = status == REJECTED ? "X" : "O"; return Attachment.builder() .color("2FC4B2") .title("가입한 후배 정보") .fields(List.of( - generateSlackField("후배 닉네임 : ", user.getNickName()), - generateSlackField("후배 전화번호", user.getPhoneNumber()), - generateSlackField("후배 매칭희망 여부", wantMatching), - generateSlackField("후배 매칭희망 전공, 분야", wish.getMajor() + ", " + wish.getField()) + generateSlackField("가입 시간 : " + + createdAt.getMonth().getValue() + "월 " + + createdAt.getDayOfMonth() + "일 " + + createdAt.getHour() + "시 " + + createdAt.getMinute() + "분 " + + createdAt.getSecond() + "초", null), + generateSlackField("후배 닉네임 : " + user.getNickName(), null), + generateSlackField("후배 매칭희망 여부 : " + wantMatching, null), + generateSlackField("후배 매칭희망 전공, 분야 : " + (wish.getMajor() + " " + wish.getField()), null) )) .build(); } private Attachment generateSeniorSignUpAttachment(Senior senior) { + LocalDateTime createdAt = senior.getCreatedAt(); User user = senior.getUser(); Info info = senior.getInfo(); return Attachment.builder() .color("2FC4B2") .title("가입한 선배 정보") .fields(List.of( - generateSlackField("선배 닉네임 : ", user.getNickName()), - generateSlackField("선배 전화번호", user.getPhoneNumber()), - generateSlackField("선배 대학원", info.getPostgradu()), - generateSlackField("선배 랩실", info.getLab()), - generateSlackField("선배 교수님", info.getProfessor()), - generateSlackField("선배 전공", info.getMajor()), - generateSlackField("선배 분야", info.getField()), - generateSlackField("선배 키워드", info.getKeyword()) + generateSlackField("선배 닉네임 : " + user.getNickName(), null), + generateSlackField("가입 시간 : " + + createdAt.getMonth().getValue() + "월 " + + createdAt.getDayOfMonth() + "일 " + + createdAt.getHour() + "시 " + + createdAt.getMinute() + "분 " + + createdAt.getSecond() + "초", null), + generateSlackField("선배 대학원 : " + info.getPostgradu(), null), + generateSlackField("선배 연구실 : " + info.getLab(), null), + generateSlackField("선배 교수님 : " + info.getProfessor(), null) )) .build(); }