File tree Expand file tree Collapse file tree 7 files changed +159
-3
lines changed
java/com/back/matchduo/global Expand file tree Collapse file tree 7 files changed +159
-3
lines changed Original file line number Diff line number Diff line change 1+ name : MatchMyDuo CI
2+
3+ on :
4+ pull_request :
5+ branches : [ main ]
6+
7+ jobs :
8+ checks :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - uses : actions/checkout@v3
13+
14+ # 1) 브랜치 타입 검사
15+ - name : Validate Branch Type
16+ run : |
17+ BRANCH="${GITHUB_HEAD_REF}"
18+ if [[ ! "$BRANCH" =~ ^(feat|fix|docs|style|refactor|test|chore|rename|remove|init)\/ ]]; then
19+ echo "::error::Invalid branch type."
20+ exit 1
21+ fi
22+
23+ # 2) PR 제목 타입 검사
24+ - name : Validate PR Title Type
25+ run : |
26+ TITLE="${{ github.event.pull_request.title }}"
27+ if [[ ! "$TITLE" =~ ^\[(FE|BE)\/(feat|fix|docs|style|refactor|test|chore|rename|remove|init)\] ]]; then
28+ echo "::error::Invalid PR title type."
29+ exit 1
30+ fi
31+
32+ - name : Done
33+ run : echo "All naming type checks passed."
Original file line number Diff line number Diff line change 1+ version : ' 3.8'
2+
3+ services :
4+ mysql :
5+ image : mysql:8.0
6+ container_name : matchduo_db-mysql
7+ environment :
8+ MYSQL_ROOT_PASSWORD : ${DB_PW}
9+ MYSQL_DATABASE : matchduo_db
10+ ports :
11+ - " 3306:3306"
12+ command :
13+ - --default-authentication-plugin=mysql_native_password
14+ - --character-set-server=utf8mb4
15+ - --collation-server=utf8mb4_unicode_ci
16+ volumes :
17+ - mysql_data:/var/lib/mysql
18+ restart : unless-stopped
19+
20+ redis :
21+ image : redis:latest
22+ command : ["redis-server", "--requirepass", "${REDIS_PW}"]
23+ container_name : matchduo_redis
24+ ports :
25+ - " 6379:6379"
26+ volumes :
27+ - redis_data:/data
28+ restart : unless-stopped
29+
30+ volumes :
31+ mysql_data :
32+ redis_data :
33+
34+
Original file line number Diff line number Diff line change 1+ package com .back .matchduo .global .config ;
2+
3+ import org .springframework .context .annotation .Configuration ;
4+ import org .springframework .data .jpa .repository .config .EnableJpaAuditing ;
5+
6+ @ Configuration
7+ @ EnableJpaAuditing
8+ public class JpaConfig {
9+ }
Original file line number Diff line number Diff line change 1+ package com .back .matchduo .global .config ;
2+
3+ import jakarta .annotation .PostConstruct ;
4+ import jakarta .persistence .EntityManager ;
5+ import lombok .RequiredArgsConstructor ;
6+ import org .hibernate .Session ;
7+ import org .springframework .stereotype .Component ;
8+
9+ /**
10+ * Soft Delete된 데이터(is_active = false)가
11+ * 기본 조회(JPQL, Repository)에서 자동으로 제외되도록 Hibernate Filter를 활성화하는 설정
12+ */
13+ @ Component
14+ @ RequiredArgsConstructor
15+ public class SoftDeleteFilterConfig {
16+
17+ private final EntityManager entityManager ;
18+
19+ @ PostConstruct
20+ public void enableFilter () {
21+ // Hibernate Session 얻기
22+ Session session = entityManager .unwrap (Session .class );
23+
24+ // softDeleteFilter 활성화 (is_active = true 조건을 전역적으로 적용)
25+ session .enableFilter ("softDeleteFilter" );
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ package com .back .matchduo .global .entity ;
2+
3+ import jakarta .persistence .Column ;
4+ import jakarta .persistence .EntityListeners ;
5+ import jakarta .persistence .MappedSuperclass ;
6+ import lombok .Getter ;
7+ import org .springframework .data .annotation .CreatedDate ;
8+ import org .springframework .data .annotation .LastModifiedDate ;
9+ import org .springframework .data .jpa .domain .support .AuditingEntityListener ;
10+
11+ import java .time .LocalDateTime ;
12+
13+ @ MappedSuperclass
14+ @ EntityListeners (AuditingEntityListener .class )
15+ @ Getter
16+ public abstract class BaseEntity {
17+
18+ @ CreatedDate
19+ @ Column (nullable = false , updatable = false )
20+ private LocalDateTime createdAt ;
21+
22+ @ LastModifiedDate
23+ @ Column (nullable = false )
24+ private LocalDateTime updatedAt ;
25+
26+ // soft delete를 쓴다면 추가
27+ @ Column
28+ private LocalDateTime deletedAt ;
29+
30+ @ Column (nullable = false )
31+ private Boolean isActive = true ;
32+
33+ public void deactivate () {
34+ this .isActive = false ;
35+ this .deletedAt = LocalDateTime .now ();
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ package com .back .matchduo .global .entity ;
2+
3+ import jakarta .persistence .MappedSuperclass ;
4+ import org .hibernate .annotations .Filter ;
5+ import org .hibernate .annotations .FilterDef ;
6+
7+ @ MappedSuperclass
8+ @ FilterDef (name = "softDeleteFilter" )
9+ @ Filter (name = "softDeleteFilter" , condition = "is_active = true" )
10+ public abstract class SoftDeletableEntity extends BaseEntity {
11+ }
Original file line number Diff line number Diff line change 11spring :
2+ profiles :
3+ active : dev
24 datasource :
3- url : jdbc:h2:./db_dev;MODE=MySQL
4- username : sa
5- password:
5+ driver-class-name : com.mysql.cj.jdbc.Driver
6+ url : jdbc:mysql://localhost:3306/
7+ username : root
8+ password : ${DB_PASSWORD}
9+ hikari :
10+ auto-commit : false
You can’t perform that action at this time.
0 commit comments