Skip to content

Commit b89a48e

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/#4
2 parents ef705e2 + 03acdd5 commit b89a48e

File tree

18 files changed

+354
-4
lines changed

18 files changed

+354
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 🧪 Calendar Server Tests on Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
jobs:
10+
project-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: 📦 Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: 🏗️ Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'temurin'
21+
java-version: '17'
22+
23+
- name: 🎟️ Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
26+
- name: 🧪 Spring Boot Test
27+
run: ./gradlew clean application:wypl-calendar:test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 🧪 Image Server Tests on Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
jobs:
10+
project-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: 📦 Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: 🖼️ Install ImageMagick
18+
run: sudo apt-get install -y imagemagick
19+
20+
- name: 🏗️ Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
distribution: 'temurin'
24+
java-version: '17'
25+
26+
- name: 🎟️ Grant execute permission for gradlew
27+
run: chmod +x gradlew
28+
29+
- name: 🧪 Spring Boot Test
30+
run: ./gradlew clean application:wypl-image:test
31+
32+
- name: Add coverage to PR
33+
id: jacoco
34+
uses: madrapps/[email protected]
35+
with:
36+
title: 📄 Image Server Jacoco Coverage Report
37+
paths: ${{ github.workspace }}/**/wypl-image/reports/jacoco/test/jacocoTestReport.xml
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
min-coverage-overall: 80
40+
min-coverage-changed-files: 80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 🧪 Notification Server Tests on Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
9+
jobs:
10+
project-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: 📦 Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: 🏗️ Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'temurin'
21+
java-version: '21'
22+
23+
- name: 🎟️ Grant execute permission for gradlew
24+
run: chmod +x gradlew
25+
26+
- name: 🧪 Spring Boot Test
27+
run: ./gradlew clean application:wypl-notification:test

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ out/
4545
magick
4646

