Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
pminsung12 committed Aug 3, 2024
2 parents 44ac00a + 0a8a206 commit e7953c8
Show file tree
Hide file tree
Showing 99 changed files with 553 additions and 355 deletions.
3 changes: 1 addition & 2 deletions application/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ dependencies {
implementation(project(":common"))
implementation(project(":domain"))
implementation(project(":usecase"))
implementation(project(":infrastructure:jpa"))
implementation(project(":infrastructure:ncp"))
implementation(project(":infrastructure"))

// spring
implementation("org.springframework:spring-aspects")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package org.depromeet.spot.application.common.config;

import org.depromeet.spot.jpa.config.JpaConfig;
import org.depromeet.spot.ncp.NcpConfig;
import org.depromeet.spot.infrastructure.aws.AwsConfig;
import org.depromeet.spot.infrastructure.cache.config.CacheConfig;
import org.depromeet.spot.infrastructure.jpa.config.JpaConfig;
import org.depromeet.spot.usecase.config.UsecaseConfig;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@ComponentScan(basePackages = {"org.depromeet.spot.application"})
@Configuration
@Import(value = {UsecaseConfig.class, JpaConfig.class, NcpConfig.class, SwaggerConfig.class})
@Import(
value = {
UsecaseConfig.class,
JpaConfig.class,
AwsConfig.class,
CacheConfig.class,
SwaggerConfig.class
})
public class SpotApplicationConfig {}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
"/favicon.ico",
"/api/v1/members",
"/actuator",
"/api/v1/levelUpConditions",
"/api/v1/levels/info",
"/api/v1/baseball-teams",
};

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

import java.util.List;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;

