-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from hseong3243/feat/pagination
[박혜성] step-8 페이징 구현하기
- Loading branch information
Showing
62 changed files
with
800 additions
and
465 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: [ "hseong3243" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{secrets.ACTION_TOKEN}} | ||
submodules: true | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 | ||
with: | ||
arguments: build | ||
|
||
- name: Build and save Docker image | ||
run: | | ||
docker build -t jsp-cafe:${{ github.sha }} . | ||
docker save -o jsp-cafe.tar jsp-cafe:${{ github.sha }} | ||
chmod 664 jsp-cafe.tar | ||
- name: copy file via ssh password | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.AWS_HOST }} | ||
username: ${{ secrets.AWS_USERNAME }} | ||
key: ${{ secrets.AWS_PRIVATE_KEY }} | ||
source: "jsp-cafe.tar" | ||
target: "/home/ubuntu" | ||
|
||
- name: executing remote ssh commands using password | ||
uses: appleboy/[email protected] | ||
with: | ||
username: ${{ secrets.AWS_USERNAME }} | ||
host: ${{ secrets.AWS_HOST }} | ||
key: ${{ secrets.AWS_PRIVATE_KEY }} | ||
script: | | ||
docker stop $(docker ps -a -q) || true | ||
docker rmi $(docker images -q) | ||
docker load -i jsp-cafe.tar | ||
docker run -d -p 8080:8080 --add-host=host.docker.internal:host-gateway jsp-cafe:${{ github.sha }} | ||
rm jsp-cafe.tar |
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,11 @@ | ||
FROM tomcat:jdk17 | ||
|
||
WORKDIR /usr/local/tomcat | ||
|
||
ARG WAR_FILE=build/libs/*.war | ||
|
||
COPY ${WAR_FILE} /usr/local/tomcat/webapps/ROOT.war | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["catalina.sh", "run"] |
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
This file was deleted.
Oops, something went wrong.
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
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,83 @@ | ||
package com.woowa.database; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class Page<T> { | ||
private final List<T> content; | ||
private final Long totalElements; | ||
private final int totalPages; | ||
private final boolean hasNext; | ||
private final int page; | ||
private final int size; | ||
|
||
public Page(List<T> content, Long totalElements, int totalPages, boolean hasNext, int page, int size) { | ||
this.content = content; | ||
this.totalElements = totalElements; | ||
this.totalPages = totalPages; | ||
this.hasNext = hasNext; | ||
this.page = page; | ||
this.size = size; | ||
} | ||
|
||
public static <T> Page<T> of(List<T> content, Long count, int page, int size) { | ||
int totalPages = (int) Math.ceil((double) count / size); | ||
boolean hasNext = (long) page * size + size < count; | ||
return new Page<>(content, count, totalPages, hasNext, page, size); | ||
} | ||
|
||
public List<T> getContent() { | ||
return content; | ||
} | ||
|
||
public Long getTotalElements() { | ||
return totalElements; | ||
} | ||
|
||
public int getTotalPages() { | ||
return totalPages; | ||
} | ||
|
||
public boolean isHasNext() { | ||
return hasNext; | ||
} | ||
|
||
public int getPage() { | ||
return page; | ||
} | ||
|
||
public int getSize() { | ||
return size; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Page<?> page1 = (Page<?>) o; | ||
return totalPages == page1.totalPages && hasNext == page1.hasNext && page == page1.page && size == page1.size | ||
&& Objects.equals(content, page1.content) && Objects.equals(totalElements, | ||
page1.totalElements); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(content, totalElements, totalPages, hasNext, page, size); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Page{" + | ||
"content=" + content + | ||
", totalElements=" + totalElements + | ||
", totalPages=" + totalPages + | ||
", hasNext=" + hasNext + | ||
", page=" + page + | ||
", size=" + size + | ||
'}'; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.