4747
### API Docs ###
48-
**/main/resources/static/swagger-ui/*.yaml
48+
**/main/resources/static/swagger-ui/*.yaml
49+
50+
### macOS ###
51+
.DS_Store

application/wypl-image/build.gradle

+58-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,63 @@ dependencies {
2626
testImplementation('org.mockito:mockito-core')
2727
}
2828

29-
// API Docs Start
29+
/* Jacoco Start */
30+
tasks.withType(JacocoReport).configureEach {
31+
reports {
32+
html.required.set(true)
33+
xml.required.set(true)
34+
html.outputLocation.set(file("reports/jacoco/index.xml"))
35+
xml.outputLocation.set(file("reports/jacoco/test/jacocoTestReport.xml"))
36+
}
37+
38+
classDirectories.setFrom(
39+
files(classDirectories.files.collect {
40+
fileTree(it) {
41+
exclude(
42+
"**/*Application*",
43+
"**/*Configuration*",
44+
"**/*Request*",
45+
"**/*Response*",
46+
"**/common/**",
47+
"**/config/**",
48+
"**/data/**",
49+
"**/exception/**",
50+
"**/properties/**"
51+
)
52+
}
53+
})
54+
)
55+
}
56+
57+
tasks.jacocoTestCoverageVerification {
58+
violationRules {
59+
rule {
60+
enabled = true
61+
element = 'CLASS'
62+
63+
limit {
64+
counter = 'LINE'
65+
value = 'COVEREDRATIO'
66+
minimum = 0.80D
67+
}
68+
69+
excludes = [
70+
"**/*Application*",
71+
"**/*Configuration*",
72+
"**/*Request*",
73+
"**/*Response*",
74+
"**/common/**",
75+
"**/config/**",
76+
"**/data/**",
77+
"**/exception/**",
78+
"**/properties/**"
79+
]
80+
}
81+
}
82+
}
83+
/* Jacoco End */
84+
85+
/* API Docs Start */
3086
openapi3 {
3187
setServer("http://127.0.0.1:8080")
3288
title = "What's Your Plan! Image Server API Docs"
@@ -42,4 +98,4 @@ tasks.register("copyOasToSwagger", Copy) {
4298
from("build/api-spec/openapi3.yaml")
4399
into("src/main/resources/static/swagger-ui/")
44100
}
45-
// API Docs End
101+
/* API Docs End */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.wypl.common.exception;
2+
3+
public enum GlobalErrorCode implements ServerErrorCode {
4+
INTERNAL_SERVER_ERROR(500, "GLOBAL_001", "알수 없는 서버의 오류입니다."),
5+
;
6+
7+
private final int statusCode;
8+
private final String errorCode;
9+
private final String message;
10+
11+
private GlobalErrorCode(int statusCode, String errorCode, String message) {
12+
this.statusCode = statusCode;
13+
this.errorCode = errorCode;
14+
this.message = message;
15+
}
16+
17+
@Override
18+
public String getErrorCode() {
19+
return errorCode;
20+
}
21+
22+
@Override
23+
public String getMessage() {
24+
return message;
25+
}
26+
27+
@Override
28+
public int getStatusCode() {
29+
return statusCode;
30+
}
31+
}

domain/jpa-core/build.gradle

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ java {
55
}
66

77
dependencies {
8+
implementation project(':common')
9+
810
api('org.springframework.boot:spring-boot-starter-data-jpa')
911

10-
runtimeOnly 'com.h2database:h2'
12+
runtimeOnly('com.h2database:h2')
1113
}

domain/jpa-core/src/main/java/com/wypl/jpacore/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.wypl.jpacore;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
5+
6+
@EnableJpaAuditing
7+
@Configuration
8+
public class JpaAuditingConfig {
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.wypl.jpacore;
2+
3+
import java.time.LocalDateTime;
4+
5+
import org.springframework.data.annotation.CreatedDate;
6+
import org.springframework.data.annotation.LastModifiedDate;
7+
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
8+
9+
import com.wypl.common.exception.WyplException;
10+
11+
import jakarta.persistence.Column;
12+
import jakarta.persistence.EntityListeners;
13+
import jakarta.persistence.MappedSuperclass;
14+
import lombok.Getter;
15+
import lombok.NoArgsConstructor;
16+
17+
@Getter
18+
@MappedSuperclass
19+
@NoArgsConstructor
20+
@EntityListeners(AuditingEntityListener.class)
21+
public abstract class JpaBaseEntity {
22+
23+
@CreatedDate
24+
@Column(name = "created_at", nullable = false, updatable = false)
25+
private LocalDateTime createdAt;
26+
27+
@LastModifiedDate
28+
@Column(name = "modified_at", nullable = false)
29+
private LocalDateTime modifiedAt;
30+
31+
@Column(name = "deleted_at")
32+
private LocalDateTime deletedAt;
33+
34+
public void delete() {
35+
if (isDeleted()) {
36+
throw new WyplException(JpaErrorCode.ALREADY_DELETED_ENTITY);
37+
}
38+
this.deletedAt = LocalDateTime.now();
39+
}
40+
41+
public void restore() {
42+
if (isNotDeleted()) {
43+
throw new WyplException(JpaErrorCode.NON_DELETED_ENTITY);
44+
}
45+
this.deletedAt = null;
46+
}
47+
48+
public boolean isNotDeleted() {
49+
return deletedAt == null;
50+
}
51+
52+
public boolean isDeleted() {
53+
return !isNotDeleted();
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.wypl.jpacore;
2+
3+
import com.wypl.common.exception.ServerErrorCode;
4+
5+
import lombok.Getter;
6+
7+
@Getter
8+
public enum JpaErrorCode implements ServerErrorCode {
9+
ALREADY_DELETED_ENTITY(400, "JPA_001", "이미 삭제된 요소는 삭제할 수 없습니다."),
10+
NON_DELETED_ENTITY(400, "JPA_002", "삭제되지 않은 요소는 복구할 수 없습니다.");
11+
private final int statusCode;
12+
private final String errorCode;
13+
private final String message;
14+
15+
private JpaErrorCode(int statusCode, String errorCode, String message) {
16+
this.statusCode = statusCode;
17+
this.errorCode = errorCode;
18+
this.message = message;
19+
}
20+
}

domain/jpa-core/src/main/resources/application.yml

Whitespace-only changes.

domain/mongo-core/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ java {
55
}
66

77
dependencies {
8+
implementation project(':common')
9+
810
/* Database */
911
api('org.springframework.boot:spring-boot-starter-data-mongodb')
1012
implementation('de.flapdoodle.embed:de.flapdoodle.embed.mongo.spring31x:4.11.0')

domain/mongo-core/src/main/java/com/wypl/mongocore/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.wypl.mongocore;
2+
3+
import org.springframework.context.annotation.Configuration;
4+
import org.springframework.data.mongodb.config.EnableMongoAuditing;
5+
6+
@EnableMongoAuditing
7+
@Configuration
8+
public class MongoAuditingConfig {
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.wypl.mongocore;
2+
3+
import java.time.LocalDateTime;
4+
5+
import org.springframework.data.annotation.CreatedDate;
6+
import org.springframework.data.annotation.LastModifiedDate;
7+
import org.springframework.data.mongodb.core.mapping.Field;
8+
9+
import com.wypl.common.exception.WyplException;
10+
11+
import lombok.Getter;
12+
import lombok.NoArgsConstructor;
13+
14+
@Getter
15+
@NoArgsConstructor
16+
public abstract class MongoBaseEntity {
17+
@CreatedDate
18+
@Field(name = "created_at", write = Field.Write.NON_NULL)
19+
private LocalDateTime createdAt;
20+
21+
@LastModifiedDate
22+
@Field(name = "modified_at", write = Field.Write.NON_NULL)
23+
private LocalDateTime modifiedAt;
24+
25+
@Field(name = "deleted_at")
26+
private LocalDateTime deletedAt;
27+
28+
public void delete() {
29+
if (isDeleted()) {
30+
throw new WyplException(MongoErrorCode.ALREADY_DELETED_ENTITY);
31+
}
32+
this.deletedAt = LocalDateTime.now();
33+
}
34+
35+
public void restore() {
36+
if (isNotDeleted()) {
37+
throw new WyplException(MongoErrorCode.NON_DELETED_ENTITY);
38+
}
39+
this.deletedAt = null;
40+
}
41+
42+
public boolean isNotDeleted() {
43+
return deletedAt == null;
44+
}
45+
46+
public boolean isDeleted() {
47+
return !isNotDeleted();
48+
}
49+
}

0 commit comments

Comments
 (0)