From 3a638190ec0c7c40e7f7ad9da50132021356c1cd Mon Sep 17 00:00:00 2001 From: BlackBean99 <54030889+BlackBean99@users.noreply.github.com> Date: Tue, 13 Feb 2024 00:44:27 +0900 Subject: [PATCH] [BE-50] Mongo Atlas -> local Mongo Migration Setting #155 --- .../executionHistory/executionHistory.bin | Bin 9188529 -> 9409632 bytes .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes .../.gradle/7.6.1/fileHashes/fileHashes.bin | Bin 262569 -> 262769 bytes .../.gradle/7.6.1/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes server/.gradle/file-system.probe | Bin 8 -> 8 bytes .../aggregate/AnswerCreatedEventListener.java | 54 ++++++++++++++++++ ...icantRegisterEventConfirmEmailHandler.java | 8 +-- .../service/AnswerCommandService.java | 35 ++---------- ...SlackSendAndCardRegisterEventHandler.java} | 7 ++- .../econovation/recruit/utils/DataInit.java | 3 +- .../src/main/resources/application.yml | 5 ++ .../apache/CommonsEmailSender.java | 12 +++- .../resources/application-infrastructure.yml | 2 +- server/docker-compose.yml | 11 +++- 15 files changed, 91 insertions(+), 46 deletions(-) rename server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/{ApplicantRegisterEventHandler.java => ApplicantSlackSendAndCardRegisterEventHandler.java} (83%) diff --git a/server/.gradle/7.6.1/executionHistory/executionHistory.bin b/server/.gradle/7.6.1/executionHistory/executionHistory.bin index acf9f7ac262163382b4227cfba43f188b1e8d904..56267e20774f5139fad0374265172f41487093cc 100644 GIT binary patch delta 1809 zcmZwGdoZI6oL1#I8~**_O(pqHQ}#`|@i=^$-D(umPfABZwdxVjvd85C@we9yWsn5+D(hU<)LJ6t+SN$Y2}D zAr-d64oHKYkPf>b12Q2CcEcXXh8)-nxsV6>PymIn4~nP;W5u|UlPir8brz1(7#pI? zWeKry5^>DDR7p&nR4U`~Tw~{L-nL`MCOJO3$)|=`aI^g>b8hxABb6>DsVY@5Bh6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ac640dc503686fab3db084c3c9986b..169b5f9332fb914b673696b40013f7931bda46ad 100644 GIT binary patch literal 17 UcmZSnnEFb{yE#yV0Sp8b05CWMxc~qF literal 17 UcmZSnnEFb{yE#yV0SpAB05CEGvj6}9 diff --git a/server/.gradle/7.6.1/fileHashes/fileHashes.bin b/server/.gradle/7.6.1/fileHashes/fileHashes.bin index 9c98e1ea08928293b22c9e376a407c6d1bec9bda..23db0517d2d0e898e3904d49da2056d630e57270 100644 GIT binary patch delta 677 zcmZ44Eby^KV1tPSW8h{}i9}BRmB*Hzn5BN70R&hWZ*T5ZG!|oB$-vN>JiUQ~IkVZ# zV!N9KW93H08NAcy<}&k5whtEGe(NXGTxQ0c?G=BS6y^CRMOqmw^V|c`$GCF) z1R3VvOpJyb6(2yfO!p0A6yCm6m-$qZ!Y$dTn=E|KqD{*VeTaX)CkO1L)>B&`PU7gF ze$$ajb^DeH%rkivZVO~OYq?fz^&SQ?`{;U)S5s-13 zzLAwlc>9xi%;pl)H_l@gMV8xcy`6cPv%JpR#go@Z%-^vroArNoF85rhnLx8afOop! zb|&HJ!oQhCSmv(2q_JJkGIi1}=# zQ&+Q;P5=6zIfbCgt(7bWjMGC!nfS$1x#a{`U;Q`#dX(yS_pGTlC%b7$;8m;b2ys-pRq7(ClWh-OYk=N;YHI_S=gY z6NR>iY-8NT%cwYgt0!~FcJCvMHCv}Ik7W{O?d3SL>;Clpu}o6ie^xSW_Gir7zV;;3 zLDA`%Qy3GrKfBLl#lx7mQE>zB^trjre3R{ig}2}O$uyUlF?)N(UnWKQ$=_TJwm+0% zKE%W*xl!>4MA>xTFh=3+OLdt~B~9ml&1^LNwIh@8_AL{bXYwjMKKX_Jti+2ATQ+np z*9#RWXJBCLo%C=1V+Jtb2%DZek2#Xt#%3u*K*nkMMpmHaC-a!iB^0 qna = event.getQna(); MongoAnswer answer = MongoAnswer.builder() .id(event.getId()) .year(event.getYear()) .qna(event.getQna()) .build(); + // 학번으로 중복 체크 + validateRegisterApplicant(qna); + answerAdaptor.save(answer); + String name = qna.get("name").toString().replace("\"", ""); + ; + String hopeField = qna.get("field").toString().replace("\"", ""); + ; + String email = qna.get("email").toString().replace("\"", ""); + ; + // email 전송 event처리 + ApplicantRegisterEvent applicantRegisterEvent = + ApplicantRegisterEvent.of(answer.getId(), name, hopeField, email); + Events.raise(applicantRegisterEvent); + } + + private Validation, Map> validateRegisterApplicant( + Map qna) { + return Validation.combine(validateDuplicateSudentId(qna), validateIsRightPosition(qna)) + .ap((a, b) -> qna); + } + + private Validation validateIsRightPosition( + Map qna) { + String field = qna.get("field").toString().replace("\"", ""); + ; + if (field.equals("기획자") || field.equals("개발자") || field.equals("디자이너")) { + return Validation.valid(qna); + } + throw ApplicantWrongPositionException.EXCEPTION; + } + + private Validation> validateDuplicateSudentId( + Map qna) { + String studentId = qna.get("classOf").toString().replace("\"", ""); + ; + if (answerAdaptor.existsByAnswer(studentId, year)) { + throw ApplicantDuplicateSubmitException.EXCEPTION; + } + return Validation.valid(qna); } } diff --git a/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/handler/ApplicantRegisterEventConfirmEmailHandler.java b/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/handler/ApplicantRegisterEventConfirmEmailHandler.java index 6aae477f..8295d291 100644 --- a/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/handler/ApplicantRegisterEventConfirmEmailHandler.java +++ b/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/handler/ApplicantRegisterEventConfirmEmailHandler.java @@ -1,6 +1,5 @@ package com.econovation.recruit.api.applicant.handler; -import com.econovation.recruit.api.user.helper.NcpMailHelper; import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantRegisterEvent; import com.econovation.recruitinfrastructure.apache.CommonsEmailSender; import lombok.RequiredArgsConstructor; @@ -16,7 +15,6 @@ @RequiredArgsConstructor @Slf4j public class ApplicantRegisterEventConfirmEmailHandler { - private final NcpMailHelper ncpMailHelper; private final CommonsEmailSender commonsEmailSender; @Async @@ -25,9 +23,9 @@ public class ApplicantRegisterEventConfirmEmailHandler { phase = TransactionPhase.AFTER_COMMIT) @Transactional(propagation = Propagation.REQUIRES_NEW) public void handle(ApplicantRegisterEvent applicantRegistEvent) { - log.info("%s님의 지원서가 접수되었습니다.", applicantRegistEvent.getUserName()); - String email = applicantRegistEvent.getEmail().replace("\"", ""); - commonsEmailSender.send(email, applicantRegistEvent.getApplicantId()); + log.info(applicantRegistEvent.getUserName() + "님의 지원서가 접수되었습니다."); + commonsEmailSender.send( + applicantRegistEvent.getEmail(), applicantRegistEvent.getApplicantId()); } private String generateConfirmRegisterEmailBody(String userName) { diff --git a/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/service/AnswerCommandService.java b/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/service/AnswerCommandService.java index 5c273b24..64da625c 100644 --- a/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/service/AnswerCommandService.java +++ b/server/Recruit-Api/src/main/java/com/econovation/recruit/api/applicant/service/AnswerCommandService.java @@ -1,20 +1,16 @@ package com.econovation.recruit.api.applicant.service; import com.econovation.recruit.api.applicant.usecase.ApplicantCommandUseCase; -import com.econovation.recruitcommon.exception.RecruitCodeException; import com.econovation.recruitdomain.common.aop.domainEvent.Events; import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswer; import com.econovation.recruitdomain.domains.applicant.domain.MongoAnswerAdaptor; import com.econovation.recruitdomain.domains.applicant.event.domainevent.ApplicantRegisterEvent; -import com.econovation.recruitdomain.domains.applicant.exception.ApplicantDuplicateSubmitException; -import com.econovation.recruitdomain.domains.applicant.exception.ApplicantWrongPositionException; -import io.vavr.collection.Seq; -import io.vavr.control.Validation; import java.util.Map; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor @@ -25,11 +21,12 @@ public class AnswerCommandService implements ApplicantCommandUseCase { private Integer year; @Override + @Transactional public UUID execute(Map qna) { UUID id = UUID.randomUUID(); MongoAnswer answer = MongoAnswer.builder().id(id.toString()).qna(qna).year(year).build(); - // 학번으로 중복 체크 - validateRegisterApplicant(qna); + // 학번으로 중복 체크 + // validateRegisterApplicant(qna); answerAdaptor.save(answer); String name = qna.get("name").toString(); @@ -41,28 +38,4 @@ public UUID execute(Map qna) { Events.raise(applicantRegisterEvent); return id; } - - private Validation, Map> validateRegisterApplicant( - Map qna) { - return Validation.combine(validateDuplicateSudentId(qna), validateIsRightPosition(qna)) - .ap((a, b) -> qna); - } - - private Validation validateIsRightPosition( - Map qna) { - String field = qna.get("field").toString(); - if (field.equals("기획자") || field.equals("개발자") || field.equals("디자이너")) { - return Validation.valid(qna); - } - throw ApplicantWrongPositionException.EXCEPTION; - } - - private Validation> validateDuplicateSudentId( - Map qna) { - String studentId = qna.get("classOf").toString(); - if (answerAdaptor.existsByAnswer(studentId, year)) { - throw ApplicantDuplicateSubmitException.EXCEPTION; - } - return Validation.valid(qna); - } } diff --git a/server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/ApplicantRegisterEventHandler.java b/server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/ApplicantSlackSendAndCardRegisterEventHandler.java similarity index 83% rename from server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/ApplicantRegisterEventHandler.java rename to server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/ApplicantSlackSendAndCardRegisterEventHandler.java index 5c341b39..53a32a5e 100644 --- a/server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/ApplicantRegisterEventHandler.java +++ b/server/Recruit-Api/src/main/java/com/econovation/recruit/api/slack/handler/ApplicantSlackSendAndCardRegisterEventHandler.java @@ -18,7 +18,7 @@ @Component @RequiredArgsConstructor @Slf4j -public class ApplicantRegisterEventHandler { +public class ApplicantSlackSendAndCardRegisterEventHandler { private final SlackMessageProvider slackMessageProvider; private final SlackProperties slackProperties; private final CardAdaptor cardAdaptor; @@ -45,7 +45,10 @@ public void handle(ApplicantRegisterEvent applicantRegistEvent) { private String generateApplicantRegisterMessage(ApplicantRegisterEvent applicantRegistEvent) { return String.format( - ":clapping: 지원자가 등록되었습니다.:clapping:\n" + ":drum_with_drumsticks:두둥-탁 -!\n" + + ":space_invader::black_small_square::space_invader::black_small_square::space_invader::black_small_square::space_invader::black_small_square::space_invader::black_small_square:\n" + + ":sparkles::eyes:새로운 지원자 등장:eyes::sparkles:\n" + + ":black_small_square::space_invader::black_small_square::space_invader::black_small_square::space_invader::black_small_square::space_invader::black_small_square::space_invader:\n" + ":chikorita: 지원자 이름: %s\n" + ":chikorita:희망 분야: %s", applicantRegistEvent.getUserName(), applicantRegistEvent.getHopeField()); diff --git a/server/Recruit-Api/src/main/java/com/econovation/recruit/utils/DataInit.java b/server/Recruit-Api/src/main/java/com/econovation/recruit/utils/DataInit.java index 211e9d35..ec7ebca1 100644 --- a/server/Recruit-Api/src/main/java/com/econovation/recruit/utils/DataInit.java +++ b/server/Recruit-Api/src/main/java/com/econovation/recruit/utils/DataInit.java @@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.core.io.ClassPathResource; import org.springframework.jdbc.datasource.init.ScriptUtils; import org.springframework.security.crypto.password.PasswordEncoder; @@ -18,7 +19,7 @@ // @Component @RequiredArgsConstructor @Slf4j -// @ConditionalOnProperty(name = "data.init.disabled", havingValue = "false", matchIfMissing = true) +@ConditionalOnProperty(name = "data.init.disabled", havingValue = "false", matchIfMissing = true) public class DataInit { private final DataSource dataSource; private final InterviewerRecordPort interviewerRecordPort; diff --git a/server/Recruit-Api/src/main/resources/application.yml b/server/Recruit-Api/src/main/resources/application.yml index 450ffc87..a6a01bcf 100644 --- a/server/Recruit-Api/src/main/resources/application.yml +++ b/server/Recruit-Api/src/main/resources/application.yml @@ -22,6 +22,11 @@ throttle: auth: blacklist: prefix: ${JWT_BLACKLIST_PREFIX:BlackList_AccessToken_} +notification: + email: + enabled: ${NOTIFICATION_EMAIL_ENABLED:true} + slack: + enabled: ${NOTIFICATION_SLACK_ENABLED:true} login: page: url: ${LOGIN_PAGE_URL:http://localhost:8080/login} diff --git a/server/Recruit-Infrastructure/src/main/java/com/econovation/recruitinfrastructure/apache/CommonsEmailSender.java b/server/Recruit-Infrastructure/src/main/java/com/econovation/recruitinfrastructure/apache/CommonsEmailSender.java index 4c514b0a..f4e9e5f8 100644 --- a/server/Recruit-Infrastructure/src/main/java/com/econovation/recruitinfrastructure/apache/CommonsEmailSender.java +++ b/server/Recruit-Infrastructure/src/main/java/com/econovation/recruitinfrastructure/apache/CommonsEmailSender.java @@ -4,6 +4,7 @@ import org.apache.commons.mail.EmailException; import org.apache.commons.mail.HtmlEmail; import org.apache.commons.mail.SimpleEmail; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component @@ -11,6 +12,9 @@ public class CommonsEmailSender { private final CommonsEmailProperties commonsEmailProperties; + @Value("${econovation.year}") + private Integer year; + public void send(String toEmail, String name, String contents) { SimpleEmail email = new SimpleEmail(); email.setCharset("euc-kr"); @@ -29,7 +33,7 @@ public void send(String toEmail, String name, String contents) { email.setContent(contents, "text/html; charset=euc-kr"); email.send(); } catch (EmailException e) { - throw new RuntimeException(e); + throw new IllegalArgumentException(e); } } @@ -51,13 +55,15 @@ public void send(String toEmail, String applicantId) { email.setHtmlMsg(generateHtml(applicantId)); email.send(); } catch (EmailException e) { - throw new RuntimeException(e); + throw new IllegalArgumentException(e); } } private String generateHtml(String applicantId) { String html = - " Econovation Recruit
\"econo-3d-logo\"

