Skip to content

Commit

Permalink
feat :: 예/적금 엔티티/타입 추가 및 SwaggerUI 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
DSMInhyeKang committed May 23, 2024
1 parent 541f754 commit 824e6c5
Show file tree
Hide file tree
Showing 16 changed files with 148 additions and 12 deletions.
6 changes: 4 additions & 2 deletions myfintech/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
// security
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
// jwt
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
// lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// oauth
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.inhyekang.myfintech.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
String jwt = "JWT";
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwt);
Components components = new Components().addSecuritySchemes(jwt, new SecurityScheme()
.name(jwt)
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")
);
return new OpenAPI()
.components(new Components())
.info(apiInfo())
.addSecurityItem(securityRequirement)
.components(components);
}
private Info apiInfo() {
return new Info()
.title("MyFintech API")
.description("내 목돈을 지켜줘! 서비스 API 명세입니다.")
.version("1.0.0");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhyekang.myfintech.dto.response;

import com.inhyekang.myfintech.entity.User;
import com.inhyekang.myfintech.entity.user.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhyekang.myfintech.dto.response;

import com.inhyekang.myfintech.entity.User;
import com.inhyekang.myfintech.entity.user.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.inhyekang.myfintech.entity.product;

import jakarta.persistence.*;
import lombok.*;

@Entity
@Table
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Deposit {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
@Enumerated(value = EnumType.STRING)
private DepositType type;

@Column(nullable = false)
private String name;

@Column(nullable = false)
private String company;

private String maxRate;

private String defaultRate;

private String target;

@Column(nullable = false)
private boolean isProtected;

@Column(columnDefinition = "TEXT", nullable = false)
private String detail;

@Column(nullable = false)
private Long URL;

@Column(nullable = false)
private boolean isBankingSector;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.inhyekang.myfintech.entity.product;

public enum DepositType {
DEPOSIT, // 정기 예금
CMA, // CMA
PARKING, // 파킹통장
MMDA // MMDA
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.inhyekang.myfintech.entity.product;

import jakarta.persistence.*;

public class Savings {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
@Enumerated(value = EnumType.STRING)
private DepositType type;

@Column(nullable = false)
private String name;

@Column(nullable = false)
private String company;

private String maxRate;

private String defaultRate;

private String target;

@Column(nullable = false)
private boolean isProtected;

@Column(columnDefinition = "TEXT", nullable = false)
private String detail;

@Column(nullable = false)
private Long URL;

@Column(nullable = false)
private boolean isBankingSector;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.inhyekang.myfintech.entity.product;

public enum SavingsType {
REGULAR, // 정기적금
FREE, // 자유적금
YOUTH, // 청년적금
YOUNG_JUMP, // 청년도약계좌
HOUSING_SUBS, // 주택청약통장
SOLDIER // 군인적금
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.inhyekang.myfintech.entity;
package com.inhyekang.myfintech.entity.user;

import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.inhyekang.myfintech.entity;
package com.inhyekang.myfintech.entity.user;

import jakarta.persistence.*;
import lombok.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhyekang.myfintech.facade;

import com.inhyekang.myfintech.entity.User;
import com.inhyekang.myfintech.entity.user.User;
import com.inhyekang.myfintech.exception.TokenInvalidException;
import com.inhyekang.myfintech.exception.UserNotFoundException;
import com.inhyekang.myfintech.repository.UserRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhyekang.myfintech.repository;

import com.inhyekang.myfintech.entity.RefreshToken;
import com.inhyekang.myfintech.entity.user.RefreshToken;
import org.springframework.data.repository.CrudRepository;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.inhyekang.myfintech.repository;

import com.inhyekang.myfintech.entity.User;
import com.inhyekang.myfintech.entity.user.User;
import org.springframework.data.repository.CrudRepository;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.inhyekang.myfintech.security.jwt;

import com.inhyekang.myfintech.dto.response.TokensResponse;
import com.inhyekang.myfintech.entity.RefreshToken;
import com.inhyekang.myfintech.entity.user.RefreshToken;
import com.inhyekang.myfintech.exception.TokenExpiredException;
import com.inhyekang.myfintech.exception.TokenInvalidException;
import com.inhyekang.myfintech.repository.RefreshTokenRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.inhyekang.myfintech.dto.request.RegisterRequest;
import com.inhyekang.myfintech.dto.response.FindUserInfoResponse;
import com.inhyekang.myfintech.dto.response.SearchUserResponse;
import com.inhyekang.myfintech.entity.User;
import com.inhyekang.myfintech.entity.user.User;
import com.inhyekang.myfintech.exception.UserAlreadyExistException;
import com.inhyekang.myfintech.exception.UserNotFoundException;
import com.inhyekang.myfintech.facade.UserFacade;
Expand Down Expand Up @@ -32,6 +32,7 @@ public void register(RegisterRequest request) {
.build());
}
}

public FindUserInfoResponse findMyInfo() {

User user = userFacade.currentUser();
Expand Down

0 comments on commit 824e6c5

Please sign in to comment.