Skip to content

Commit

Permalink
Merge pull request #293 from themoment-team/develop
Browse files Browse the repository at this point in the history
20231019.0 버전 적용
  • Loading branch information
YangSiJun528 authored Oct 19, 2023
2 parents 7c4b557 + e47f61a commit d620e83
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public record SearchApplicationResDto(
String teacherPhoneNumber,
EvaluationStatus firstEvaluation,
EvaluationStatus secondEvaluation,
Long registrationNumber,
BigDecimal secondScore
){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ default Application updateApplicationByApplicationReqDtoAndApplication(Applicati
@Mapping(source = "admissionInfo.teacherPhoneNumber", target = "teacherPhoneNumber"),
@Mapping(source = "admissionStatus.firstEvaluation", target = "firstEvaluation"),
@Mapping(source = "admissionStatus.secondEvaluation", target = "secondEvaluation"),
@Mapping(source = "admissionStatus.registrationNumber", target = "registrationNumber"),
@Mapping(source = "admissionStatus.secondScore", target = "secondScore"),
})
SearchApplicationResDto applicationToSearchApplicationResDto(Application application);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ public interface ApplicationRepository extends JpaRepository<Application, Long>

List<Application> findAllByAdmissionStatus_FirstEvaluation(EvaluationStatus evaluationStatus);

List<Application> findAllByAdmissionStatusFirstEvaluationOrAdmissionStatusSecondEvaluation(EvaluationStatus firstEvaluationStatus, EvaluationStatus secondEvaluationStatus);
List<Application> findAllByAdmissionStatusFirstEvaluationOrAdmissionStatusSecondEvaluationAndAdmissionStatusIsFinalSubmitted(EvaluationStatus firstEvaluationStatus, EvaluationStatus secondEvaluationStatus, Boolean isFinalSubmitted);

Boolean existsByAdmissionStatusFirstEvaluation(EvaluationStatus evaluationStatus);

Boolean existsByAdmissionStatusSecondEvaluation(EvaluationStatus evaluationStatus);

List<Application> findAllByAdmissionInfoScreening(Screening screening);
List<Application> findAllByAdmissionInfoScreeningAndAdmissionStatusIsFinalSubmitted(Screening screening, Boolean isFinalSubmitted);

List<Application> findAllByAdmissionStatusScreeningFirstEvaluationAt(Screening screening);
List<Application> findAllByAdmissionStatusScreeningFirstEvaluationAtAndAdmissionStatusIsFinalSubmitted(Screening screening, Boolean isFinalSubmitted);

List<Application> findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNot(Screening screening, EvaluationStatus evaluationStatus);
List<Application> findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNotAndAdmissionStatusIsFinalSubmitted(Screening screening, EvaluationStatus evaluationStatus, Boolean isFinalSubmitted);

