diff --git a/src/main/java/usw/suwiki/domain/admin/service/AdminBusinessService.java b/src/main/java/usw/suwiki/domain/admin/service/AdminBusinessService.java index eabe46c5..0cbbbba2 100644 --- a/src/main/java/usw/suwiki/domain/admin/service/AdminBusinessService.java +++ b/src/main/java/usw/suwiki/domain/admin/service/AdminBusinessService.java @@ -1,10 +1,22 @@ package usw.suwiki.domain.admin.service; +import static usw.suwiki.global.exception.ExceptionType.PASSWORD_ERROR; +import static usw.suwiki.global.exception.ExceptionType.USER_RESTRICTED; +import static usw.suwiki.global.util.apiresponse.ApiResponseFactory.successCapitalFlag; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.*; +import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.EvaluatePostBlacklistForm; +import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.EvaluatePostNoProblemForm; +import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.EvaluatePostRestrictForm; +import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.ExamPostBlacklistForm; +import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.ExamPostNoProblemForm; +import usw.suwiki.domain.admin.controller.dto.UserAdminRequestDto.ExamPostRestrictForm; import usw.suwiki.domain.admin.controller.dto.UserAdminResponseDto.LoadAllReportedPostForm; import usw.suwiki.domain.blacklistdomain.service.BlacklistDomainCRUDService; import usw.suwiki.domain.evaluatepost.domain.EvaluatePost; @@ -23,14 +35,6 @@ import usw.suwiki.global.exception.errortype.AccountException; import usw.suwiki.global.jwt.JwtAgent; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static usw.suwiki.global.exception.ExceptionType.PASSWORD_ERROR; -import static usw.suwiki.global.exception.ExceptionType.USER_RESTRICTED; -import static usw.suwiki.global.util.apiresponse.ApiResponseFactory.successCapitalFlag; - @Service @Transactional @RequiredArgsConstructor @@ -54,9 +58,9 @@ public Map executeAdminLogin(LoginForm loginForm) { if (user.validatePassword(bCryptPasswordEncoder, loginForm.password())) { if (user.getRole().getKey().equals(Role.ADMIN.getKey())) { - final int userCount = userCRUDService.findAllUsersSize(); - final int userIsolationCount = userIsolationCRUDService.findAllIsolationUsersSize(); - final int totalUserCount = userCount + userIsolationCount; + final long userCount = userCRUDService.countAllUsers(); + final long userIsolationCount = userIsolationCRUDService.countAllIsolatedUsers(); + final long totalUserCount = userCount + userIsolationCount; return new HashMap<>() {{ put("AccessToken", jwtAgent.createAccessToken(user)); diff --git a/src/main/java/usw/suwiki/domain/user/user/service/UserCRUDService.java b/src/main/java/usw/suwiki/domain/user/user/service/UserCRUDService.java index 90b9b3ea..c351695c 100644 --- a/src/main/java/usw/suwiki/domain/user/user/service/UserCRUDService.java +++ b/src/main/java/usw/suwiki/domain/user/user/service/UserCRUDService.java @@ -1,5 +1,11 @@ package usw.suwiki.domain.user.user.service; +import static usw.suwiki.global.exception.ExceptionType.USER_NOT_EXISTS; +import static usw.suwiki.global.exception.ExceptionType.USER_NOT_FOUND; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -7,13 +13,6 @@ import usw.suwiki.domain.user.user.repository.UserRepository; import usw.suwiki.global.exception.errortype.AccountException; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; - -import static usw.suwiki.global.exception.ExceptionType.USER_NOT_EXISTS; -import static usw.suwiki.global.exception.ExceptionType.USER_NOT_FOUND; - @Service @RequiredArgsConstructor @Transactional @@ -73,8 +72,8 @@ private User convertOptionalUserToDomainUser(Optional optionalUser) { } @Transactional(readOnly = true) - public int findAllUsersSize() { - return userRepository.findAll().size(); + public long countAllUsers() { + return userRepository.count(); } public void deleteFromUserIdx(Long userIdx) { diff --git a/src/main/java/usw/suwiki/domain/user/userIsolation/service/UserIsolationCRUDService.java b/src/main/java/usw/suwiki/domain/user/userIsolation/service/UserIsolationCRUDService.java index 4067e620..2b2896e7 100644 --- a/src/main/java/usw/suwiki/domain/user/userIsolation/service/UserIsolationCRUDService.java +++ b/src/main/java/usw/suwiki/domain/user/userIsolation/service/UserIsolationCRUDService.java @@ -1,20 +1,17 @@ package usw.suwiki.domain.user.userIsolation.service; +import static usw.suwiki.global.exception.ExceptionType.USER_NOT_EXISTS; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import usw.suwiki.domain.user.user.User; import usw.suwiki.domain.user.userIsolation.UserIsolation; import usw.suwiki.domain.user.userIsolation.repository.UserIsolationRepository; import usw.suwiki.global.exception.errortype.AccountException; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static usw.suwiki.global.exception.ExceptionType.USER_NOT_EXISTS; - @Service @RequiredArgsConstructor @Transactional @@ -62,8 +59,8 @@ public UserIsolation loadUserFromEmail(String email) { } @Transactional(readOnly = true) - public int findAllIsolationUsersSize() { - return userIsolationRepository.findAll().size(); + public long countAllIsolatedUsers() { + return userIsolationRepository.count(); } public void deleteByUserIdx(Long userIdx) {