-
Notifications
You must be signed in to change notification settings - Fork 1
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 #21 from Fairy-Taless/dev
Dev
- Loading branch information
Showing
109 changed files
with
4,340 additions
and
0 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,72 @@ | ||
name: FairyTale Dev CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ "dev" ] | ||
pull_request: | ||
branches: [ "dev" ] | ||
workflow_dispatch: | ||
|
||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
# JDK 설정 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
# gradle build 시간 향상 | ||
- name: Gradle Caching | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
# application.yml 파일 생성 | ||
- name: make application.yml | ||
run: | | ||
mkdir -p src/main/resources | ||
echo "$APPLICATION" > src/main/resources/application.yml | ||
env: | ||
APPLICATION: ${{ secrets.APPLICATION }} | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
- name: Docker build | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t app . | ||
docker tag app ${{ secrets.DOCKER_USERNAME }}/fairytale:latest | ||
docker push ${{ secrets.DOCKER_USERNAME }}/fairytale:latest | ||
- name: Deploy to dev | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/fairytale:latest | ||
sudo docker stop $(docker ps -a -q) | ||
sudo docker run -d --log-driver=syslog -p 8080:8080 -e SPRING_PROFILES_ACTIVE= ${{ secrets.DOCKER_USERNAME }}/fairytale:latest | ||
sudo docker rm $(docker ps --filter 'status=exited' -a -q) | ||
sudo docker image prune -a -f | ||
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,3 @@ | ||
FROM openjdk:17 | ||
COPY ./build/libs/TBD-0.0.1-SNAPSHOT.jar fairytale.jar | ||
ENTRYPOINT ["java", "-jar", "fairytale.jar"] |
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
18 changes: 18 additions & 0 deletions
18
src/main/java/fairytale/tbd/domain/faceSwap/converter/FaceSwapConverter.java
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,18 @@ | ||
package fairytale.tbd.domain.faceSwap.converter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import fairytale.tbd.domain.faceSwap.entity.OriginalCharacter; | ||
import fairytale.tbd.domain.faceSwap.web.dto.FaceResponseDTO; | ||
|
||
public class FaceSwapConverter { | ||
|
||
public static FaceResponseDTO.OriginalCharacterSaveResponseDTO toOriginalCharacterSaveResponseDTO( | ||
OriginalCharacter originalCharacter) { | ||
return FaceResponseDTO.OriginalCharacterSaveResponseDTO.builder() | ||
.created_at(LocalDateTime.now()) | ||
.image_url(originalCharacter.getOriginalURL()) | ||
.original_character_id(originalCharacter.getOriginId()) | ||
.build(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/fairytale/tbd/domain/faceSwap/entity/CustomCharacter.java
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,53 @@ | ||
package fairytale.tbd.domain.faceSwap.entity; | ||
|
||
import fairytale.tbd.domain.fairytale.entity.Fairytale; | ||
import fairytale.tbd.domain.user.entity.User; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "custom_character") | ||
public class CustomCharacter { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "custom_character_id") | ||
private Long customId; | ||
|
||
@Column(name = "custom_character_image_url", nullable = false) | ||
private String customURL; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@Column(name = "page_num", nullable = false) | ||
private Long pageNum; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "fairytale_id") | ||
private Fairytale fairytale; | ||
|
||
public void setUser(User user) { | ||
this.user = user; | ||
} | ||
|
||
public void setFairytale(Fairytale fairytale) { | ||
this.fairytale = fairytale; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/fairytale/tbd/domain/faceSwap/entity/ImageSaveQueue.java
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,41 @@ | ||
package fairytale.tbd.domain.faceSwap.entity; | ||
|
||
import fairytale.tbd.global.entity.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "image_save_queue") | ||
public class ImageSaveQueue extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "image_save_id") | ||
private Long id; | ||
|
||
@Column(name = "user_id", nullable = false) | ||
private Long userId; | ||
|
||
@Column(name = "image_url", nullable = false) | ||
private String imageURL; | ||
|
||
@Column(name = "page_num", nullable = false) | ||
private Long pageNum; | ||
|
||
@Column(name = "fairytale_id", nullable = false) | ||
private Long fairytaleId; | ||
|
||
@Column(name = "image_swap_request_id", nullable = false) | ||
private String requestId; | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/fairytale/tbd/domain/faceSwap/entity/OriginalCharacter.java
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,50 @@ | ||
package fairytale.tbd.domain.faceSwap.entity; | ||
|
||
import fairytale.tbd.domain.fairytale.entity.Fairytale; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "original_character") | ||
public class OriginalCharacter { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "original_character_id") | ||
private Long originId; | ||
|
||
@Column(name = "originl_character_image_url", nullable = false) | ||
private String originalURL; | ||
|
||
@Column(name = "page_num", nullable = false) | ||
private Long pageNum; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "fairytale_id") | ||
private Fairytale fairytale; | ||
|
||
@Column(name = "original_character_image_opts", nullable = false) | ||
private String opts; | ||
|
||
// 연관 관계 편의 메서드 | ||
|
||
public void setFairytale(Fairytale fairytale) { | ||
this.fairytale = fairytale; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/fairytale/tbd/domain/faceSwap/entity/Uuid.java
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,18 @@ | ||
package fairytale.tbd.domain.faceSwap.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
@Entity | ||
@Getter | ||
@Builder | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
|
||
public class Uuid { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long uuidId; | ||
|
||
@Column(unique = true) | ||
private String uuid; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/fairytale/tbd/domain/faceSwap/exception/FaceNotDetectException.java
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,10 @@ | ||
package fairytale.tbd.domain.faceSwap.exception; | ||
|
||
import fairytale.tbd.global.enums.statuscode.BaseCode; | ||
import fairytale.tbd.global.exception.GeneralException; | ||
|
||
public class FaceNotDetectException extends GeneralException { | ||
public FaceNotDetectException(BaseCode errorStatus) { | ||
super(errorStatus); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/fairytale/tbd/domain/faceSwap/exception/FaceSwapFailureException.java
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,10 @@ | ||
package fairytale.tbd.domain.faceSwap.exception; | ||
|
||
import fairytale.tbd.global.enums.statuscode.BaseCode; | ||
import fairytale.tbd.global.exception.GeneralException; | ||
|
||
public class FaceSwapFailureException extends GeneralException { | ||
public FaceSwapFailureException(BaseCode errorStatus) { | ||
super(errorStatus); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/fairytale/tbd/domain/faceSwap/exception/UserFaceNotExistException.java
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,10 @@ | ||
package fairytale.tbd.domain.faceSwap.exception; | ||
|
||
import fairytale.tbd.global.enums.statuscode.BaseCode; | ||
import fairytale.tbd.global.exception.GeneralException; | ||
|
||
public class UserFaceNotExistException extends GeneralException { | ||
public UserFaceNotExistException(BaseCode errorStatus) { | ||
super(errorStatus); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/fairytale/tbd/domain/faceSwap/repository/CustomCharacterRepository.java
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,13 @@ | ||
package fairytale.tbd.domain.faceSwap.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import fairytale.tbd.domain.faceSwap.entity.CustomCharacter; | ||
|
||
@Repository | ||
public interface CustomCharacterRepository extends JpaRepository<CustomCharacter, Long> { | ||
List<CustomCharacter> findByUserIdAndFairytaleId(Long userId, Long fairytaleId); | ||
} |
Oops, something went wrong.