Skip to content

Commit

Permalink
Merge pull request #295 from Myongji-Graduate/develop
Browse files Browse the repository at this point in the history
졸업을 부탁해 V2.2.0
  • Loading branch information
5uhwann authored Dec 23, 2024
2 parents 04da5d1 + 8ddb5b0 commit a1005b4
Show file tree
Hide file tree
Showing 79 changed files with 2,282 additions and 935 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ jacocoTestReport {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"com/plzgraduate/myongjigraduatebe/core/**",
"com/plzgraudate/myongjigraduatebe/*Request*",
"com/plzgraudate/myongjigraduatebe/*Command*",
"com/plzgraudate/myongjigraduatebe/*Response*",
"com/plzgraudate/myongjigraduatebe/*Mapper*"
"com/plzgraduate/myongjigraduatebe/*Request*",
"com/plzgraduate/myongjigraduatebe/*Command*",
"com/plzgraduate/myongjigraduatebe/*Response*",
"com/plzgraduate/myongjigraduatebe/*Mapper*"
])
}))
}
Expand Down
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
codecov:
require_ci_to_pass: true
ignore:
- "com/plzgraduate/myongjigraduatebe/core/**"
- "com/plzgraudate/myongjigraduatebe/*Request*"
- "com/plzgraudate/myongjigraduatebe/*Command*"
- "com/plzgraudate/myongjigraduatebe/*Response*"
- "com/plzgraudate/myongjigraduatebe/*Mapper*"

comment:
layout: "reach,diff,flags,files,footer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
public class CompletedCreditResponse {

private String category;
private int totalCredit;
private double totalCredit;
private double takenCredit;
private boolean completed;

@Builder
private CompletedCreditResponse(String category, int totalCredit, double takenCredit,
private CompletedCreditResponse(String category, double totalCredit, double takenCredit,
boolean completed) {
this.category = category;
this.totalCredit = totalCredit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.DetailGraduationResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationResult;
import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -34,6 +35,7 @@ class GenerateOrModifyCompletedCreditService implements GenerateOrModifyComplete

private final CalculateGraduationUseCase calculateGraduationUseCase;

//TODO()
@Override
public void generateOrModifyCompletedCredit(User user) {
List<CompletedCredit> completedCredits = findCompletedCreditPort.findCompletedCredit(user);
Expand All @@ -42,27 +44,32 @@ public void generateOrModifyCompletedCredit(User user) {

List<CompletedCredit> updatedCompletedCredits = createGeneralCompletedCreditModel(
completedCredits,
detailGraduationResults);
detailGraduationResults
);
CompletedCredit chapelCompletedCreditModel = createOrUpdateChapelCompletedCreditModel(
completedCredits,
graduationResult);
graduationResult,
user
);
CompletedCredit normalCultureCompletedCreditModel = createOrUpdateNormalCultureCompletedCreditModel(
completedCredits, graduationResult);
CompletedCredit freeElectiveCompletedCreditModel = createOrUpdateFreeElectiveCompletedCreditModel(
completedCredits, graduationResult);

ArrayList<CompletedCredit> allCompletedCreditModels = new ArrayList<>(
updatedCompletedCredits);
ArrayList<CompletedCredit> allCompletedCreditModels = new ArrayList<>(updatedCompletedCredits);
allCompletedCreditModels.addAll(
List.of(chapelCompletedCreditModel, normalCultureCompletedCreditModel,
freeElectiveCompletedCreditModel));
generateOrModifyCompletedCreditPort.generateOrModifyCompletedCredits(user,
allCompletedCreditModels);
List.of(
chapelCompletedCreditModel,
normalCultureCompletedCreditModel,
freeElectiveCompletedCreditModel
));
generateOrModifyCompletedCreditPort.generateOrModifyCompletedCredits(user, allCompletedCreditModels);
}

private List<CompletedCredit> createGeneralCompletedCreditModel(
List<CompletedCredit> completedCredits,
List<DetailGraduationResult> detailGraduationResults) {
List<DetailGraduationResult> detailGraduationResults
) {
Map<DetailGraduationResult, Optional<CompletedCredit>> resultMap = detailGraduationResults.stream()
.collect(Collectors.toMap(
Function.identity(),
Expand All @@ -73,14 +80,17 @@ private List<CompletedCredit> createGeneralCompletedCreditModel(
));
return resultMap.keySet()
.stream()
.map(detailGraduationResult -> createCompletedCreditModel(detailGraduationResult,
resultMap.get(detailGraduationResult)))
.map(detailGraduationResult -> createCompletedCreditModel(
detailGraduationResult,
resultMap.get(detailGraduationResult)
))
.collect(Collectors.toList());
}

private CompletedCredit createCompletedCreditModel(
DetailGraduationResult detailGraduationResult,
Optional<CompletedCredit> completedCredit) {
Optional<CompletedCredit> completedCredit
) {
return CompletedCredit.builder()
.id(completedCredit.map(CompletedCredit::getId)
.orElse(null))
Expand All @@ -92,59 +102,82 @@ private CompletedCredit createCompletedCreditModel(

private CompletedCredit createOrUpdateChapelCompletedCreditModel(
List<CompletedCredit> completedCredits,
GraduationResult graduationResult) {
GraduationResult graduationResult,
User user
) {
Optional<CompletedCredit> chapelCompletedCredit = findCompletedCreditByCategory(
completedCredits, CHAPEL);

double totalCredit = user.getStudentCategory() == StudentCategory.TRANSFER
? 0.5
: (double) GRADUATION_COUNT / 2;

return chapelCompletedCredit.map(
completedCredit -> updateCompletedCredit(completedCredit, GRADUATION_COUNT / 2,
graduationResult.getChapelResult()
.getTakenChapelCredit()))
completedCredit -> updateCompletedCredit(
completedCredit,
totalCredit,
graduationResult.getChapelResult().getTakenChapelCredit()
))
.orElseGet(() -> CompletedCredit.createChapelCompletedCreditModel(
graduationResult.getChapelResult()));
graduationResult.getChapelResult(), user));
}


private CompletedCredit createOrUpdateNormalCultureCompletedCreditModel(
List<CompletedCredit> completedCredits,
GraduationResult graduationResult) {
GraduationResult graduationResult
) {
Optional<CompletedCredit> normalCultureCompletedCredit = findCompletedCreditByCategory(
completedCredits,
NORMAL_CULTURE);
NORMAL_CULTURE
);
return normalCultureCompletedCredit.map(
completedCredit -> updateCompletedCredit(completedCredit,
completedCredit -> updateCompletedCredit(
completedCredit,
graduationResult.getNormalCultureGraduationResult()
.getTotalCredit(),
graduationResult.getNormalCultureGraduationResult()
.getTakenCredit()))
.getTakenCredit()
))
.orElseGet(() -> CompletedCredit.createNormalCultureCompletedCreditModel(
graduationResult.getNormalCultureGraduationResult()));
}

