-
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.
- Loading branch information
Showing
11 changed files
with
150 additions
and
17 deletions.
There are no files selected for viewing
8 changes: 7 additions & 1 deletion
8
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package fairytale.tbd.domain.faceSwap.repository; | ||
|
||
import fairytale.tbd.domain.faceSwap.entity.CustomCharacter; | ||
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); | ||
} |
8 changes: 7 additions & 1 deletion
8
src/main/java/fairytale/tbd/domain/faceSwap/repository/OriginalCharacterRepository.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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package fairytale.tbd.domain.faceSwap.repository; | ||
|
||
import fairytale.tbd.domain.faceSwap.entity.OriginalCharacter; | ||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import fairytale.tbd.domain.faceSwap.entity.OriginalCharacter; | ||
|
||
@Repository | ||
public interface OriginalCharacterRepository extends JpaRepository<OriginalCharacter, Long> { | ||
List<OriginalCharacter> findByFairytaleId(Long fairytaleId); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapQueryService.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,9 @@ | ||
package fairytale.tbd.domain.faceSwap.service; | ||
|
||
import java.util.Map; | ||
|
||
import fairytale.tbd.domain.user.entity.User; | ||
|
||
public interface FaceSwapQueryService { | ||
Map<Long, String> getFaceImages(User user, Long fairytaleId, boolean changeFace); | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/java/fairytale/tbd/domain/faceSwap/service/FaceSwapQueryServiceImpl.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,48 @@ | ||
package fairytale.tbd.domain.faceSwap.service; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import fairytale.tbd.domain.faceSwap.entity.CustomCharacter; | ||
import fairytale.tbd.domain.faceSwap.entity.OriginalCharacter; | ||
import fairytale.tbd.domain.faceSwap.repository.CustomCharacterRepository; | ||
import fairytale.tbd.domain.faceSwap.repository.OriginalCharacterRepository; | ||
import fairytale.tbd.domain.fairytale.entity.Fairytale; | ||
import fairytale.tbd.domain.fairytale.exception.FairytaleNotFoundException; | ||
import fairytale.tbd.domain.fairytale.repository.FairytaleRepository; | ||
import fairytale.tbd.domain.user.entity.User; | ||
import fairytale.tbd.global.enums.statuscode.ErrorStatus; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class FaceSwapQueryServiceImpl implements FaceSwapQueryService { | ||
private final FairytaleRepository fairytaleRepository; | ||
private final OriginalCharacterRepository originalCharacterRepository; | ||
private final CustomCharacterRepository customCharacterRepository; | ||
|
||
@Override | ||
public Map<Long, String> getFaceImages(User user, Long fairytaleId, boolean changeFace) { | ||
Map<Long, String> result = new HashMap<>(); | ||
Fairytale fairytale = fairytaleRepository.findById(fairytaleId) | ||
.orElseThrow(() -> new FairytaleNotFoundException( | ||
ErrorStatus._FAIRYTALE_NOT_FOUND)); | ||
|
||
if (changeFace) { | ||
for (CustomCharacter customCharacter : customCharacterRepository.findByUserIdAndFairytaleId(user.getId(), | ||
fairytale.getId())) { | ||
result.put(customCharacter.getPageNum(), customCharacter.getCustomURL()); | ||
} | ||
} else { | ||
for (OriginalCharacter originalCharacter : originalCharacterRepository.findByFairytaleId( | ||
fairytale.getId())) { | ||
result.put(originalCharacter.getPageNum(), originalCharacter.getOriginalURL()); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
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
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