Skip to content

Commit bf8e89f

Browse files
committed
Docs: README.md 작성
1 parent 55ff28e commit bf8e89f

1 file changed

Lines changed: 79 additions & 10 deletions

File tree

README.md

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,113 @@
22

33
![GitHub last commit (branch)](https://img.shields.io/github/last-commit/CoffeeDrivenDevelopment/sangchu-common/main)
44
![GitHub License](https://img.shields.io/badge/license-MIT-blue)
5+
[![](https://jitpack.io/v/CoffeeDrivenDevelopment/sangchu-common.svg)](https://jitpack.io/#CoffeeDrivenDevelopment/sangchu-common)
56

7+
해당 라이브러리는 `Sangchu` 프로젝트에서 사용하는 기본적인 기능들을 제공합니다.
68

7-
## Dependency
9+
## Quick Starter
810

9-
[Jitpack - Dependency]()
10-
11-
### build.gradle
11+
### 1. Add Dependency
1212

1313
---
1414

15+
**build.gradle**
16+
1517
```groovy
1618
repositories {
1719
mavenCentral()
1820
maven { url 'https://jitpack.io' }
1921
}
2022
2123
dependencies {
22-
implementation 'com.github.CoffeeDrivenDevelopment:sangchu-common:Tag'
24+
implementation 'com.github.CoffeeDrivenDevelopment:sangchu-common:0.0.2'
2325
}
2426
```
2527

26-
### build.gradle.kts
27-
28-
---
28+
**build.gradle.kts**
2929

3030
```kts
3131
repositories {
3232
mavenCentral()
33-
maven('https://jitpack.io')
33+
maven("https://jitpack.io")
3434
}
3535

3636
dependencies {
3737
implementation("com.github.CoffeeDrivenDevelopment:sangchu-common:Tag")
3838
}
3939
```
4040

41+
### 2. RestControllerAdvice
42+
43+
---
44+
45+
공통으로 사용하는 에러 처리용 `RestControllerAdvice`입니다.
46+
47+
**SangchuConfig.java**
48+
49+
```java
50+
51+
@Configuration
52+
public class SangchuConfig {
53+
@Bean
54+
public SangchuAdvice sangchuAdvice() {
55+
return new SangchuAdvice();
56+
}
57+
}
58+
```
59+
60+
**SangchuConfig.kt**
61+
62+
```kotlin
63+
@Configuration
64+
class SangchuConfig {
65+
@Bean
66+
fun sangchuAdvice(): SangchuAdvice {
67+
return SangchuAdvice()
68+
}
69+
}
70+
```
71+
72+
### 3. ResponseEntityFactory
73+
74+
---
75+
76+
반복되는 `ResponseEntity<MessageBody<Void>>` 와 같은 클래스를 생성해주는 유틸입니다.
77+
78+
예시는 아래와 같습니다.
79+
80+
```java
81+
82+
@GetMapping("/v1")
83+
public ResponseEntity<MessageBody<String>> get() {
84+
ResponseEntity<MessageBody<Passport>> response = ResponseEntityFactory.ok("Hello", "world!");
85+
return response;
86+
}
87+
```
88+
89+
```kotlin
90+
@GetMapping("/v1")
91+
fun get(): ResponseEntity<MessageBody<String>> {
92+
val response: ResponseEntity<MessageBody<Passport>> = ResponseEntityFactory.ok(
93+
message = "Hello",
94+
body = "world!"
95+
)
96+
return response
97+
}
98+
```
99+
100+
이 외에도 헤더를 추가하여 전송할 수 있는 `ResponseEntityFactoryWithHeaders`와 예외 처리를 담당하는 `ResponseEntityExceptionFactory`가 있습니다.
101+
41102
## Dependencies
42103

104+
해당 프로젝트에서 사용하는 라이브러리의 모음입니다.
105+
43106
- [Jackson Databind 2.15.3](https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.15.3)
44107

45-
> `2.15.3`을 사용하는 이유는 현재(2024.03.13) Spring Boot에서 사용하는 버전이 2.15.3이기 때문입니다.
108+
> `2.15.3`을 사용하는 이유는 현재(2024.03.13) Spring Boot에서 사용하는 버전이 2.15.3이기 때문입니다.
109+
110+
- [Lombok 1.18.30](https://mvnrepository.com/artifact/org.projectlombok/lombok/1.18.30)
111+
- [Spring WebMvc 6.1.5](https://mvnrepository.com/artifact/org.springframework/spring-webmvc/6.1.5)
112+
- [Spring Web 6.1.5](https://mvnrepository.com/artifact/org.springframework/spring-web/6.1.5)
113+
- [Slf4j Api 2.0.7](https://mvnrepository.com/artifact/org.slf4j/slf4j-api/2.0.7)
114+

0 commit comments

Comments
 (0)