Skip to content

Commit

Permalink
v1.2.0 (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
uwoobeat authored Mar 1, 2024
2 parents 30346c7 + dda8433 commit f3e87b9
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import com.gdschongik.gdsc.domain.member.dto.request.MemberPaymentRequest;
import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest;
import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest;
import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse;
import com.gdschongik.gdsc.domain.member.dto.response.AdminMemberResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberGrantResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberPaymentFindAllResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberPendingFindAllResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand All @@ -36,8 +34,8 @@ public class AdminMemberController {

@Operation(summary = "전체 회원 목록 조회", description = "전체 회원 목록을 조회합니다.")
@GetMapping
public ResponseEntity<Page<MemberFindAllResponse>> getMembers(MemberQueryRequest queryRequest, Pageable pageable) {
Page<MemberFindAllResponse> response = adminMemberService.findAll(queryRequest, pageable);
public ResponseEntity<Page<AdminMemberResponse>> getMembers(MemberQueryRequest queryRequest, Pageable pageable) {
Page<AdminMemberResponse> response = adminMemberService.findAll(queryRequest, pageable);
return ResponseEntity.ok().body(response);
}

Expand All @@ -50,9 +48,9 @@ public ResponseEntity<Void> withdrawMember(@PathVariable Long memberId) {

@Operation(summary = "대기중인 회원 목록 조회", description = "대기중인 회원 목록을 조회합니다.")
@GetMapping("/pending")
public ResponseEntity<Page<MemberPendingFindAllResponse>> getPendingMembers(
public ResponseEntity<Page<AdminMemberResponse>> getPendingMembers(
MemberQueryRequest queryRequest, Pageable pageable) {
Page<MemberPendingFindAllResponse> response = adminMemberService.findAllPendingMembers(queryRequest, pageable);
Page<AdminMemberResponse> response = adminMemberService.findAllPendingMembers(queryRequest, pageable);
return ResponseEntity.ok().body(response);
}

Expand All @@ -73,19 +71,19 @@ public ResponseEntity<MemberGrantResponse> grantMember(@Valid @RequestBody Membe

@Operation(summary = "승인 가능 회원 전체 조회", description = "승인 가능한 회원 전체를 조회합니다.")
@GetMapping("/grantable")
public ResponseEntity<Page<MemberFindAllResponse>> getGrantableMembers(
public ResponseEntity<Page<AdminMemberResponse>> getGrantableMembers(
MemberQueryRequest queryRequest, Pageable pageable) {
Page<MemberFindAllResponse> response = adminMemberService.getGrantableMembers(queryRequest, pageable);
Page<AdminMemberResponse> response = adminMemberService.getGrantableMembers(queryRequest, pageable);
return ResponseEntity.ok().body(response);
}

@Operation(summary = "회비 납부 상태에 따른 회원 전체 조회", description = "회비 납부 상태에 따라 회원 목록을 조회합니다.")
@GetMapping("/payment")
public ResponseEntity<Page<MemberPaymentFindAllResponse>> getMembersByPaymentStatus(
public ResponseEntity<Page<AdminMemberResponse>> getMembersByPaymentStatus(
MemberQueryRequest queryRequest,
@RequestParam(name = "status", required = false) RequirementStatus paymentStatus,
Pageable pageable) {
Page<MemberPaymentFindAllResponse> response =
Page<AdminMemberResponse> response =
adminMemberService.getMembersByPaymentStatus(queryRequest, paymentStatus, pageable);
return ResponseEntity.ok().body(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
import com.gdschongik.gdsc.domain.member.dto.request.MemberPaymentRequest;
import com.gdschongik.gdsc.domain.member.dto.request.MemberQueryRequest;
import com.gdschongik.gdsc.domain.member.dto.request.MemberUpdateRequest;
import com.gdschongik.gdsc.domain.member.dto.response.MemberFindAllResponse;
import com.gdschongik.gdsc.domain.member.dto.response.AdminMemberResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberGrantResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberPaymentFindAllResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberPendingFindAllResponse;
import com.gdschongik.gdsc.global.exception.CustomException;
import com.gdschongik.gdsc.global.exception.ErrorCode;
import java.util.List;
Expand All @@ -31,9 +29,9 @@ public class AdminMemberService {

private final MemberRepository memberRepository;

public Page<MemberFindAllResponse> findAll(MemberQueryRequest queryRequest, Pageable pageable) {
public Page<AdminMemberResponse> findAll(MemberQueryRequest queryRequest, Pageable pageable) {
Page<Member> members = memberRepository.findAll(queryRequest, pageable);
return members.map(MemberFindAllResponse::of);
return members.map(AdminMemberResponse::from);
}

@Transactional
Expand All @@ -56,10 +54,9 @@ public void updateMember(Long memberId, MemberUpdateRequest request) {
request.nickname());
}

public Page<MemberPendingFindAllResponse> findAllPendingMembers(
MemberQueryRequest queryRequest, Pageable pageable) {
public Page<AdminMemberResponse> findAllPendingMembers(MemberQueryRequest queryRequest, Pageable pageable) {
Page<Member> members = memberRepository.findAllByRole(queryRequest, MemberRole.GUEST, pageable);
return members.map(MemberPendingFindAllResponse::of);
return members.map(AdminMemberResponse::from);
}

@Transactional
Expand All @@ -70,15 +67,15 @@ public MemberGrantResponse grantMember(MemberGrantRequest request) {
return MemberGrantResponse.from(classifiedMember);
}

public Page<MemberFindAllResponse> getGrantableMembers(MemberQueryRequest queryRequest, Pageable pageable) {
public Page<AdminMemberResponse> getGrantableMembers(MemberQueryRequest queryRequest, Pageable pageable) {
Page<Member> members = memberRepository.findAllGrantable(queryRequest, pageable);
return members.map(MemberFindAllResponse::of);
return members.map(AdminMemberResponse::from);
}

public Page<MemberPaymentFindAllResponse> getMembersByPaymentStatus(
public Page<AdminMemberResponse> getMembersByPaymentStatus(
MemberQueryRequest queryRequest, RequirementStatus paymentStatus, Pageable pageable) {
Page<Member> members = memberRepository.findAllByPaymentStatus(queryRequest, paymentStatus, pageable);
return members.map(MemberPaymentFindAllResponse::from);
return members.map(AdminMemberResponse::from);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,16 @@ private BooleanBuilder queryOption(MemberQueryRequest queryRequest) {
.and(eqStudentId(queryRequest.studentId()))
.and(eqName(queryRequest.name()))
.and(eqPhone(queryRequest.phone()))
.and(eqDepartment(queryRequest.department()))
.and(inDepartmentList(Department.getDepartmentCodes(queryRequest.department())))
.and(eqEmail(queryRequest.email()))
.and(eqDiscordUsername(queryRequest.discordUsername()))
.and(eqNickname(queryRequest.nickname()));
}

private BooleanExpression inDepartmentList(List<Department> departmentCodes) {
return departmentCodes != null ? member.department.in(departmentCodes) : null;
}

private BooleanExpression eqStudentId(String studentId) {
return studentId != null ? member.studentId.containsIgnoreCase(studentId) : null;
}
Expand All @@ -195,10 +199,6 @@ private BooleanExpression eqPhone(String phone) {
return phone != null ? member.phone.contains(phone.replaceAll("-", "")) : null;
}

private BooleanExpression eqDepartment(Department department) {
return department != null ? member.department.eq(department) : null;
}

private BooleanExpression eqEmail(String email) {
return email != null ? member.email.containsIgnoreCase(email) : null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.gdschongik.gdsc.domain.member.domain;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import lombok.AllArgsConstructor;
import lombok.Getter;

Expand Down Expand Up @@ -85,4 +88,12 @@ public enum Department {
D077("영어교육과");

private String departmentName;

public static List<Department> getDepartmentCodes(String keyword) {
return Optional.ofNullable(keyword)
.map(s -> Arrays.stream(Department.values())
.filter(department -> department.getDepartmentName().contains(s))
.toList())
.orElse(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import static com.gdschongik.gdsc.global.common.constant.RegexConstant.*;

import com.gdschongik.gdsc.domain.member.domain.Department;
import io.swagger.v3.oas.annotations.media.Schema;

public record MemberQueryRequest(
@Schema(description = "학번", pattern = STUDENT_ID) String studentId,
@Schema(description = "이름") String name,
@Schema(description = "전화번호", pattern = PHONE_WITHOUT_HYPHEN) String phone,
@Schema(description = "학과") Department department,
@Schema(description = "학과") String department,
@Schema(description = "이메일") String email,
@Schema(description = "디스코드 유저네임") String discordUsername,
@Schema(description = "커뮤니티 닉네임", pattern = NICKNAME) String nickname) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.gdschongik.gdsc.domain.member.dto.response;

import com.gdschongik.gdsc.domain.member.domain.Department;
import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.member.domain.Requirement;
import java.util.Optional;

public record AdminMemberResponse(
Long memberId,
String studentId,
String name,
String phone,
DepartmentDto department,
String email,
String discordUsername,
String nickname,
RequirementDto requirement) {

public static AdminMemberResponse from(Member member) {
return new AdminMemberResponse(
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),
DepartmentDto.from(member.getDepartment()),
member.getEmail(),
member.getDiscordUsername(),
member.getNickname(),
RequirementDto.from(member.getRequirement()));
}

record DepartmentDto(Department code, String name) {
public static DepartmentDto from(Department department) {
return Optional.ofNullable(department)
.map(code -> new DepartmentDto(code, code.getDepartmentName()))
.orElse(new DepartmentDto(null, null));
}
}

record RequirementDto(String univStatus, String discordStatus, String paymentStatus, String bevyStatus) {
public static RequirementDto from(Requirement requirement) {
return new RequirementDto(
requirement.getUnivStatus().name(),
requirement.getDiscordStatus().name(),
requirement.getPaymentStatus().name(),
requirement.getBevyStatus().name());
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
public class SecurityConstant {

public static final String LANDING_STATUS_PARAM = "landing-status";
public static final String ACCESS_TOKEN_PARAM = "access";
public static final String REFRESH_TOKEN_PARAM = "refresh";
public static final String TOKEN_ROLE_NAME = "role";
public static final String GITHUB_NAME_ATTR_KEY = "id";
public static final String ACCESS_TOKEN_HEADER_PREFIX = "Bearer ";
public static final String ACCESS_TOKEN_HEADER_NAME = "Authorization";
public static final String OAUTH_BASE_URI_COOKIE_NAME = "oauth-base-uri";
public static final String OAUTH_REDIRECT_PATH_SEGMENT = "/social-login/redirect";

private SecurityConstant() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@

import static com.gdschongik.gdsc.global.common.constant.SecurityConstant.*;

import java.util.List;

public class UrlConstant {

private UrlConstant() {}

public static final String PROD_CLIENT_URL = "https://onboarding.gdschongik.com";
public static final String DEV_CLIENT_URL = "https://dev-onboarding.gdschongik.com";
// 클라이언트 URL
public static final String PROD_CLIENT_ONBOARDING_URL = "https://onboarding.gdschongik.com";
public static final String PROD_CLIENT_ADMIN_URL = "https://admin.gdschongik.com";
public static final String DEV_CLIENT_ONBOARDING_URL = "https://dev-onboarding.gdschongik.com";
public static final String DEV_CLIENT_ADMIN_URL = "https://dev-admin.gdschongik.com";
public static final String LOCAL_REACT_CLIENT_URL = "http://localhost:3000";
public static final String LOCAL_REACT_CLIENT_SECURE_URL = "https://localhost:3000";
public static final String LOCAL_VITE_CLIENT_URL = "http://localhost:5173";
public static final String LOCAL_VITE_CLIENT_SECURE_URL = "https://localhost:5173";
public static final List<String> LOCAL_CLIENT_URLS = List.of(
LOCAL_REACT_CLIENT_URL, LOCAL_REACT_CLIENT_SECURE_URL, LOCAL_VITE_CLIENT_URL, LOCAL_VITE_CLIENT_SECURE_URL);

// 서버 URL
public static final String PROD_SERVER_URL = "https://api.gdschongik.com";
public static final String DEV_SERVER_URL = "https://dev-api.gdschongik.com";
public static final String LOCAL_SERVER_URL = "http://localhost:8080";

public static final String SOCIAL_LOGIN_REDIRECT_URL = "%ssocial-login/redirect?%s=%s&%s=%s&%s=%s";
// 기타
public static final String ROOT_DOMAIN = "gdschongik.com";
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();

if (environmentUtil.isProdProfile()) {
configuration.addAllowedOriginPattern(PROD_CLIENT_URL);
configuration.addAllowedOriginPattern(PROD_CLIENT_ONBOARDING_URL);
configuration.addAllowedOriginPattern(PROD_CLIENT_ADMIN_URL);
}

if (environmentUtil.isDevProfile()) {
configuration.addAllowedOriginPattern(DEV_CLIENT_URL);
configuration.addAllowedOriginPattern(DEV_CLIENT_ONBOARDING_URL);
configuration.addAllowedOriginPattern(DEV_CLIENT_ADMIN_URL);
configuration.addAllowedOriginPattern(LOCAL_REACT_CLIENT_URL);
configuration.addAllowedOriginPattern(LOCAL_REACT_CLIENT_SECURE_URL);
configuration.addAllowedOriginPattern(LOCAL_VITE_CLIENT_URL);
Expand Down
Loading

0 comments on commit f3e87b9

Please sign in to comment.