Skip to content

Commit

Permalink
Merge branch 'test'
Browse files Browse the repository at this point in the history
  • Loading branch information
choihuk committed Dec 8, 2023
2 parents 1db515c + f2bc2c4 commit 4c7d013
Show file tree
Hide file tree
Showing 174 changed files with 2,703 additions and 1,592 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
files/

### STS ###
.apt_generated
Expand Down
631 changes: 382 additions & 249 deletions ddl.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package aplus.insurancesystem2;
package aplus.insurancesystem;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class InsuranceSystem2Application {
public class InsuranceSystemApplication {

public static void main(String[] args) {
SpringApplication.run(InsuranceSystem2Application.class, args);
SpringApplication.run(InsuranceSystemApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aplus.insurancesystem2.common.config;
package aplus.insurancesystem.common.config;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aplus.insurancesystem2.common.config;
package aplus.insurancesystem.common.config;

import java.util.Locale;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package aplus.insurancesystem2.common.config;
package aplus.insurancesystem.common.config;

import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -10,10 +12,15 @@
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import aplus.insurancesystem2.common.security.AplusAccessDeniedHandler;
import aplus.insurancesystem2.common.security.AplusAuthenticationSuccessHandler;
import aplus.insurancesystem.common.security.AplusAccessDeniedHandler;
import aplus.insurancesystem.common.security.AplusAuthenticationFailureHandler;
import aplus.insurancesystem.common.security.AplusAuthenticationSuccessHandler;

@Configuration
@EnableWebSecurity
Expand All @@ -29,6 +36,11 @@ public SimpleUrlAuthenticationSuccessHandler loginSuccessHandler() {
return new AplusAuthenticationSuccessHandler();
}

@Bean
public AuthenticationFailureHandler loginFailureHandler() {
return new AplusAuthenticationFailureHandler();
}

@Bean
public AccessDeniedHandler accessDeniedHandler() {
return new AplusAccessDeniedHandler();
Expand All @@ -49,12 +61,15 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.anyRequest().authenticated()
)
.csrf(AbstractHttpConfigurer::disable)
.cors((cors) -> cors
.configurationSource(apiConfigurationSource()))
.formLogin((login) -> login
.loginPage("/loginpage")
.loginProcessingUrl("/login")
.usernameParameter("loginId")
.passwordParameter("password")
.successHandler(loginSuccessHandler())
.failureHandler(loginFailureHandler())
)
.exceptionHandling((exception) -> exception
.accessDeniedHandler(accessDeniedHandler())
Expand All @@ -68,4 +83,15 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
);
return http.build();
}

private CorsConfigurationSource apiConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowCredentials(true);
configuration.setAllowedOrigins(List.of("http://localhost:3000"));
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("*"));
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aplus.insurancesystem2.common.config;
package aplus.insurancesystem.common.config;

import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
Expand All @@ -19,6 +19,17 @@
@Configuration
public class SwaggerConfig {

@Bean
public GroupedOpenApi allOpenApi() {
String[] paths = {"/**"};

return GroupedOpenApi
.builder()
.group("전체 API")
.pathsToMatch(paths)
.build();
}

@Bean
public GroupedOpenApi customerOpenApi() {
String[] paths = {"/customers/**"};
Expand Down Expand Up @@ -64,12 +75,45 @@ public GroupedOpenApi insuranceApplicationOpenApi() {
}

@Bean
public GroupedOpenApi loginOpenApi() {
String[] paths = {"/**"};
public GroupedOpenApi contractOpenApi() {
String[] paths = {"/contracts/**"};

return GroupedOpenApi
.builder()
.group("계약 API")
.pathsToMatch(paths)
.build();
}

@Bean
public GroupedOpenApi paymentOpenApi() {
String[] paths = {"/payments/**"};

return GroupedOpenApi
.builder()
.group("납입 API")
.pathsToMatch(paths)
.build();
}

@Bean
public GroupedOpenApi compensationClaimOpenApi() {
String[] paths = {"/compensation-claim/**"};

return GroupedOpenApi
.builder()
.group("보상금 청구 API")
.pathsToMatch(paths)
.build();
}

@Bean
public GroupedOpenApi surveyOpenApi() {
String[] paths = {"/survey/**"};

return GroupedOpenApi
.builder()
.group("로그인 API")
.group("손해사정 API")
.pathsToMatch(paths)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package aplus.insurancesystem2.common.config;
package aplus.insurancesystem.common.config;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import aplus.insurancesystem2.common.converter.UserInfoArgumentResolver;
import aplus.insurancesystem.common.converter.EInsuranceTypeConverter;
import aplus.insurancesystem.common.converter.EPaymentCycleConverter;
import aplus.insurancesystem.common.converter.UserInfoArgumentResolver;
import lombok.RequiredArgsConstructor;

@Configuration
Expand All @@ -17,18 +19,15 @@
public class WebConfig implements WebMvcConfigurer {

private final UserInfoArgumentResolver userInfoArgumentResolver;
private final EPaymentCycleConverter ePaymentCycleConverter;

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(userInfoArgumentResolver);
}

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("*")
.allowedHeaders("*")
.allowCredentials(true).maxAge(3600);
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(ePaymentCycleConverter);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package aplus.insurancesystem2.common.converter;
package aplus.insurancesystem.common.converter;

import java.util.EnumSet;


import aplus.insurancesystem2.domain.customer.entity.customer.EGender;
import aplus.insurancesystem.domain.customer.entity.customer.EGender;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package aplus.insurancesystem.common.converter;

import java.util.EnumSet;

import aplus.insurancesystem.domain.Insurance.entity.insurance.InsuranceType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter(autoApply = true)
public class EInsuranceTypeConverter implements AttributeConverter<InsuranceType, String> {

@Override
public String convertToDatabaseColumn(InsuranceType insuranceType) {
return insuranceType.getName();
}

@Override
public InsuranceType convertToEntityAttribute(String dbData) {
return EnumSet.allOf(InsuranceType.class).stream()
.filter(e -> e.getName().equals(dbData))
.findAny()
.orElseThrow(IllegalArgumentException::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package aplus.insurancesystem.common.converter;

import java.util.EnumSet;

import aplus.insurancesystem.domain.customer.entity.customer.Job;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;

@Converter(autoApply = true)
public class EJobConverter implements AttributeConverter<Job, String> {

@Override
public String convertToDatabaseColumn(Job job) {
return job.getName();
}

@Override
public Job convertToEntityAttribute(String dbData) {
return EnumSet.allOf(Job.class).stream()
.filter(e -> e.getName().equals(dbData))
.findAny()
.orElseThrow(IllegalArgumentException::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package aplus.insurancesystem.common.converter;

import java.util.Arrays;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import aplus.insurancesystem.domain.Insurance.entity.insurauceApplication.PaymentCycle;

@Component
public class EPaymentCycleConverter implements Converter<String, PaymentCycle> {

@Override
public PaymentCycle convert(String source) {
return Arrays.stream(PaymentCycle.values())
.filter(e -> e.getName().equals(source))
.findAny()
.orElseThrow(IllegalArgumentException::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aplus.insurancesystem2.common.converter;
package aplus.insurancesystem.common.converter;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package aplus.insurancesystem2.common.converter;
package aplus.insurancesystem.common.converter;

import aplus.insurancesystem2.domain.customer.entity.customer.Role;
import aplus.insurancesystem.domain.customer.entity.customer.Role;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.util.EnumSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aplus.insurancesystem2.common.converter;
package aplus.insurancesystem.common.converter;

import java.util.Objects;

Expand All @@ -10,11 +10,11 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import aplus.insurancesystem2.common.exception.BusinessException;
import aplus.insurancesystem2.common.exception.ErrorCode;
import aplus.insurancesystem2.common.security.CustomUserDetails;
import aplus.insurancesystem2.common.security.CustomerInfo;
import aplus.insurancesystem2.domain.customer.entity.customer.Customer;
import aplus.insurancesystem.common.exception.BusinessException;
import aplus.insurancesystem.common.exception.ErrorCode;
import aplus.insurancesystem.common.security.CustomUserDetails;
import aplus.insurancesystem.common.security.CustomerInfo;
import aplus.insurancesystem.domain.customer.entity.customer.Customer;

@Component
public class UserInfoArgumentResolver implements HandlerMethodArgumentResolver {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package aplus.insurancesystem2.common.dto;
package aplus.insurancesystem.common.dto;

import aplus.insurancesystem2.common.exception.ErrorCode;
import aplus.insurancesystem.common.exception.ErrorCode;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package aplus.insurancesystem2.common.dto;
package aplus.insurancesystem.common.dto;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package aplus.insurancesystem2.common.exception;
package aplus.insurancesystem.common.exception;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
public class BusinessException extends RuntimeException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aplus.insurancesystem2.common.exception;
package aplus.insurancesystem.common.exception;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand All @@ -10,6 +10,8 @@ public enum ErrorCode {
// Common
INTERNAL_SERVER_ERROR(500, "C001", "서버에 오류가 발생하였습니다."),
NOT_LOGIN(401, "C002", "로그인이 필요합니다."),
UPLOAD_FILE_ERROR(500, "C003", "파일 업로드에 실패하였습니다."),
DOWNLOAD_FILE_ERROR(500, "C004", "파일 다운로드에 실패하였습니다."),

// Customer
CUSTOMER_NOT_FOUND(404, "U001", "고객을 찾을 수 없습니다."),
Expand All @@ -26,7 +28,10 @@ public enum ErrorCode {
// Contract
CONTRACT_NOT_FOUND(404, "C001", "계약을 찾을 수 없습니다."),

COMPENSATION_CLIAM_NOT_FOUND(404, "CC001" , "청구 내역을 찾을 수 없습니다."),
// Payment
PAYMENT_NOT_FOUND(404, "P001", "납입을 찾을 수 없습니다."),

COMPENSATION_CLAIM_NOT_FOUND(404, "CC001" , "청구 내역을 찾을 수 없습니다."),
CAR_ACCIDENT_NOT_FOUND(404, "CA001" ,"사고 접수 내역을 찾을 수 없습니다." ),
SURVEY_NOT_FOUND(404, "SV001", "손해사정 내역을 찾을 수 없습니다.");

Expand Down
Loading

0 comments on commit 4c7d013

Please sign in to comment.