-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/BSVR-25
- Loading branch information
Showing
18 changed files
with
314 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: 버그 레포트 | ||
about: 버그 제보 & QA | ||
title: "[BUG] " | ||
labels: 🐛 Bug | ||
assignees: "" | ||
--- | ||
|
||
## 📍 재현 위치 | ||
|
||
<!-- 이슈가 발생한 API나 어플 스크린샷, 실행 환경(OS) 등을 알려주세요. --> | ||
|
||
## 📌 상황 설명 | ||
|
||
<!-- 발생한 버그에 대해 알려주세요. (e.g. A 버튼 클릭시 B 오류가 발생했어요.) --> | ||
|
||
## 🤔 정상 기대값 (선택) | ||
|
||
<!-- 정상적으로 동작했다면 어떤 결과가 나와야 하는지 알려주세요. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
name: Suggest | ||
about: 프로젝트 관련해서 무엇이든 제안해주세요! | ||
title: "[제안]" | ||
labels: 👋 Suggest | ||
assignees: "" | ||
--- | ||
|
||
## 💁♀️ 제안 사항 | ||
|
||
<!-- 제안할 내용을 적어주세요. --> | ||
|
||
|
||
## 👀 제안 이유 | ||
|
||
<!-- 제안하는 이유를 알려주세요. (e.g., 이 제안을 통해 우리가 얻을 수 있는 것 등) --> | ||
|
||
|
||
## ✅ 참고 사항 | ||
|
||
<!-- 공유할 내용, 스크린샷 등을 넣어 주세요. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Build And Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
- main | ||
pull_request: | ||
branches: | ||
- dev | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" | ||
distribution: "corretto" | ||
|
||
- name: Cache Gradle | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test --stacktrace --parallel | ||
|
||
- name: Run tests | ||
run: ./gradlew test | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: JUnit Report Action | ||
uses: mikepenz/action-junit-report@v3 | ||
if: always() | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: Store test results | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: Test Report Summary | ||
if: always() | ||
run: | | ||
echo '## Test Report Summary' >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
./gradlew test --console=plain || true | ||
echo '```' >> $GITHUB_STEP_SUMMARY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
70 changes: 70 additions & 0 deletions
70
infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/common/P6spySqlFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.depromeet.spot.jpa.common; | ||
|
||
import java.util.Locale; | ||
|
||
import org.hibernate.engine.jdbc.internal.FormatStyle; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.p6spy.engine.logging.Category; | ||
import com.p6spy.engine.spy.appender.MessageFormattingStrategy; | ||
|
||
@Configuration | ||
public class P6spySqlFormatter implements MessageFormattingStrategy { | ||
|
||
private static String ROOT_PACKAGE = "org.depromeet.spot"; | ||
private static String P6SPY_PACKAGE = "org.depromeet.spot.jpa.common.P6spySqlFormatter"; | ||
|
||
@Override | ||
public String formatMessage( | ||
int connectionId, | ||
String now, | ||
long elapsed, | ||
String category, | ||
String prepared, | ||
String sql, | ||
String url) { | ||
sql = formatSql(category, sql); | ||
return String.format( | ||
"[%s] | took %d ms | connectionId %d | %s | %s", | ||
category, elapsed, connectionId, filterStack(), formatSql(category, sql)); | ||
} | ||
|
||
private String formatSql(String category, String sql) { | ||
if (isNotEmpty(sql) && isStatement(category)) { | ||
String trimmedSQL = sql.trim().toLowerCase(Locale.ROOT); | ||
if (isDDL(trimmedSQL)) { | ||
return FormatStyle.DDL.getFormatter().format(sql); | ||
} | ||
return FormatStyle.BASIC.getFormatter().format(sql); | ||
} | ||
return sql; | ||
} | ||
|
||
// 일반적인 쿼리인지 판단 | ||
// 트랜잭션 커밋, 롤백 등 쿼리가 아닌 작업은 포맷팅하지 않는다. | ||
private boolean isStatement(String category) { | ||
return Category.STATEMENT.getName().equals(category); | ||
} | ||
|
||
private boolean isNotEmpty(String sql) { | ||
return sql != null && !sql.trim().isEmpty(); | ||
} | ||
|
||
private boolean isDDL(String sql) { | ||
return (sql.startsWith("create")) || sql.startsWith("alter") || sql.startsWith("comment"); | ||
} | ||
|
||
private String filterStack() { | ||
StackTraceElement[] stackTraces = new Throwable().getStackTrace(); | ||
StringBuilder sb = new StringBuilder(); | ||
int order = 1; | ||
|
||
for (StackTraceElement element : stackTraces) { | ||
String trace = element.toString(); | ||
if (trace.startsWith(ROOT_PACKAGE) && !trace.contains(P6SPY_PACKAGE)) { | ||
sb.append("\n\t\t").append(order++).append(".").append(trace); | ||
} | ||
} | ||
return sb.toString(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/config/P6spyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.depromeet.spot.jpa.config; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
|
||
import org.depromeet.spot.jpa.common.P6spySqlFormatter; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.p6spy.engine.spy.P6SpyOptions; | ||
|
||
@Configuration | ||
public class P6spyConfig { | ||
|
||
@PostConstruct | ||
public void setLogMessageFormat() { | ||
P6SpyOptions.getActiveInstance().setLogMessageFormat(P6spySqlFormatter.class.getName()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/config/QueryDslConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.depromeet.spot.jpa.config; | ||
|
||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
@Configuration | ||
public class QueryDslConfig { | ||
|
||
@PersistenceContext private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory queryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...re/jpa/src/main/java/org/depromeet/spot/jpa/member/repository/MemberCustomRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.depromeet.spot.jpa.member.repository; | ||
|
||
import static org.depromeet.spot.jpa.member.entity.QMemberEntity.memberEntity; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.jpa.member.entity.MemberEntity; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class MemberCustomRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public List<MemberEntity> findByName(final String name) { | ||
return queryFactory.selectFrom(memberEntity).where(eqMemberName(name)).fetch(); | ||
} | ||
|
||
private BooleanExpression eqMemberName(final String name) { | ||
if (name == null) { | ||
return null; | ||
} | ||
return memberEntity.name.eq(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
usecase/src/main/java/org/depromeet/spot/usecase/port/in/MemberUsecase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package org.depromeet.spot.usecase.port.in; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.domain.member.Member; | ||
|
||
public interface MemberUsecase { | ||
|
||
Member create(String name); | ||
|
||
List<Member> findByName(String name); | ||
} |
4 changes: 4 additions & 0 deletions
4
usecase/src/main/java/org/depromeet/spot/usecase/port/out/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package org.depromeet.spot.usecase.port.out; | ||
|
||
import java.util.List; | ||
|
||
import org.depromeet.spot.domain.member.Member; | ||
|
||
public interface MemberRepository { | ||
|
||
Member save(Member member); | ||
|
||
List<Member> findByName(String name); | ||
} |
Oops, something went wrong.