신입모집 지원 완료!

에코노베이션 26기 지원서가 정상적으로 업로드 되었습니다
서류 합격 결과는 9월 19일에 개인 메일으로 공지 될 예정입니다.
여기에서 지원서를 확인하실 수 있습니다.
지원해주셔서 감사합니다.
"; + " Econovation Recruit
\"econo-3d-logo\"

신입모집 지원 완료!

에코노베이션 " + + year + + "기 지원서가 정상적으로 업로드 되었습니다
서류 합격 결과는 9월 19일에 개인 메일으로 공지 될 예정입니다.
여기에서 지원서를 확인하실 수 있습니다.
지원해주셔서 감사합니다.
"; return html.replace("%APPLICANT_ID%", applicantId); } } diff --git a/server/Recruit-Infrastructure/src/main/resources/application-infrastructure.yml b/server/Recruit-Infrastructure/src/main/resources/application-infrastructure.yml index 344d5b08..e6c206c2 100644 --- a/server/Recruit-Infrastructure/src/main/resources/application-infrastructure.yml +++ b/server/Recruit-Infrastructure/src/main/resources/application-infrastructure.yml @@ -12,7 +12,7 @@ ncp: access-key: ${NCP_ACCESS_KEY} secret-key: ${NCP_SECRET_KEY} sender-address: ${NCP_SENDER_ADDRESS:} - send-url: ${NCP_MAIL_URL:https://mail.apigw.gov-ntruss.com} + send-url: ${NCP_MAIL_URL:https://mail.apigw.gov-ntruss. com} commons: email: host: ${COMMONS_EMAIL_HOST:smtp.naver.com} diff --git a/server/docker-compose.yml b/server/docker-compose.yml index 4fd9dc09..94ad08e6 100644 --- a/server/docker-compose.yml +++ b/server/docker-compose.yml @@ -1,15 +1,20 @@ version: "3.7" services: redis: - image: "redis:alpine" + image: redis:alpine + hostname: redis + container_name: redis network_mode: "host" + axon-server: image: axoniq/axonserver:4.6.11 container_name: axon-server restart: unless-stopped + network_mode: "host" ports: - "8024:8024" - "8124:8124" + backend: image: blackbean99/econo-recruit:latest restart: unless-stopped @@ -20,5 +25,5 @@ services: environment: - TZ=Asia/Seoul depends_on: - - axon-server - - redis \ No newline at end of file + - redis + - axon-server \ No newline at end of file