private CompletedCredit createOrUpdateFreeElectiveCompletedCreditModel(
List<CompletedCredit> completedCredits,
GraduationResult graduationResult) {
GraduationResult graduationResult
) {
Optional<CompletedCredit> freeElectiveCompletedCredit = findCompletedCreditByCategory(
completedCredits,
FREE_ELECTIVE);
FREE_ELECTIVE
);

int finalTakenCredit = graduationResult.getFreeElectiveGraduationResult()
.getTakenCredit();
return freeElectiveCompletedCredit.map(
completedCredit -> updateCompletedCredit(completedCredit,
completedCredit -> updateCompletedCredit(
completedCredit,
graduationResult.getFreeElectiveGraduationResult()
.getTotalCredit(),
graduationResult.getFreeElectiveGraduationResult()
.getTakenCredit()))
finalTakenCredit
))
.orElseGet(() -> CompletedCredit.createFreeElectiveCompletedCreditModel(
graduationResult.getFreeElectiveGraduationResult()));
}

private Optional<CompletedCredit> findCompletedCreditByCategory(
List<CompletedCredit> completedCredits,
GraduationCategory category) {
GraduationCategory category
) {
return completedCredits.stream()
.filter(completedCredit -> completedCredit.getGraduationCategory() == category)
.findFirst();
}

