Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5기 이경민, 소승수] Spring Boot JPA 게시판 구현 미션 제출합니다. #266

Open
wants to merge 7 commits into
base: voidmelody,-tidavid1---mission
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
HELP.md
.gradle
build/*
!build/generated-snippets
!build/generated-snippets/*
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
51 changes: 51 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
}

group = 'com.programmers'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

ext {
set('snippetsDir', file("build/generated-snippets"))
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
}

tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-base:latest'
}

tasks.named('test') {
outputs.dir snippetsDir
useJUnitPlatform()
}

tasks.named('asciidoctor') {
inputs.dir snippetsDir
dependsOn test
}
6 changes: 6 additions & 0 deletions build/generated-snippets/post-create/curl-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[source,bash]
----
$ curl 'http://localhost:8080/posts' -i -X POST \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{"title":"title","content":"content","userId":4}'
----
9 changes: 9 additions & 0 deletions build/generated-snippets/post-create/http-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[source,http,options="nowrap"]
----
POST /posts HTTP/1.1
Content-Type: application/json;charset=UTF-8
Content-Length: 48
Host: localhost:8080

{"title":"title","content":"content","userId":4}
----
8 changes: 8 additions & 0 deletions build/generated-snippets/post-create/http-response.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[source,http,options="nowrap"]
----
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 212

{"code":0,"data":{"postId":4,"title":"title","content":"content","user":{"userId":4,"name":"username","age":26,"hobby":"testHobby"},"createdAt":"2023-11-18T21:25:14.113386","createdBy":"username"},"success":true}
----
5 changes: 5 additions & 0 deletions build/generated-snippets/post-create/httpie-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[source,bash]
----
$ echo '{"title":"title","content":"content","userId":4}' | http POST 'http://localhost:8080/posts' \
'Content-Type:application/json;charset=UTF-8'
----
4 changes: 4 additions & 0 deletions build/generated-snippets/post-create/request-body.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,json,options="nowrap"]
----
{"title":"title","content":"content","userId":4}
----
16 changes: 16 additions & 0 deletions build/generated-snippets/post-create/request-fields.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
|===
|Path|Type|Description

|`+title+`
|`+String+`
|제목

|`+content+`
|`+String+`
|컨텐츠

|`+userId+`
|`+Number+`
|유저 ID

|===
4 changes: 4 additions & 0 deletions build/generated-snippets/post-create/response-body.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,json,options="nowrap"]
----
{"code":0,"data":{"postId":4,"title":"title","content":"content","user":{"userId":4,"name":"username","age":26,"hobby":"testHobby"},"createdAt":"2023-11-18T21:25:14.113386","createdBy":"username"},"success":true}
----
48 changes: 48 additions & 0 deletions build/generated-snippets/post-create/response-fields.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
|===
|Path|Type|Description

|`+code+`
|`+Number+`
|응답 코드

|`+data.postId+`
|`+Number+`
|포스트 ID

|`+data.title+`
|`+String+`
|제목

|`+data.content+`
|`+String+`
|컨텐츠

|`+data.user.userId+`
|`+Number+`
|유저 ID

|`+data.user.name+`
|`+String+`
|유저 이름

|`+data.user.age+`
|`+Number+`
|유저 나이

|`+data.user.hobby+`
|`+String+`
|유저 취미

|`+data.createdAt+`
|`+String+`
|작성 시간

|`+data.createdBy+`
|`+String+`
|작성자

|`+success+`
|`+Boolean+`
|성공 여부

|===
4 changes: 4 additions & 0 deletions build/generated-snippets/post-getAllPost/curl-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,bash]
----
$ curl 'http://localhost:8080/posts?page=0&size=10' -i -X GET
----
6 changes: 6 additions & 0 deletions build/generated-snippets/post-getAllPost/http-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[source,http,options="nowrap"]
----
GET /posts?page=0&size=10 HTTP/1.1
Host: localhost:8080

----
8 changes: 8 additions & 0 deletions build/generated-snippets/post-getAllPost/http-response.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[source,http,options="nowrap"]
----
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 531

{"code":0,"data":{"content":[{"postId":3,"title":"제목","content":"컨텐츠","user":{"userId":3,"name":"username","age":26,"hobby":"testHobby"},"createdAt":"2023-11-18T21:25:14.072675","createdBy":"username"}],"pageable":{"pageNumber":0,"pageSize":10,"sort":{"empty":true,"sorted":false,"unsorted":true},"offset":0,"paged":true,"unpaged":false},"last":true,"totalElements":1,"totalPages":1,"first":true,"size":10,"number":0,"sort":{"empty":true,"sorted":false,"unsorted":true},"numberOfElements":1,"empty":false},"success":true}
----
4 changes: 4 additions & 0 deletions build/generated-snippets/post-getAllPost/httpie-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,bash]
----
$ http GET 'http://localhost:8080/posts?page=0&size=10'
----
4 changes: 4 additions & 0 deletions build/generated-snippets/post-getAllPost/request-body.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,options="nowrap"]
----

----
4 changes: 4 additions & 0 deletions build/generated-snippets/post-getAllPost/response-body.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,json,options="nowrap"]
----
{"code":0,"data":{"content":[{"postId":3,"title":"제목","content":"컨텐츠","user":{"userId":3,"name":"username","age":26,"hobby":"testHobby"},"createdAt":"2023-11-18T21:25:14.072675","createdBy":"username"}],"pageable":{"pageNumber":0,"pageSize":10,"sort":{"empty":true,"sorted":false,"unsorted":true},"offset":0,"paged":true,"unpaged":false},"last":true,"totalElements":1,"totalPages":1,"first":true,"size":10,"number":0,"sort":{"empty":true,"sorted":false,"unsorted":true},"numberOfElements":1,"empty":false},"success":true}
----
124 changes: 124 additions & 0 deletions build/generated-snippets/post-getAllPost/response-fields.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
|===
|Path|Type|Description

|`+code+`
|`+Number+`
|응답 코드

|`+data.content[].postId+`
|`+Number+`
|포스트 ID

|`+data.content[].title+`
|`+String+`
|제목

|`+data.content[].content+`
|`+String+`
|컨텐츠

|`+data.content[].user.userId+`
|`+Number+`
|유저 ID

|`+data.content[].user.name+`
|`+String+`
|유저 이름

|`+data.content[].user.age+`
|`+Number+`
|유저 나이

|`+data.content[].user.hobby+`
|`+String+`
|유저 취미

|`+data.content[].createdAt+`
|`+String+`
|작성 시간

|`+data.content[].createdBy+`
|`+String+`
|작성자

|`+data.pageable.pageNumber+`
|`+Number+`
|페이지 번호

|`+data.pageable.pageSize+`
|`+Number+`
|페이지 크기

|`+data.pageable.sort.empty+`
|`+Boolean+`
|공백 여부

|`+data.pageable.sort.sorted+`
|`+Boolean+`
|정렬 여부(O)

|`+data.pageable.sort.unsorted+`
|`+Boolean+`
|정렬 여부 (X)

|`+data.pageable.offset+`
|`+Number+`
|오프셋

|`+data.pageable.paged+`
|`+Boolean+`
|페이지 여부(O)

|`+data.pageable.unpaged+`
|`+Boolean+`
|페이지 여부(X)

|`+data.last+`
|`+Boolean+`
|마지막 여부

|`+data.totalPages+`
|`+Number+`
|전체 페이지

|`+data.totalElements+`
|`+Number+`
|전체 원소 개수

|`+data.first+`
|`+Boolean+`
|처음 여부

|`+data.size+`
|`+Number+`
|크기

|`+data.number+`
|`+Number+`
|번호

|`+data.sort.empty+`
|`+Boolean+`
|정렬 공백 여부

|`+data.sort.sorted+`
|`+Boolean+`
|정렬 여부(O)

|`+data.sort.unsorted+`
|`+Boolean+`
|정렬 여부(X)

|`+data.numberOfElements+`
|`+Number+`
|원소 갯수

|`+data.empty+`
|`+Boolean+`
|공백 여부

|`+success+`
|`+Boolean+`
|성공 여부

|===
4 changes: 4 additions & 0 deletions build/generated-snippets/post-getById/curl-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[source,bash]
----
$ curl 'http://localhost:8080/posts/1' -i -X GET
----
6 changes: 6 additions & 0 deletions build/generated-snippets/post-getById/http-request.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[source,http,options="nowrap"]
----
GET /posts/1 HTTP/1.1
Host: localhost:8080

----
Loading