List<Application> findAllByAdmissionStatusFirstEvaluationAndAdmissionStatusIsFinalSubmitted(EvaluationStatus evaluationStatus, Boolean isFinalSubmitted);
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,36 @@ private List<List<List<String>>> getSheetDataList() {
List<List<String>> falledSheetData = new ArrayList<>();

if (!applicationRepository.existsByAdmissionStatusFirstEvaluation(EvaluationStatus.PASS)) {
generalSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionInfoScreening(Screening.GENERAL), false);
socialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionInfoScreening(Screening.SOCIAL), false);
generalSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionInfoScreeningAndAdmissionStatusIsFinalSubmitted(Screening.GENERAL, true), false);
socialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionInfoScreeningAndAdmissionStatusIsFinalSubmitted(Screening.SOCIAL, true), false);
List<Application> combinedSpecialAppList = Stream.concat(
applicationRepository.findAllByAdmissionInfoScreening(Screening.SPECIAL_VETERANS).stream(),
applicationRepository.findAllByAdmissionInfoScreening(Screening.SPECIAL_ADMISSION).stream()
applicationRepository.findAllByAdmissionInfoScreeningAndAdmissionStatusIsFinalSubmitted(Screening.SPECIAL_VETERANS, true).stream(),
applicationRepository.findAllByAdmissionInfoScreeningAndAdmissionStatusIsFinalSubmitted(Screening.SPECIAL_ADMISSION, true).stream()
)
.toList();
specialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(combinedSpecialAppList, false);
} else {
if (applicationRepository.existsByAdmissionStatusSecondEvaluation(EvaluationStatus.PASS)) {
generalSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNot(Screening.GENERAL, EvaluationStatus.NOT_YET), true);
socialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNot(Screening.SOCIAL, EvaluationStatus.NOT_YET), true);
generalSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNotAndAdmissionStatusIsFinalSubmitted(Screening.GENERAL, EvaluationStatus.NOT_YET, true), true);
socialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNotAndAdmissionStatusIsFinalSubmitted(Screening.SOCIAL, EvaluationStatus.NOT_YET, true), true);
List<Application> combinedSpecialAppList = Stream.concat(
applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNot(Screening.SPECIAL_VETERANS, EvaluationStatus.NOT_YET).stream(),
applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNot(Screening.SPECIAL_ADMISSION, EvaluationStatus.NOT_YET).stream()
applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNotAndAdmissionStatusIsFinalSubmitted(Screening.SPECIAL_VETERANS, EvaluationStatus.NOT_YET, true).stream(),
applicationRepository.findAllByAdmissionStatusScreeningSecondEvaluationAtAndAdmissionStatusSecondEvaluationNotAndAdmissionStatusIsFinalSubmitted(Screening.SPECIAL_ADMISSION, EvaluationStatus.NOT_YET, true).stream()
)
.toList();
specialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(combinedSpecialAppList, true);
falledSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusFirstEvaluationOrAdmissionStatusSecondEvaluation(EvaluationStatus.FALL, EvaluationStatus.FALL), true);
falledSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusFirstEvaluationOrAdmissionStatusSecondEvaluationAndAdmissionStatusIsFinalSubmitted(EvaluationStatus.FALL, EvaluationStatus.FALL, true), true);

} else {
generalSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAt(Screening.GENERAL), false);
socialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAt(Screening.SOCIAL), false);
generalSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAtAndAdmissionStatusIsFinalSubmitted(Screening.GENERAL, true), false);
socialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAtAndAdmissionStatusIsFinalSubmitted(Screening.SOCIAL, true), false);
List<Application> combinedSpecialAppList = Stream.concat(
applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAt(Screening.SPECIAL_VETERANS).stream(),
applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAt(Screening.SPECIAL_ADMISSION).stream()
applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAtAndAdmissionStatusIsFinalSubmitted(Screening.SPECIAL_VETERANS, true).stream(),
applicationRepository.findAllByAdmissionStatusScreeningFirstEvaluationAtAndAdmissionStatusIsFinalSubmitted(Screening.SPECIAL_ADMISSION, true).stream()
)
.toList();
specialSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(combinedSpecialAppList, false);
falledSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatus_FirstEvaluation(EvaluationStatus.FALL), false);
falledSheetData = applicationMapper.INSTANCE.applicationToExcelDataList(applicationRepository.findAllByAdmissionStatusFirstEvaluationAndAdmissionStatusIsFinalSubmitted(EvaluationStatus.FALL, true), false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ private void oauth2Login(HttpSecurity http) throws Exception {
}

private void logout(HttpSecurity http) throws Exception {
http.logout(logout -> logout
.logoutUrl(logoutUri)
.logoutSuccessHandler(new CustomUrlLogoutSuccessHandler(authEnv.redirectBaseUri(), authEnv.redirectAdminUri()))
);
// http.logout(logout -> logout
// .logoutUrl(logoutUri)
// .logoutSuccessHandler(new CustomUrlLogoutSuccessHandler(authEnv.redirectBaseUri(), authEnv.redirectAdminUri()))
// );
//TODO session 없이 요청하는 경우에 에러 발생하지 않도록 수정하고 적용하기
}

private void exceptionHandling(HttpSecurity http) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package team.themoment.hellogsm.web.global.security.auth;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.util.UriComponentsBuilder;
import team.themoment.hellogsm.entity.domain.user.enums.Role;

import java.io.IOException;

@Controller
@RequiredArgsConstructor
@RequestMapping("/auth/v1")
public class AuthController {

private final AuthEnvironment authEnvironment;


// spring security logout 기능 관련 이슈로 인한 임시 구현
//TODO 이슈 해결하고 spring security logout으로 대체하기
@GetMapping("/logout")
public void logout(HttpServletRequest request, HttpServletResponse response) throws IOException {
var auth = SecurityContextHolder.getContext().getAuthentication();
if (auth instanceof OAuth2AuthenticationToken) {
new SecurityContextLogoutHandler().logout(request, response, SecurityContextHolder.getContext().getAuthentication());
}
String redirectUrl = buildRedirectUrl(isAdmin(auth));
response.sendRedirect(redirectUrl);

}

protected final boolean isAdmin(Authentication authentication) {
return authentication.getAuthorities().stream()
.anyMatch(authority -> Role.ROLE_ADMIN.name().equals(authority.getAuthority()));
}

protected final String buildRedirectUrl(boolean isAdmin) {
final String defaultTargetUrl = authEnvironment.redirectBaseUri();
final String adminUrl = authEnvironment.redirectBaseUri();

String targetUrl = isAdmin ? adminUrl : defaultTargetUrl;

return UriComponentsBuilder.fromUriString(targetUrl)
.queryParam("logout", "success")
.build()
.toUriString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ void search() throws Exception {
"01012341234",
EvaluationStatus.PASS,
EvaluationStatus.NOT_YET,
2002L,
BigDecimal.valueOf(100)
))
);
Expand Down Expand Up @@ -614,6 +615,7 @@ void search() throws Exception {
.andExpect(jsonPath("$.applications[0].guardianPhoneNumber").value(searchApplicationsResDto.applications().get(0).guardianPhoneNumber()))
.andExpect(jsonPath("$.applications[0].firstEvaluation").value(searchApplicationsResDto.applications().get(0).firstEvaluation().name()))
.andExpect(jsonPath("$.applications[0].secondEvaluation").value(searchApplicationsResDto.applications().get(0).secondEvaluation().name()))
.andExpect(jsonPath("$.applications[0].registrationNumber").value(searchApplicationsResDto.applications().get(0).registrationNumber()))
.andExpect(jsonPath("$.applications[0].secondScore").value(searchApplicationsResDto.applications().get(0).secondScore()))
.andDo(this.documentationHandler.document(
queryParameters(
Expand All @@ -637,6 +639,7 @@ void search() throws Exception {
fieldWithPath("applications[].teacherPhoneNumber").type(STRING).description("선생님 전화번호"),
fieldWithPath("applications[].firstEvaluation").type(enumAsString(EvaluationStatus.class)).description("1차 평가 결과"),
fieldWithPath("applications[].secondEvaluation").type(enumAsString(EvaluationStatus.class)).description("2차 평가 결과"),
fieldWithPath("applications[].registrationNumber").type(enumAsString(EvaluationStatus.class)).description("접수번호"),
fieldWithPath("applications[].secondScore").type(NUMBER).description("2차 시험 점수")
)
));
Expand Down

0 comments on commit d620e83

Please sign in to comment.