private CompletedCredit updateCompletedCredit(CompletedCredit completedCredit,
int totalCredit, double takenCredit) {
private CompletedCredit updateCompletedCredit(
CompletedCredit completedCredit,
double totalCredit, double takenCredit
) {
completedCredit.updateCredit(totalCredit, takenCredit);
return completedCredit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.FreeElectiveGraduationResult;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.GraduationCategory;
import com.plzgraduate.myongjigraduatebe.graduation.domain.model.NormalCultureGraduationResult;
import com.plzgraduate.myongjigraduatebe.user.domain.model.StudentCategory;
import com.plzgraduate.myongjigraduatebe.user.domain.model.User;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -17,36 +19,42 @@ public class CompletedCredit {

private final Long id;
private final GraduationCategory graduationCategory;
private int totalCredit;
private double totalCredit;
private double takenCredit;

@Builder
private CompletedCredit(Long id, GraduationCategory graduationCategory, int totalCredit,
private CompletedCredit(Long id, GraduationCategory graduationCategory, double totalCredit,
double takenCredit) {
this.id = id;
this.graduationCategory = graduationCategory;
this.totalCredit = totalCredit;
this.takenCredit = takenCredit;
}

public static CompletedCredit from(DetailGraduationResult detailGraduationResults) {
public CompletedCredit from(DetailGraduationResult detailGraduationResults) {
return CompletedCredit.builder()
.graduationCategory(detailGraduationResults.getGraduationCategory())
.totalCredit(detailGraduationResults.getTotalCredit())
.takenCredit(detailGraduationResults.getTakenCredit())
.build();
}

public static CompletedCredit createChapelCompletedCreditModel(ChapelResult chapelResult) {
public static CompletedCredit createChapelCompletedCreditModel(ChapelResult chapelResult, User user) {
double totalCredit = user.getStudentCategory() == StudentCategory.TRANSFER
? 0.5 // 편입생일 경우 채플 이수 요건은 1회
: (double) ChapelResult.GRADUATION_COUNT / 2; // 일반 학생일 경우 기본 채플 이수 요건

return CompletedCredit.builder()
.graduationCategory(CHAPEL)
.totalCredit(ChapelResult.GRADUATION_COUNT / 2)
.takenCredit(chapelResult.getTakenChapelCredit())
.build();
.graduationCategory(CHAPEL)
.totalCredit(totalCredit)
.takenCredit(chapelResult.getTakenChapelCredit())
.build();
}


public static CompletedCredit createNormalCultureCompletedCreditModel(
NormalCultureGraduationResult normalCultureGraduationResult) {
NormalCultureGraduationResult normalCultureGraduationResult
) {
return CompletedCredit.builder()
.graduationCategory(NORMAL_CULTURE)
.totalCredit(normalCultureGraduationResult.getTotalCredit())
Expand All @@ -63,7 +71,7 @@ public static CompletedCredit createFreeElectiveCompletedCreditModel(
.build();
}

public void updateCredit(int totalCredit, double takenCredit) {
public void updateCredit(double totalCredit, double takenCredit) {
this.totalCredit = totalCredit;
this.takenCredit = takenCredit;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public class CompletedCreditJpaEntity {
@Enumerated(value = EnumType.STRING)
private GraduationCategory graduationCategory;

private int totalCredit;
private double totalCredit;

private double takenCredit;

@Builder
private CompletedCreditJpaEntity(Long id, UserJpaEntity userJpaEntity,
GraduationCategory graduationCategory,
int totalCredit, double takenCredit) {
double totalCredit, double takenCredit) {
this.id = id;
this.userJpaEntity = userJpaEntity;
this.graduationCategory = graduationCategory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,51 +35,31 @@ public class SecurityConfig {

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf()
.disable()
.headers()
.disable()
.formLogin()
.disable()
.httpBasic()
.disable()
.rememberMe()
.disable()
.logout()
.disable()
.exceptionHandling()
http.csrf().disable().headers().disable().formLogin().disable().httpBasic().disable()
.rememberMe().disable().logout().disable().exceptionHandling()
.accessDeniedHandler(jwtAccessDeniedHandler)
.authenticationEntryPoint(jwtAuthenticationEntryPoint)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests()
.antMatchers(
API_V1_PREFIX + "/users/sign-up/**", // 회원가입
API_V1_PREFIX + "/auth/sign-in", // 로그인
API_V1_PREFIX + "/auth/token", //새 토큰 발급
API_V1_PREFIX + "/auth/token", // 새 토큰 발급
API_V1_PREFIX + "/users/{student-number}/auth-id", // 아이디 찾기
API_V1_PREFIX + "/users/{student-number}/validate", // 유저 검증
API_V1_PREFIX + "/users/password", // 비밀번호 재설정
API_V1_PREFIX + "/health", //헬스체크
API_V1_PREFIX + "/health", // 헬스체크
API_V1_PREFIX + "/graduations/check", // 비로그인 졸업 요건 검사
"/api-docs",
"/swagger-custom-ui.html",
"/v3/api-docs/**",
"/swagger-ui/**",
"/api-docs/**",
"/swagger-ui.html"
)
.permitAll()
.anyRequest()
.authenticated()
.and()
.cors()
.configurationSource(corsConfigurationSource())
.and()
.addFilterBefore(tokenAuthenticationFilter(tokenProvider),
UsernamePasswordAuthenticationFilter.class);
).permitAll().anyRequest().authenticated().and().cors()
.configurationSource(corsConfigurationSource()).and().addFilterBefore(
tokenAuthenticationFilter(tokenProvider),
UsernamePasswordAuthenticationFilter.class
);

return http.build();
}
Expand All @@ -105,14 +85,15 @@ public PasswordEncoder passwordEncoder() {
}

@Bean
public AuthenticationManager authenticationManager(
JwtAuthenticationProvider jwtAuthenticationProvider) {
public AuthenticationManager authenticationManager(JwtAuthenticationProvider jwtAuthenticationProvider) {
return new ProviderManager(jwtAuthenticationProvider);
}

@Bean
public JwtAuthenticationProvider jwtAuthenticationProvider(PasswordEncoder passwordEncoder,
FindUserUseCase findUserUseCase) {
public JwtAuthenticationProvider jwtAuthenticationProvider(
PasswordEncoder passwordEncoder,
FindUserUseCase findUserUseCase
) {
return new JwtAuthenticationProvider(passwordEncoder, findUserUseCase);
}

Expand Down
Loading

0 comments on commit a1005b4

Please sign in to comment.