From 97fd2ce42abcd9950597e79c0180e9e09c6e89ce Mon Sep 17 00:00:00 2001 From: 0702Yoon Date: Wed, 2 Oct 2024 12:26:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?refactor=20:=20class=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EC=98=A4=ED=83=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{AffiliationManger.java => AffiliationManager.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/example/bigbrotherbe/domain/affiliation/component/{AffiliationManger.java => AffiliationManager.java} (98%) diff --git a/src/main/java/com/example/bigbrotherbe/domain/affiliation/component/AffiliationManger.java b/src/main/java/com/example/bigbrotherbe/domain/affiliation/component/AffiliationManager.java similarity index 98% rename from src/main/java/com/example/bigbrotherbe/domain/affiliation/component/AffiliationManger.java rename to src/main/java/com/example/bigbrotherbe/domain/affiliation/component/AffiliationManager.java index 0b78783..ba2de60 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/affiliation/component/AffiliationManger.java +++ b/src/main/java/com/example/bigbrotherbe/domain/affiliation/component/AffiliationManager.java @@ -15,7 +15,7 @@ @Component @RequiredArgsConstructor -public class AffiliationManger { +public class AffiliationManager { private final AffiliationRepository affiliationRepository; private final AffiliationMemberRepository affiliationMemberRepository; From 153b8cb8d35a649059d256383d507a0e42535f34 Mon Sep 17 00:00:00 2001 From: 0702Yoon Date: Wed, 2 Oct 2024 12:27:33 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor=20:=20class=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EC=98=A4=ED=83=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../affiliation/service/AffiliationServiceImpl.java | 6 +++--- .../domain/member/component/MemberManager.java | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/example/bigbrotherbe/domain/affiliation/service/AffiliationServiceImpl.java b/src/main/java/com/example/bigbrotherbe/domain/affiliation/service/AffiliationServiceImpl.java index 1c891b8..bedf942 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/affiliation/service/AffiliationServiceImpl.java +++ b/src/main/java/com/example/bigbrotherbe/domain/affiliation/service/AffiliationServiceImpl.java @@ -1,6 +1,6 @@ package com.example.bigbrotherbe.domain.affiliation.service; -import com.example.bigbrotherbe.domain.affiliation.component.AffiliationManger; +import com.example.bigbrotherbe.domain.affiliation.component.AffiliationManager; import com.example.bigbrotherbe.domain.member.dto.response.AffiliationResponse; import com.example.bigbrotherbe.domain.member.entity.enums.AffiliationCode; @@ -18,13 +18,13 @@ @RequiredArgsConstructor public class AffiliationServiceImpl implements AffiliationService { - private final AffiliationManger affiliationManger; + private final AffiliationManager affiliationManager; private final String CollegeKoreanText = "단과대"; @Override public boolean checkExistAffiliationById(Long affiliationId) { - return affiliationManger.existsById(affiliationId); + return affiliationManager.existsById(affiliationId); } diff --git a/src/main/java/com/example/bigbrotherbe/domain/member/component/MemberManager.java b/src/main/java/com/example/bigbrotherbe/domain/member/component/MemberManager.java index f11ffae..59fa20c 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/member/component/MemberManager.java +++ b/src/main/java/com/example/bigbrotherbe/domain/member/component/MemberManager.java @@ -1,6 +1,6 @@ package com.example.bigbrotherbe.domain.member.component; -import com.example.bigbrotherbe.domain.affiliation.component.AffiliationManger; +import com.example.bigbrotherbe.domain.affiliation.component.AffiliationManager; import com.example.bigbrotherbe.domain.member.dto.request.SignUpDto; import com.example.bigbrotherbe.domain.member.dto.response.MemberInfoResponse; import com.example.bigbrotherbe.domain.member.dto.response.MemberResponse; @@ -29,7 +29,7 @@ public class MemberManager { private final MemberChecker memberChecker; private final MemberDeleter memberDeleter; private final MemberSaver memberSaver; - private final AffiliationManger affiliationManger; + private final AffiliationManager affiliationManager; @Transactional(rollbackFor = Exception.class) @@ -38,8 +38,8 @@ public MemberResponse userSignup(SignUpDto signUpDto) { String encodePassword = passwordEncoder.encode(signUpDto.getPassword()); Member member = signUpDto.toEntity(encodePassword); Member savedMember = memberSaver.saveMember(member); - AffiliationMember collegeMember = affiliationManger.createAfiiliationMember(savedMember,signUpDto.getCollege(), Role.ROLE_USER); - AffiliationMember affiliationMember = affiliationManger.createAfiiliationMember(savedMember,signUpDto.getAffiliation(),Role.ROLE_USER); + AffiliationMember collegeMember = affiliationManager.createAfiiliationMember(savedMember,signUpDto.getCollege(), Role.ROLE_USER); + AffiliationMember affiliationMember = affiliationManager.createAfiiliationMember(savedMember,signUpDto.getAffiliation(),Role.ROLE_USER); return MemberResponse.form( savedMember.getId(), @@ -60,7 +60,7 @@ public JwtToken signIn(String email, String password) { public AffiliationListDto getMemberAffiliationRoleList() { Member member = authUtil.getLoginMember(); - return affiliationListToEntity(member.getUsername(), affiliationManger.findAllByMemberId(member.getId())); + return affiliationListToEntity(member.getUsername(), affiliationManager.findAllByMemberId(member.getId())); } public Member getLoginMember() { From f510784bf6215d3e25e00bc97b281aa9c7205875 Mon Sep 17 00:00:00 2001 From: 0702Yoon Date: Wed, 2 Oct 2024 12:27:54 +0900 Subject: [PATCH 3/4] =?UTF-8?q?refactor=20:=20=EC=93=B0=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8A=94=20getCurrentUserName=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigbrotherbe/global/security/SecurityConfig.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/com/example/bigbrotherbe/global/security/SecurityConfig.java b/src/main/java/com/example/bigbrotherbe/global/security/SecurityConfig.java index 0b5c246..f211ce4 100644 --- a/src/main/java/com/example/bigbrotherbe/global/security/SecurityConfig.java +++ b/src/main/java/com/example/bigbrotherbe/global/security/SecurityConfig.java @@ -63,12 +63,5 @@ public PasswordEncoder passwordEncoder() { // BCrypt Encoder 사용 return PasswordEncoderFactories.createDelegatingPasswordEncoder(); } - public static String getCurrentUserName(){ - final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if(authentication == null || authentication.getName() == null){ - throw new RuntimeException("No authentication information"); - } - return authentication.getName(); - } } From 2a626263d794bd3b29c778c8e118aed8ab3c5f61 Mon Sep 17 00:00:00 2001 From: 0702Yoon Date: Wed, 2 Oct 2024 12:28:42 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat=20:=20member,=20admin=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/swagger/SwaggerConfig.java | 60 ++++++++++++++----- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/example/bigbrotherbe/global/swagger/SwaggerConfig.java b/src/main/java/com/example/bigbrotherbe/global/swagger/SwaggerConfig.java index aec14b5..f3cf3af 100644 --- a/src/main/java/com/example/bigbrotherbe/global/swagger/SwaggerConfig.java +++ b/src/main/java/com/example/bigbrotherbe/global/swagger/SwaggerConfig.java @@ -19,20 +19,36 @@ public class SwaggerConfig { @Bean public OpenAPI customOpenAPI() { return new OpenAPI() - .info(new Info().title("My API") - .version("1.0") - .description("My API Description")) - .servers(List.of( - new Server().url(DOMAIN_URL) // HTTPS로 설정 - .description("Production server") - )) - .components(new Components() - .addSecuritySchemes("Authorization", new SecurityScheme() - .type(SecurityScheme.Type.APIKEY) - .in(SecurityScheme.In.HEADER) - .name("Authorization") - )) - .addSecurityItem(new SecurityRequirement().addList("Authorization")); + .info(apiInfo()) + .servers(httpsServer()) + .components(createComponents()) + .addSecurityItem(createSecurityRequirement()); + } + + private static SecurityRequirement createSecurityRequirement() { + return new SecurityRequirement().addList("Authorization"); + } + + private static Components createComponents() { + return new Components() + .addSecuritySchemes("Authorization", new SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .in(SecurityScheme.In.HEADER) + .name("Authorization") + ); + } + + private static List httpsServer() { + return List.of( + new Server().url(DOMAIN_URL) // HTTPS로 설정 + .description("Production server") + ); + } + + private static Info apiInfo() { + return new Info().title("My API") + .version("1.0") + .description("My API Description"); } @Bean @@ -43,4 +59,20 @@ public GroupedOpenApi publicApi() { .build(); } + @Bean + public GroupedOpenApi memberApi() { + return GroupedOpenApi.builder() + .group("멤버 API") + .pathsToMatch("/api/v1/members/**") // 멤버 관련 엔드포인트만 포함 + .build(); + } + + @Bean + public GroupedOpenApi adminApi() { + return GroupedOpenApi.builder() + .group("어드민 API") + .pathsToMatch("/api/v1/admin/**") // 관리자 관련 엔드포인트만 포함 + .build(); + } + }