-
Notifications
You must be signed in to change notification settings - Fork 8
feat: 관리자 페이지 학점 인증 관리 api 추가 #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4ad60d6
feat: 페이징 검증을 위한 util 클래스 추가
Gyuhyeok99 e66cd77
feat: 관리자 전용 GPA 페이징 조회 api 추가
Gyuhyeok99 ee2e26f
test: 관리자 전용 GPA 페이징 조회 api 테스트 코드 추가
Gyuhyeok99 e51a714
refactor: GPA 페이징 조회 uri 수정
Gyuhyeok99 0111dbf
feat: 페이징 응답 DTO 추가
Gyuhyeok99 98ac050
chore: 잘못 추가한 라인 삭제
Gyuhyeok99 0866334
feat: 거절 사유 관련 검증 어노테이션 추가
Gyuhyeok99 57a8190
feat: 관리자 전용 GPA 검증 api 추가
Gyuhyeok99 a6f624c
feat: 관리자 전용 GPA 수정 api 추가
Gyuhyeok99 bf729a7
refactor: updateGpaScore → updateGpa 메서드명 변경
Gyuhyeok99 d96d475
refactor: ScoreVerificationAdminService → GpaScoreVerificationAdminSe…
Gyuhyeok99 c1e2fad
test: 관리자 전용 GPA 수정 api 테스트 코드 추가
Gyuhyeok99 fb22382
test: 불필요한 GPA 검증 실패 테스트 제거
Gyuhyeok99 28eef3b
refactor: 페이징 처리 로직 이동 및 기본값 설정
Gyuhyeok99 f7ebafe
refactor: GPA 수정 및 검증 하나의 api로 통합
Gyuhyeok99 72d629c
test: 통합된 api에 맞게 테스트 코드 수정
Gyuhyeok99 c74d396
style: 코드리뷰 반영하여 네이밍 및 개행 수정
Gyuhyeok99 a0d4d5b
refactor: 임베디드 엔티티 DTO 변환 적용
Gyuhyeok99 fdb426e
refactor: GpaScore 프로젝션 및 ZoneId 변수로 분리
Gyuhyeok99 dc3d0fa
Merge branch 'develop' into feat/194-admin-score-verification
Gyuhyeok99 1435fb0
feat: 페이지네이션 검증 로직에 최대값 조건 추가
Gyuhyeok99 ba5a027
style: 2차 코드리뷰 반영하여 네이밍 및 개행 수정
Gyuhyeok99 abb963a
style: 개행 추가
Gyuhyeok99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/example/solidconnection/admin/controller/AdminScoreController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package com.example.solidconnection.admin.controller; | ||
|
|
||
| import com.example.solidconnection.admin.dto.GpaScoreResponse; | ||
| import com.example.solidconnection.admin.dto.GpaScoreSearchResponse; | ||
| import com.example.solidconnection.admin.dto.GpaScoreUpdateRequest; | ||
| import com.example.solidconnection.admin.dto.ScoreSearchCondition; | ||
| import com.example.solidconnection.admin.service.AdminGpaScoreService; | ||
| import com.example.solidconnection.custom.response.PageResponse; | ||
| import com.example.solidconnection.util.PagingUtils; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.web.PageableDefault; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.ModelAttribute; | ||
| import org.springframework.web.bind.annotation.PatchMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RequestMapping("/admin/scores") | ||
| @RestController | ||
| public class AdminScoreController { | ||
|
|
||
| private final AdminGpaScoreService adminGpaScoreService; | ||
|
|
||
| @GetMapping("/gpas") | ||
| public ResponseEntity<PageResponse<GpaScoreSearchResponse>> searchGpaScores( | ||
| @Valid @ModelAttribute ScoreSearchCondition scoreSearchCondition, | ||
| @PageableDefault(page = 1) Pageable pageable | ||
| ) { | ||
| PagingUtils.validatePage(pageable.getPageNumber(), pageable.getPageSize()); | ||
| Pageable internalPageable = PageRequest.of(pageable.getPageNumber() - 1, pageable.getPageSize()); | ||
| Page<GpaScoreSearchResponse> page = adminGpaScoreService.searchGpaScores(scoreSearchCondition, internalPageable); | ||
| return ResponseEntity.ok(PageResponse.of(page)); | ||
| } | ||
|
|
||
| @PatchMapping("/gpas/{gpa-score-id}") | ||
| public ResponseEntity<GpaScoreResponse> updateGpaScore( | ||
| @PathVariable("gpa-score-id") Long gpaScoreId, | ||
| @Valid @RequestBody GpaScoreUpdateRequest request | ||
| ) { | ||
| GpaScoreResponse response = adminGpaScoreService.updateGpaScore(gpaScoreId, request); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/example/solidconnection/admin/dto/GpaResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| public record GpaResponse( | ||
| double gpa, | ||
| double gpaCriteria, | ||
| String gpaReportUrl | ||
| ) { | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/example/solidconnection/admin/dto/GpaScoreResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| import com.example.solidconnection.score.domain.GpaScore; | ||
| import com.example.solidconnection.type.VerifyStatus; | ||
|
|
||
| public record GpaScoreResponse( | ||
| long id, | ||
| double gpa, | ||
| double gpaCriteria, | ||
| VerifyStatus verifyStatus, | ||
| String rejectedReason | ||
| ) { | ||
| public static GpaScoreResponse from(GpaScore gpaScore) { | ||
| return new GpaScoreResponse( | ||
| gpaScore.getId(), | ||
| gpaScore.getGpa().getGpa(), | ||
| gpaScore.getGpa().getGpaCriteria(), | ||
| gpaScore.getVerifyStatus(), | ||
| gpaScore.getRejectedReason() | ||
| ); | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/solidconnection/admin/dto/GpaScoreSearchResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| public record GpaScoreSearchResponse( | ||
| GpaScoreStatusResponse gpaScoreStatusResponse, | ||
| SiteUserResponse siteUserResponse | ||
| ) { | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/example/solidconnection/admin/dto/GpaScoreStatusResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| import com.example.solidconnection.type.VerifyStatus; | ||
|
|
||
| import java.time.ZonedDateTime; | ||
|
|
||
| public record GpaScoreStatusResponse( | ||
| long id, | ||
| GpaResponse gpaResponse, | ||
| VerifyStatus verifyStatus, | ||
| String rejectedReason, | ||
| ZonedDateTime createdAt, | ||
| ZonedDateTime updatedAt | ||
| ) { | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/example/solidconnection/admin/dto/GpaScoreUpdateRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| import com.example.solidconnection.custom.validation.annotation.RejectedReasonRequired; | ||
| import com.example.solidconnection.type.VerifyStatus; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| @RejectedReasonRequired | ||
| public record GpaScoreUpdateRequest( | ||
|
|
||
| @NotNull(message = "GPA를 입력해주세요.") | ||
| Double gpa, | ||
|
|
||
| @NotNull(message = "GPA 기준을 입력해주세요.") | ||
| Double gpaCriteria, | ||
|
|
||
| @NotNull(message = "승인 상태를 설정해주세요.") | ||
| VerifyStatus verifyStatus, | ||
|
|
||
| String rejectedReason | ||
| ) { | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
src/main/java/com/example/solidconnection/admin/dto/ScoreSearchCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| import com.example.solidconnection.type.VerifyStatus; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| public record ScoreSearchCondition( | ||
| VerifyStatus verifyStatus, | ||
| String nickname, | ||
| LocalDate createdAt) { | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/example/solidconnection/admin/dto/SiteUserResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.example.solidconnection.admin.dto; | ||
|
|
||
| public record SiteUserResponse( | ||
| long id, | ||
| String nickname, | ||
| String profileImageUrl | ||
| ) { | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/example/solidconnection/admin/service/AdminGpaScoreService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.example.solidconnection.admin.service; | ||
|
|
||
| import com.example.solidconnection.admin.dto.GpaScoreResponse; | ||
| import com.example.solidconnection.admin.dto.GpaScoreSearchResponse; | ||
| import com.example.solidconnection.admin.dto.GpaScoreUpdateRequest; | ||
| import com.example.solidconnection.admin.dto.ScoreSearchCondition; | ||
| import com.example.solidconnection.application.domain.Gpa; | ||
| import com.example.solidconnection.custom.exception.CustomException; | ||
| import com.example.solidconnection.score.domain.GpaScore; | ||
| import com.example.solidconnection.score.repository.GpaScoreRepository; | ||
| import com.example.solidconnection.type.VerifyStatus; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import static com.example.solidconnection.custom.exception.ErrorCode.GPA_SCORE_NOT_FOUND; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Service | ||
| public class AdminGpaScoreService { | ||
|
|
||
| private final GpaScoreRepository gpaScoreRepository; | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public Page<GpaScoreSearchResponse> searchGpaScores(ScoreSearchCondition scoreSearchCondition, Pageable pageable) { | ||
| return gpaScoreRepository.searchGpaScores(scoreSearchCondition, pageable); | ||
| } | ||
|
|
||
| @Transactional | ||
| public GpaScoreResponse updateGpaScore(Long gpaScoreId, GpaScoreUpdateRequest request) { | ||
| GpaScore gpaScore = gpaScoreRepository.findById(gpaScoreId) | ||
| .orElseThrow(() -> new CustomException(GPA_SCORE_NOT_FOUND)); | ||
| gpaScore.updateGpaScore( | ||
| new Gpa( | ||
| request.gpa(), | ||
| request.gpaCriteria(), | ||
| gpaScore.getGpa().getGpaReportUrl() | ||
| ), | ||
| request.verifyStatus(), | ||
| request.verifyStatus() == VerifyStatus.REJECTED ? request.rejectedReason() : null | ||
| ); | ||
| return GpaScoreResponse.from(gpaScore); | ||
| } | ||
Gyuhyeok99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/example/solidconnection/custom/response/PageResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.example.solidconnection.custom.response; | ||
|
|
||
| import org.springframework.data.domain.Page; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record PageResponse<T>( | ||
| List<T> content, | ||
| int pageNumber, | ||
| int pageSize, | ||
| long totalElements, | ||
| int totalPages | ||
| ) { | ||
| /* | ||
| * 페이지 번호는 1부터 시작하는 것이 사용자 입장에서 더 직관적이기 때문에 1을 더해줌 | ||
| */ | ||
| public static <T> PageResponse<T> of(Page<T> page) { | ||
| return new PageResponse<>( | ||
| page.getContent(), | ||
| page.getNumber() + 1, | ||
| page.getSize(), | ||
| page.getTotalElements(), | ||
| page.getTotalPages() | ||
| ); | ||
| } | ||
nayonsoso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
20 changes: 20 additions & 0 deletions
20
...java/com/example/solidconnection/custom/validation/annotation/RejectedReasonRequired.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.example.solidconnection.custom.validation.annotation; | ||
|
|
||
| import com.example.solidconnection.custom.validation.validator.RejectedReasonValidator; | ||
| import jakarta.validation.Constraint; | ||
| import jakarta.validation.Payload; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| @Target({ElementType.TYPE}) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Constraint(validatedBy = RejectedReasonValidator.class) | ||
| public @interface RejectedReasonRequired { | ||
|
|
||
| String message() default "거절 사유 입력값이 올바르지 않습니다."; | ||
| Class<?>[] groups() default {}; | ||
| Class<? extends Payload>[] payload() default {}; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.