import org.depromeet.spot.application.member.dto.response.LevelUpDialogInfo;
import org.depromeet.spot.application.member.dto.response.LevelUpTableResponse;
import org.depromeet.spot.domain.member.Level;
import org.depromeet.spot.usecase.port.in.member.LevelUsecase;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -17,15 +23,23 @@
@RestController
@RequiredArgsConstructor
@Tag(name = "레벨")
@RequestMapping("/api/v1/levelUpConditions")
public class LevelUpTableController {
@RequestMapping("/api/v1/levels")
public class ReadLevelController {

private final LevelUsecase levelUsecase;

@GetMapping
@GetMapping("/info")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "레벨업 조건 테이블 조회 API")
public List<LevelUpTableResponse> getLevelUpTable() {
return levelUsecase.findAllLevels().stream().map(LevelUpTableResponse::from).toList();
}

@GetMapping("/up/info")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "레벨업 다이얼로그 조회 API")
public LevelUpDialogInfo getLevelUpDialogInfo(@RequestParam @NotNull @Positive int nextLevel) {
Level level = levelUsecase.findLevelUpDialogInfo(nextLevel);
return LevelUpDialogInfo.from(level);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.depromeet.spot.application.member.dto.response;

import org.depromeet.spot.domain.member.Level;

public record LevelUpDialogInfo(String title, String levelUpImage) {

public static LevelUpDialogInfo from(Level level) {
return new LevelUpDialogInfo(level.getTitle(), level.getLevelUpImageUrl());
}
}
3 changes: 0 additions & 3 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
dependencies {
implementation(project(":common"))

// ImmutableMap을 위한 구아바 사용
implementation("com.google.guava:guava:31.0.1-jre")
}

tasks.jar { enabled = true }
Expand Down
54 changes: 27 additions & 27 deletions domain/src/main/java/org/depromeet/spot/domain/member/Level.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.depromeet.spot.domain.member;

import java.time.LocalDateTime;

import com.google.common.collect.ImmutableMap;
import java.util.Map;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -11,46 +10,47 @@
@AllArgsConstructor
public class Level {

private static final ImmutableMap<Integer, Integer> LEVEL_MINIMUM_CONDITIONS =
ImmutableMap.<Integer, Integer>builder()
.put(0, 0)
.put(1, 1)
.put(2, 3)
.put(3, 5)
.put(4, 8)
.put(5, 14)
.put(6, 21)
.build();
// of는 오버로딩으로 파라미터 수에 따라 사용됨. 10개 이상은 오버로딩 없어서 오류가 발생하니 주의!
private static final Map<Integer, Integer> LEVEL_MINIMUM_CONDITIONS =
Map.of(
0, 0,
1, 1,
2, 3,
3, 5,
4, 8,
5, 14,
6, 21);

private static final Map<Integer, Integer> LEVEL_MAXIMUM_CONDITIONS =
Map.of(
0, 0,
1, 2,
2, 4,
3, 7,
4, 13,
5, 20);

private static final ImmutableMap<Integer, Integer> LEVEL_MAXIMUM_CONDITIONS =
ImmutableMap.<Integer, Integer>builder()
.put(0, 0)
.put(1, 2)
.put(2, 4)
.put(3, 7)
.put(4, 13)
.put(5, 20)
.build();
private final Long id;
private final int value;
private final String title;
private final String mascotImageUrl;
private final String levelUpImageUrl;
private final LocalDateTime createdAt;
private final LocalDateTime updatedAt;
private final LocalDateTime deletedAt;

public static int calculateLevel(final long reviewCnt) {
if (reviewCnt > LEVEL_MINIMUM_CONDITIONS.get(6)) {
if (reviewCnt >= LEVEL_MINIMUM_CONDITIONS.get(6)) {
return 6;
} else if (reviewCnt > LEVEL_MAXIMUM_CONDITIONS.get(5)) {
} else if (reviewCnt >= LEVEL_MINIMUM_CONDITIONS.get(5)) {
return 5;
} else if (reviewCnt > LEVEL_MAXIMUM_CONDITIONS.get(4)) {
} else if (reviewCnt >= LEVEL_MINIMUM_CONDITIONS.get(4)) {
return 4;
} else if (reviewCnt > LEVEL_MAXIMUM_CONDITIONS.get(3)) {
} else if (reviewCnt >= LEVEL_MINIMUM_CONDITIONS.get(3)) {
return 3;
} else if (reviewCnt > LEVEL_MAXIMUM_CONDITIONS.get(2)) {
} else if (reviewCnt >= LEVEL_MINIMUM_CONDITIONS.get(2)) {
return 2;
} else if (reviewCnt > LEVEL_MAXIMUM_CONDITIONS.get(1)) {
} else if (reviewCnt >= LEVEL_MINIMUM_CONDITIONS.get(1)) {
return 1;
}
return 0;
Expand Down
33 changes: 33 additions & 0 deletions infrastructure/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
dependencies {
implementation(project(":common"))
implementation(project(":domain"))
implementation(project(":usecase"))

// spring
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-cache")
implementation("org.springframework.boot:spring-boot-starter-data-jpa:_")

// mysql
runtimeOnly("com.mysql:mysql-connector-j")

// queryDSL
implementation("com.querydsl:querydsl-jpa:_:jakarta")
annotationProcessor("com.querydsl:querydsl-apt:_:jakarta")
annotationProcessor("jakarta.annotation:jakarta.annotation-api")
annotationProcessor("jakarta.persistence:jakarta.persistence-api")

// p6spy
implementation("com.github.gavlyukovskiy:p6spy-spring-boot-starter:_")

// aws
implementation("org.springframework.cloud:spring-cloud-starter-aws:_")

// webflux (HTTP 요청에 사용)
implementation("org.springframework.boot:spring-boot-starter-webflux")

// caffeine cache
implementation("com.github.ben-manes.caffeine:caffeine:_")
}

tasks.bootJar { enabled = false }
tasks.jar { enabled = true }
26 changes: 0 additions & 26 deletions infrastructure/jpa/build.gradle.kts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions infrastructure/ncp/build.gradle.kts

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.depromeet.spot.ncp;
package org.depromeet.spot.infrastructure.aws;

import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -7,6 +7,6 @@

@Configuration
@EnableConfigurationProperties
@ConfigurationPropertiesScan(basePackages = {"org.depromeet.spot.ncp.property"})
@ComponentScan(basePackages = {"org.depromeet.spot.ncp"})
public class NcpConfig {}
@ConfigurationPropertiesScan(basePackages = {"org.depromeet.spot.infrastructure.aws.property"})
@ComponentScan(basePackages = {"org.depromeet.spot.infrastructure.aws"})
public class AwsConfig {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.depromeet.spot.ncp.config;
package org.depromeet.spot.infrastructure.aws.config;

import org.depromeet.spot.ncp.property.ObjectStorageProperties;
import org.depromeet.spot.infrastructure.aws.property.ObjectStorageProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
Expand Down
Loading

0 comments on commit e7953c8

Please sign in to comment.