From e345b30c00c8961c9347bcb3565a9127fe289b95 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 16:20:01 +0900 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20MoneyFormatter=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/util/formatter/MoneyFormatter.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java diff --git a/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java b/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java new file mode 100644 index 000000000..2c71dc524 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java @@ -0,0 +1,17 @@ +package com.gdschongik.gdsc.global.util.formatter; + +import com.gdschongik.gdsc.domain.common.vo.Money; +import java.text.NumberFormat; +import java.util.Locale; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import lombok.NonNull; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class MoneyFormatter { + public static String format(@NonNull Money money) { + NumberFormat formatter = NumberFormat.getNumberInstance(Locale.KOREA); + String formattedAmount = formatter.format(money.getAmount()); + return formattedAmount + "원"; + } +} From 85ed95f94c8d64e605e7f5c7788a30f8975461e8 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 16:52:17 +0900 Subject: [PATCH 02/10] =?UTF-8?q?feat:=20=ED=95=99=EA=B8=B0=20=EC=9B=8C?= =?UTF-8?q?=EB=94=A9=EC=9D=84=20=ED=8F=AC=EB=A7=A4=ED=84=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdschongik/gdsc/domain/common/model/SemesterType.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index dace965f4..72a0b990a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -7,9 +7,9 @@ @Getter @AllArgsConstructor public enum SemesterType { - FIRST("1학기", MonthDay.of(3, 1)), - SECOND("2학기", MonthDay.of(9, 1)); + FIRST(1, MonthDay.of(3, 1)), + SECOND(2, MonthDay.of(9, 1)); - private final String value; + private final Integer value; private final MonthDay startDate; } From d45731055745c07b9a6ad07feb1de47baf69d25c Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 16:52:34 +0900 Subject: [PATCH 03/10] =?UTF-8?q?feat:=20=ED=95=99=EA=B8=B0=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=A4=ED=84=B0=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/AdminRecruitmentResponse.java | 4 +--- .../dto/response/AdminRecruitmentRoundResponse.java | 4 +--- .../gdsc/global/util/formatter/SemesterFormatter.java | 10 ++++++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentResponse.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentResponse.java index 9b9f4aaef..30c385517 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentResponse.java @@ -19,9 +19,7 @@ public static AdminRecruitmentResponse from(Recruitment recruitment) { return new AdminRecruitmentResponse( recruitment.getId(), - SemesterFormatter.format( - recruitment.getAcademicYear(), - recruitment.getSemesterType().getValue()), + SemesterFormatter.format(recruitment), recruitment.getSemesterPeriod().getStartDate(), recruitment.getSemesterPeriod().getEndDate(), String.format("%s원", decimalFormat.format(recruitment.getFee().getAmount())), diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentRoundResponse.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentRoundResponse.java index 57c2f36b9..b1b402497 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentRoundResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/response/AdminRecruitmentRoundResponse.java @@ -17,9 +17,7 @@ public static AdminRecruitmentRoundResponse from(RecruitmentRound recruitmentRou return new AdminRecruitmentRoundResponse( recruitmentRound.getId(), - SemesterFormatter.format( - recruitmentRound.getAcademicYear(), - recruitmentRound.getSemesterType().getValue()), + SemesterFormatter.format(recruitmentRound), recruitmentRound.getPeriod().getStartDate(), recruitmentRound.getPeriod().getEndDate(), recruitmentRound.getName(), diff --git a/src/main/java/com/gdschongik/gdsc/global/util/formatter/SemesterFormatter.java b/src/main/java/com/gdschongik/gdsc/global/util/formatter/SemesterFormatter.java index 679c47972..7612d5823 100644 --- a/src/main/java/com/gdschongik/gdsc/global/util/formatter/SemesterFormatter.java +++ b/src/main/java/com/gdschongik/gdsc/global/util/formatter/SemesterFormatter.java @@ -1,11 +1,17 @@ package com.gdschongik.gdsc.global.util.formatter; +import com.gdschongik.gdsc.domain.common.model.BaseSemesterEntity; import lombok.AccessLevel; import lombok.NoArgsConstructor; @NoArgsConstructor(access = AccessLevel.PRIVATE) public class SemesterFormatter { - public static String format(Integer academicYear, String semester) { - return String.format("%d-%s", academicYear, semester); + public static String format(BaseSemesterEntity semesterEntity) { + return semesterEntity.getAcademicYear() + "-" + + semesterEntity.getSemesterType().getValue(); + } + + public static String formatType(BaseSemesterEntity semesterEntity) { + return semesterEntity.getSemesterType().getValue() + "학기"; } } From e04c9e1e8b601d9038ddad700f7f87479d50db27 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 16:57:21 +0900 Subject: [PATCH 04/10] =?UTF-8?q?refactor:=20PhoneFormatter=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/global/util/formatter/PhoneFormatter.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java b/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java index 70d13a45a..600de92fc 100644 --- a/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java +++ b/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java @@ -7,14 +7,7 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class PhoneFormatter { public static String format(@Nullable String phone) { - return phone == null - ? null - : new StringBuilder(12) - .append(phone, 0, 3) - .append('-') - .append(phone, 3, 7) - .append('-') - .append(phone, 7, 11) - .toString(); + if (phone == null) return null; + return phone.substring(0, 3) + '-' + phone.substring(3, 7) + '-' + phone.substring(7, 11); } } From 178ae51af37275abb336a48e2cf2c75b12f86400 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 16:58:26 +0900 Subject: [PATCH 05/10] =?UTF-8?q?refactor:=20nullable=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdschongik/gdsc/global/util/formatter/PhoneFormatter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java b/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java index 600de92fc..1fd675919 100644 --- a/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java +++ b/src/main/java/com/gdschongik/gdsc/global/util/formatter/PhoneFormatter.java @@ -6,7 +6,7 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class PhoneFormatter { - public static String format(@Nullable String phone) { + @Nullable public static String format(@Nullable String phone) { if (phone == null) return null; return phone.substring(0, 3) + '-' + phone.substring(3, 7) + '-' + phone.substring(7, 11); } From c4fb79d2da39eaaed641e5313972cf0d2e5e33ba Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 17:03:44 +0900 Subject: [PATCH 06/10] =?UTF-8?q?refactor:=20PhoneFormatter=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/dto/response/AdminMemberResponse.java | 6 ++---- .../domain/member/dto/response/MemberBasicInfoResponse.java | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/AdminMemberResponse.java b/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/AdminMemberResponse.java index 11243865b..434921dc1 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/AdminMemberResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/AdminMemberResponse.java @@ -3,6 +3,7 @@ import com.gdschongik.gdsc.domain.member.domain.AssociateRequirement; import com.gdschongik.gdsc.domain.member.domain.Department; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.global.util.formatter.PhoneFormatter; import java.util.Optional; public record AdminMemberResponse( @@ -21,10 +22,7 @@ public static AdminMemberResponse from(Member member) { member.getId(), member.getStudentId(), member.getName(), - Optional.ofNullable(member.getPhone()) - .map(phone -> String.format( - "%s-%s-%s", phone.substring(0, 3), phone.substring(3, 7), phone.substring(7))) - .orElse(null), + PhoneFormatter.format(member.getPhone()), DepartmentDto.from(member.getDepartment()), member.getEmail(), member.getDiscordUsername(), diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberBasicInfoResponse.java b/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberBasicInfoResponse.java index df535bd19..986082d10 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberBasicInfoResponse.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberBasicInfoResponse.java @@ -2,6 +2,7 @@ import com.gdschongik.gdsc.domain.member.domain.Department; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.global.util.formatter.PhoneFormatter; import java.util.Optional; public record MemberBasicInfoResponse( @@ -18,10 +19,7 @@ public static MemberBasicInfoResponse from(Member member) { member.getId(), member.getStudentId(), member.getName(), - Optional.ofNullable(member.getPhone()) - .map(phone -> String.format( - "%s-%s-%s", phone.substring(0, 3), phone.substring(3, 7), phone.substring(7))) - .orElse(null), + PhoneFormatter.format(member.getPhone()), Optional.ofNullable(member.getDepartment()) .map(Department::getDepartmentName) .orElse(null), From 34a49a761a23fd2ebbcc2a34be613b7cfe04914a Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 17:06:39 +0900 Subject: [PATCH 07/10] =?UTF-8?q?feat:=20deprecated=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/OnboardingMemberController.java | 9 ---- .../application/OnboardingMemberService.java | 7 --- .../dto/response/MemberInfoResponse.java | 52 ------------------- 3 files changed, 68 deletions(-) delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberInfoResponse.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java b/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java index 07205df48..7e5d86514 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java @@ -5,7 +5,6 @@ import com.gdschongik.gdsc.domain.member.dto.request.OnboardingMemberUpdateRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberBasicInfoResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberDashboardResponse; -import com.gdschongik.gdsc.domain.member.dto.response.MemberInfoResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberUnivStatusResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -35,14 +34,6 @@ public ResponseEntity updateMember(@Valid @RequestBody OnboardingMemberUpd return ResponseEntity.ok().build(); } - @Deprecated - @Operation(summary = "회원 정보 조회", description = "회원 정보를 조회합니다.") - @GetMapping("/me") - public ResponseEntity getMemberInfo() { - MemberInfoResponse response = onboardingMemberService.getMemberInfo(); - return ResponseEntity.ok().body(response); - } - @Operation(summary = "내 대시보드 조회", description = "내 대시보드를 조회합니다. 2차 MVP 기능입니다.") @GetMapping("/me/dashboard") public ResponseEntity getDashboard() { diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java index 3a2d59677..f47076175 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java @@ -12,7 +12,6 @@ import com.gdschongik.gdsc.domain.member.dto.request.OnboardingMemberUpdateRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberBasicInfoResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberDashboardResponse; -import com.gdschongik.gdsc.domain.member.dto.response.MemberInfoResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberTokenResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberUnivStatusResponse; import com.gdschongik.gdsc.domain.membership.application.MembershipService; @@ -53,12 +52,6 @@ private void validateDiscordUsernameDuplicate(Member member) { } } - public MemberInfoResponse getMemberInfo() { - // TODO: 대시보드 API로 통합 - Member currentMember = memberUtil.getCurrentMember(); - return MemberInfoResponse.of(currentMember); - } - public MemberUnivStatusResponse checkUnivVerificationStatus() { Member currentMember = memberUtil.getCurrentMember(); return MemberUnivStatusResponse.from(currentMember); diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberInfoResponse.java b/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberInfoResponse.java deleted file mode 100644 index 4c2badab4..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/member/dto/response/MemberInfoResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.gdschongik.gdsc.domain.member.dto.response; - -import com.gdschongik.gdsc.domain.common.model.RequirementStatus; -import com.gdschongik.gdsc.domain.member.domain.Member; -import com.gdschongik.gdsc.domain.member.domain.MemberRole; -import com.gdschongik.gdsc.global.util.formatter.PhoneFormatter; -import io.swagger.v3.oas.annotations.media.Schema; - -public record MemberInfoResponse( - Long memberId, - String studentId, - String name, - String phone, - String department, - String email, - String discordUsername, - String nickname, - @Schema(description = "디스코드 연동 상태") RequirementStatus discordStatus, - @Schema(description = "GDSC Bevy 가입 상태") RequirementStatus bevyStatus, - @Schema(description = "가입 상태") MemberRole role, - @Schema(description = "입금자명") String depositorName, - @Schema(description = "가입 상태") RegistrationStatus registrationStatus) { - - // TODO: 2차 MVP 응답 스펙에 맞게 수정 필요 - public static MemberInfoResponse of(Member member) { - return new MemberInfoResponse( - member.getId(), - member.getStudentId(), - member.getName(), - PhoneFormatter.format(member.getPhone()), - member.getDepartment().getDepartmentName(), - member.getEmail(), - member.getDiscordUsername(), - member.getNickname(), - member.getAssociateRequirement().getDiscordStatus(), - member.getAssociateRequirement().getBevyStatus(), - member.getRole(), - String.format("%s%s", member.getName(), member.getPhone().substring(7)), - RegistrationStatus.from(member)); - } - - enum RegistrationStatus { - APPLIED, - PENDING, - GRANTED; - - // TODO: 2차 MVP 응답 스펙에 맞게 수정 필요 - static RegistrationStatus from(Member member) { - return GRANTED; - } - } -} From ec5dbd953b4ace613d8db32efb9ffbf159eeb2a7 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 17:12:23 +0900 Subject: [PATCH 08/10] =?UTF-8?q?feat:=20=EB=94=94=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=9A=8C=EC=9B=90=EC=A0=95=EB=B3=B4=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20API=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/api/OnboardingMemberController.java | 10 ---------- .../application/OnboardingMemberService.java | 15 --------------- 2 files changed, 25 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java b/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java index 7e5d86514..9bd572657 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/api/OnboardingMemberController.java @@ -2,7 +2,6 @@ import com.gdschongik.gdsc.domain.member.application.OnboardingMemberService; import com.gdschongik.gdsc.domain.member.dto.request.BasicMemberInfoRequest; -import com.gdschongik.gdsc.domain.member.dto.request.OnboardingMemberUpdateRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberBasicInfoResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberDashboardResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberUnivStatusResponse; @@ -13,7 +12,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -26,14 +24,6 @@ public class OnboardingMemberController { private final OnboardingMemberService onboardingMemberService; - @Deprecated - @Operation(summary = "디스코드 회원 정보 수정", description = "디스코드 회원 정보를 수정합니다.") - @PutMapping("/me/discord") - public ResponseEntity updateMember(@Valid @RequestBody OnboardingMemberUpdateRequest request) { - onboardingMemberService.updateMember(request); - return ResponseEntity.ok().build(); - } - @Operation(summary = "내 대시보드 조회", description = "내 대시보드를 조회합니다. 2차 MVP 기능입니다.") @GetMapping("/me/dashboard") public ResponseEntity getDashboard() { diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java index f47076175..d9cc6b700 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/OnboardingMemberService.java @@ -9,7 +9,6 @@ import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.member.dto.request.BasicMemberInfoRequest; import com.gdschongik.gdsc.domain.member.dto.request.MemberTokenRequest; -import com.gdschongik.gdsc.domain.member.dto.request.OnboardingMemberUpdateRequest; import com.gdschongik.gdsc.domain.member.dto.response.MemberBasicInfoResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberDashboardResponse; import com.gdschongik.gdsc.domain.member.dto.response.MemberTokenResponse; @@ -38,20 +37,6 @@ public class OnboardingMemberService { private final MemberRepository memberRepository; private final EnvironmentUtil environmentUtil; - @Deprecated - @Transactional - public void updateMember(OnboardingMemberUpdateRequest request) { - Member currentMember = memberUtil.getCurrentMember(); - validateDiscordUsernameDuplicate(currentMember); - currentMember.verifyDiscord(request.discordUsername(), request.nickname()); - } - - private void validateDiscordUsernameDuplicate(Member member) { - if (memberRepository.existsByDiscordUsername(member.getDiscordUsername())) { - throw new CustomException(MEMBER_DISCORD_USERNAME_DUPLICATE); - } - } - public MemberUnivStatusResponse checkUnivVerificationStatus() { Member currentMember = memberUtil.getCurrentMember(); return MemberUnivStatusResponse.from(currentMember); From e313502c15010a39bdf83e610202c65d0771b877 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 17:25:34 +0900 Subject: [PATCH 09/10] =?UTF-8?q?feat:=20=EB=94=94=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=ED=95=A9=EB=A5=98=ED=95=98=EA=B8=B0=20=EC=BB=A4?= =?UTF-8?q?=EB=A7=A8=EB=93=9C=20=EA=B4=80=EB=A0=A8=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/OnboardingDiscordService.java | 14 ------ .../handler/JoinCommandHandler.java | 43 ------------------- .../listener/JoinCommandListener.java | 24 ----------- .../dto/response/DiscordNicknameResponse.java | 8 ---- .../common/constant/DiscordConstant.java | 6 --- .../gdsc/global/config/DiscordConfig.java | 1 - .../gdsc/global/exception/ErrorCode.java | 1 - 7 files changed, 97 deletions(-) delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/discord/application/handler/JoinCommandHandler.java delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/discord/application/listener/JoinCommandListener.java delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/discord/dto/response/DiscordNicknameResponse.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/discord/application/OnboardingDiscordService.java b/src/main/java/com/gdschongik/gdsc/domain/discord/application/OnboardingDiscordService.java index 5c2b28e4a..8b2b5ecfa 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/discord/application/OnboardingDiscordService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/discord/application/OnboardingDiscordService.java @@ -9,7 +9,6 @@ import com.gdschongik.gdsc.domain.discord.dto.request.DiscordLinkRequest; import com.gdschongik.gdsc.domain.discord.dto.response.DiscordCheckDuplicateResponse; import com.gdschongik.gdsc.domain.discord.dto.response.DiscordCheckJoinResponse; -import com.gdschongik.gdsc.domain.discord.dto.response.DiscordNicknameResponse; import com.gdschongik.gdsc.domain.discord.dto.response.DiscordVerificationCodeResponse; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; @@ -83,19 +82,6 @@ private void updateDiscordId(String discordUsername, Member currentMember) { currentMember.updateDiscordId(discordId); } - @Transactional(readOnly = true) - public DiscordNicknameResponse checkDiscordRoleAssignable(String discordUsername) { - Member member = memberRepository - .findByDiscordUsername(discordUsername) - .orElseThrow(() -> new CustomException(MEMBER_NOT_FOUND)); - - if (!member.isRegular()) { - throw new CustomException(DISCORD_ROLE_UNASSIGNABLE); - } - - return DiscordNicknameResponse.of(member.getNickname()); - } - @Transactional(readOnly = true) public DiscordCheckDuplicateResponse checkUsernameDuplicate(String discordUsername) { boolean isExist = memberRepository.existsByDiscordUsername(discordUsername); diff --git a/src/main/java/com/gdschongik/gdsc/domain/discord/application/handler/JoinCommandHandler.java b/src/main/java/com/gdschongik/gdsc/domain/discord/application/handler/JoinCommandHandler.java deleted file mode 100644 index da646c5d4..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/discord/application/handler/JoinCommandHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.gdschongik.gdsc.domain.discord.application.handler; - -import static com.gdschongik.gdsc.global.common.constant.DiscordConstant.*; - -import com.gdschongik.gdsc.domain.discord.application.OnboardingDiscordService; -import com.gdschongik.gdsc.domain.discord.dto.response.DiscordNicknameResponse; -import com.gdschongik.gdsc.global.util.DiscordUtil; -import java.util.Objects; -import lombok.RequiredArgsConstructor; -import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.Role; -import net.dv8tion.jda.api.events.GenericEvent; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import org.springframework.stereotype.Component; - -@Deprecated -@Component -@RequiredArgsConstructor -public class JoinCommandHandler implements DiscordEventHandler { - - private final OnboardingDiscordService onboardingDiscordService; - private final DiscordUtil discordUtil; - - @Override - public void delegate(GenericEvent genericEvent) { - SlashCommandInteractionEvent event = (SlashCommandInteractionEvent) genericEvent; - - event.deferReply().setEphemeral(true).setContent(DEFER_MESSAGE_JOIN).queue(); - - String discordUsername = event.getUser().getName(); - DiscordNicknameResponse response = onboardingDiscordService.checkDiscordRoleAssignable(discordUsername); - - Member member = event.getMember(); - Role role = discordUtil.findRoleByName(MEMBER_ROLE_NAME); - Guild guild = Objects.requireNonNull(event.getGuild()); - - guild.addRoleToMember(member, role).queue(); - guild.modifyNickname(member, response.nickname()).queue(); - - event.getHook().sendMessage(REPLY_MESSAGE_JOIN).setEphemeral(true).queue(); - } -} diff --git a/src/main/java/com/gdschongik/gdsc/domain/discord/application/listener/JoinCommandListener.java b/src/main/java/com/gdschongik/gdsc/domain/discord/application/listener/JoinCommandListener.java deleted file mode 100644 index a5d947443..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/discord/application/listener/JoinCommandListener.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.gdschongik.gdsc.domain.discord.application.listener; - -import static com.gdschongik.gdsc.global.common.constant.DiscordConstant.*; - -import com.gdschongik.gdsc.domain.discord.application.handler.JoinCommandHandler; -import jakarta.validation.constraints.NotNull; -import lombok.RequiredArgsConstructor; -import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import net.dv8tion.jda.api.hooks.ListenerAdapter; - -@Deprecated -@Listener -@RequiredArgsConstructor -public class JoinCommandListener extends ListenerAdapter { - - private final JoinCommandHandler joinCommandHandler; - - @Override - public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { - if (event.getName().equals(COMMAND_NAME_JOIN)) { - joinCommandHandler.delegate(event); - } - } -} diff --git a/src/main/java/com/gdschongik/gdsc/domain/discord/dto/response/DiscordNicknameResponse.java b/src/main/java/com/gdschongik/gdsc/domain/discord/dto/response/DiscordNicknameResponse.java deleted file mode 100644 index 8983711cc..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/discord/dto/response/DiscordNicknameResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.gdschongik.gdsc.domain.discord.dto.response; - -public record DiscordNicknameResponse(String nickname) { - - public static DiscordNicknameResponse of(String nickname) { - return new DiscordNicknameResponse(nickname); - } -} diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/DiscordConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/DiscordConstant.java index 597bbcd31..81aa63986 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/DiscordConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/DiscordConstant.java @@ -15,12 +15,6 @@ private DiscordConstant() {} public static final String DEFER_MESSAGE_ISSUING_CODE = "인증코드를 발급받는 중입니다..."; public static final String REPLY_MESSAGE_ISSUING_CODE = "인증코드는 %d 입니다. 인증코드는 %d분 동안 유효합니다."; - // 가입하기 커맨드 - public static final String COMMAND_NAME_JOIN = "가입하기"; - public static final String COMMAND_DESCRIPTION_JOIN = "가입 신청이 승인된 멤버에게 역할을 부여합니다."; - public static final String DEFER_MESSAGE_JOIN = "가입 신청을 처리하는 중입니다..."; - public static final String REPLY_MESSAGE_JOIN = "가입 신청이 승인되었습니다. GDSC Hongik에 합류하신 것을 환영합니다!"; - // 디스코드 ID 저장 커맨드 public static final String COMMAND_NAME_BATCH_DISCORD_ID = "디스코드id-저장하기"; public static final String COMMAND_DESCRIPTION_BATCH_DISCORD_ID = "디스코드 인증이 완료된 멤버들의 디스코드 ID를 저장합니다."; diff --git a/src/main/java/com/gdschongik/gdsc/global/config/DiscordConfig.java b/src/main/java/com/gdschongik/gdsc/global/config/DiscordConfig.java index 2e605e99f..4b429d9dd 100644 --- a/src/main/java/com/gdschongik/gdsc/global/config/DiscordConfig.java +++ b/src/main/java/com/gdschongik/gdsc/global/config/DiscordConfig.java @@ -42,7 +42,6 @@ public JDA jda() { Objects.requireNonNull(jda.awaitReady().getGuildById(discordProperty.getServerId())) .updateCommands() .addCommands(Commands.slash(COMMAND_NAME_ISSUING_CODE, COMMAND_DESCRIPTION_ISSUING_CODE)) - .addCommands(Commands.slash(COMMAND_NAME_JOIN, COMMAND_DESCRIPTION_JOIN)) .addCommands(Commands.slash(COMMAND_NAME_BATCH_DISCORD_ID, COMMAND_DESCRIPTION_BATCH_DISCORD_ID)) .queue(); diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 57d2bf744..5b1af0388 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -63,7 +63,6 @@ public enum ErrorCode { DISCORD_INVALID_CODE_RANGE(HttpStatus.INTERNAL_SERVER_ERROR, "디스코드 인증코드는 4자리 숫자여야 합니다."), DISCORD_CODE_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 유저네임으로 발급된 디스코드 인증코드가 존재하지 않습니다."), DISCORD_CODE_MISMATCH(HttpStatus.CONFLICT, "디스코드 인증코드가 일치하지 않습니다."), - DISCORD_ROLE_UNASSIGNABLE(HttpStatus.INTERNAL_SERVER_ERROR, "디스코드 역할 부여가 불가능합니다. 가입 조건을 확인해주세요."), DISCORD_ROLE_NOT_FOUND(HttpStatus.NOT_FOUND, "디스코드 역할을 찾을 수 없습니다."), DISCORD_NOT_SIGNUP(HttpStatus.INTERNAL_SERVER_ERROR, "아직 가입신청서를 작성하지 않은 회원입니다."), DISCORD_NICKNAME_NOTNULL(HttpStatus.INTERNAL_SERVER_ERROR, "닉네임은 빈 값이 될 수 없습니다."), From 0536c9a761056b48fdf0aa905d15eaa05d3d1e03 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn Date: Sat, 20 Jul 2024 17:33:57 +0900 Subject: [PATCH 10/10] =?UTF-8?q?refactor:=20=EA=B8=88=EC=95=A1=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=A4=ED=84=B0=20=EB=A1=9C=EC=A7=81=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/global/util/formatter/MoneyFormatter.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java b/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java index 2c71dc524..a7f7c4f37 100644 --- a/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java +++ b/src/main/java/com/gdschongik/gdsc/global/util/formatter/MoneyFormatter.java @@ -9,9 +9,10 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class MoneyFormatter { + + public static final NumberFormat KOREA_NUMBER_FORMAT = NumberFormat.getNumberInstance(Locale.KOREA); + public static String format(@NonNull Money money) { - NumberFormat formatter = NumberFormat.getNumberInstance(Locale.KOREA); - String formattedAmount = formatter.format(money.getAmount()); - return formattedAmount + "원"; + return KOREA_NUMBER_FORMAT.format(money.getAmount()) + "원"; } }