Skip to content

Commit

Permalink
[NO_JIRA] 멤버 수 확인 API 추가 (#200)
Browse files Browse the repository at this point in the history
* feat : 멤버 수 API 추가

* feat : 멤버가 존재하지 않을 경우 Exception 추가

* feat : 멤버 수 API 화이트 리스트 추가

* refactor : 복수 표현으로 변경
  • Loading branch information
wjdwnsdnjs13 authored Oct 18, 2024
1 parent fc7edea commit 3493e4c
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
"/api/v2/GOOGLE",
Set.of("GET"),
"/api/v2/KAKAO",
Set.of("GET"),
"/api/v1/admin/memberCount",
Set.of("GET"));

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,11 @@ public MyHomeResponse findMemberHomeFeed(@Parameter(hidden = true) Long memberId
public void softDelete(@Parameter(hidden = true) Long memberId) {
memberUsecase.softDelete(memberId);
}

@GetMapping("/admin/membersCount")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "(admin) 가입 멤버 수 조회 API")
public int membersCount() {
return memberUsecase.membersCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum MemberErrorCode implements ErrorCode {
INVALID_LEVEL(HttpStatus.INTERNAL_SERVER_ERROR, "M003", "잘못된 레벨입니다."),
INACTIVE_MEMBER(HttpStatus.GONE, "M004", "탈퇴한 유저입니다."),
MEMBER_CONFLICT(HttpStatus.BAD_REQUEST, "M005", "이미 가입된 유저입니다."),
;
MEMBERS_NOT_EXIST(HttpStatus.NOT_FOUND, "M006", "가입한 유저가 없습니다.");

private final HttpStatus status;
private final String code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public MemberNicknameConflictException() {
}
}

public static class MembersNotExistException extends MemberException {
public MembersNotExistException() {
super(MemberErrorCode.MEMBERS_NOT_EXIST);
}

public MembersNotExistException(Object o) {
super(MemberErrorCode.MEMBERS_NOT_EXIST.appended(o));
}
}

public static class InvalidLevelException extends MemberException {
public InvalidLevelException() {
super(MemberErrorCode.INVALID_LEVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ void updateDeletedAt(
"update MemberEntity m set m.deletedAt = null, m.updatedAt = :updatedAt where m.id = :memberId")
void updateDeletedAtAndUpdatedAt(
@Param("memberId") Long memberId, @Param("updatedAt") LocalDateTime updatedAt);

@Query("select count(*) from MemberEntity m")
Optional<Integer> findMemberCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Optional;

import org.depromeet.spot.common.exception.member.MemberException.MemberNotFoundException;
import org.depromeet.spot.common.exception.member.MemberException.MembersNotExistException;
import org.depromeet.spot.domain.member.Level;
import org.depromeet.spot.domain.member.Member;
import org.depromeet.spot.infrastructure.jpa.member.entity.MemberEntity;
Expand Down Expand Up @@ -70,4 +71,9 @@ public void updateDeletedAt(Long memberId, LocalDateTime deletedAt) {
public void updateDeletedAtAndUpdatedAt(Long memberId, LocalDateTime updatedAt) {
memberJpaRepository.updateDeletedAtAndUpdatedAt(memberId, updatedAt);
}

@Override
public int membersCount() {
return memberJpaRepository.findMemberCount().orElseThrow(MembersNotExistException::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public interface MemberUsecase {

void softDelete(Long memberId);

int membersCount();

@Getter
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ public interface MemberRepository {
void updateDeletedAt(Long memberId, LocalDateTime deletedAt);

void updateDeletedAtAndUpdatedAt(Long memberId, LocalDateTime updatedAt);

int membersCount();
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,9 @@ public void softDelete(Long memberId) {

memberRepository.updateDeletedAt(memberId, LocalDateTime.now());
}

@Override
public int membersCount() {
return memberRepository.membersCount();
}
}

0 comments on commit 3493e4c

Please sign in to comment.