-
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 #108 from oduck-team/feature/102
장르, 성우, 원작자, 제작사, 시리즈 삭제 수정 #102
- Loading branch information
Showing
23 changed files
with
275 additions
and
29 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
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
5 changes: 5 additions & 0 deletions
5
src/main/java/io/oduck/api/domain/genre/repository/GenreRepositoryCustom.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,5 @@ | ||
package io.oduck.api.domain.genre.repository; | ||
|
||
public interface GenreRepositoryCustom { | ||
boolean existsByName(String name); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/oduck/api/domain/genre/repository/GenreRepositoryCustomImpl.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,31 @@ | ||
package io.oduck.api.domain.genre.repository; | ||
|
||
import static io.oduck.api.domain.genre.entity.QGenre.genre; | ||
|
||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class GenreRepositoryCustomImpl implements GenreRepositoryCustom{ | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public boolean existsByName(String name) { | ||
Integer fetchOne = queryFactory | ||
.selectOne() | ||
.from(genre) | ||
.where( | ||
genre.name.eq(name), | ||
notDeleted() | ||
).fetchFirst(); | ||
return fetchOne != null; | ||
} | ||
|
||
private BooleanExpression notDeleted() { | ||
return genre.deletedAt.isNull(); | ||
} | ||
} |
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
10 changes: 5 additions & 5 deletions
10
src/main/java/io/oduck/api/domain/originalAuthor/repository/OriginalAuthorRepository.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,16 +1,16 @@ | ||
package io.oduck.api.domain.originalAuthor.repository; | ||
|
||
import com.querydsl.core.Fetchable; | ||
import io.oduck.api.domain.originalAuthor.entity.OriginalAuthor; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface OriginalAuthorRepository extends JpaRepository<OriginalAuthor, Long> { | ||
public interface OriginalAuthorRepository extends JpaRepository<OriginalAuthor, Long>, OriginalAuthorRepositoryCustom { | ||
|
||
boolean existsByName(String name); | ||
|
||
Optional<OriginalAuthor> findByIdAndDeletedAtIsNull(Long originalAuthorId); | ||
@Query("select distinct oa from OriginalAuthor oa left join fetch oa.animeOriginalAuthors where oa.id = :id and oa.deletedAt = null") | ||
Optional<OriginalAuthor> findByIdAndDeletedAtIsNull(@Param("id") Long originalAuthorId); | ||
|
||
List<OriginalAuthor> findAllByDeletedAtIsNull(); | ||
} |
5 changes: 5 additions & 0 deletions
5
...in/java/io/oduck/api/domain/originalAuthor/repository/OriginalAuthorRepositoryCustom.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,5 @@ | ||
package io.oduck.api.domain.originalAuthor.repository; | ||
|
||
public interface OriginalAuthorRepositoryCustom { | ||
boolean existsByName(String name); | ||
} |
32 changes: 32 additions & 0 deletions
32
...ava/io/oduck/api/domain/originalAuthor/repository/OriginalAuthorRepositoryCustomImpl.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,32 @@ | ||
package io.oduck.api.domain.originalAuthor.repository; | ||
|
||
|
||
import static io.oduck.api.domain.originalAuthor.entity.QOriginalAuthor.originalAuthor; | ||
|
||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class OriginalAuthorRepositoryCustomImpl implements OriginalAuthorRepositoryCustom { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public boolean existsByName(String name) { | ||
Integer fetchOne = queryFactory.selectOne() | ||
.from(originalAuthor) | ||
.where( | ||
originalAuthor.name.eq(name), | ||
notDeleted() | ||
) | ||
.fetchFirst(); | ||
return fetchOne != null; | ||
} | ||
|
||
private BooleanExpression notDeleted() { | ||
return originalAuthor.deletedAt.isNull(); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/main/java/io/oduck/api/domain/series/repository/SeriesRepositoryCustom.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,6 @@ | ||
package io.oduck.api.domain.series.repository; | ||
|
||
public interface SeriesRepositoryCustom { | ||
|
||
boolean existsByTitle(String title); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/oduck/api/domain/series/repository/SeriesRepositoryCustomImpl.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,31 @@ | ||
package io.oduck.api.domain.series.repository; | ||
|
||
import static io.oduck.api.domain.series.entity.QSeries.series; | ||
|
||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class SeriesRepositoryCustomImpl implements SeriesRepositoryCustom{ | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public boolean existsByTitle(String title) { | ||
Integer fetchOne = queryFactory.selectOne() | ||
.from(series) | ||
.where( | ||
series.title.eq(title), | ||
notDeleted() | ||
) | ||
.fetchFirst(); | ||
return fetchOne != null; | ||
} | ||
|
||
private BooleanExpression notDeleted() { | ||
return series.deletedAt.isNull(); | ||
} | ||
} |
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
10 changes: 5 additions & 5 deletions
10
src/main/java/io/oduck/api/domain/studio/repository/StudioRepository.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,16 +1,16 @@ | ||
package io.oduck.api.domain.studio.repository; | ||
|
||
import com.querydsl.core.Fetchable; | ||
import io.oduck.api.domain.studio.entity.Studio; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface StudioRepository extends JpaRepository<Studio, Long> { | ||
public interface StudioRepository extends JpaRepository<Studio, Long>, StudioRepositoryCustom { | ||
|
||
boolean existsByName(String name); | ||
|
||
Optional<Studio> findByIdAndDeletedAtIsNull(Long studioId); | ||
@Query("select distinct s from Studio s left join fetch s.animeStudios where s.id = :id and s.deletedAt = null") | ||
Optional<Studio> findByIdAndDeletedAtIsNull(@Param("id") Long studioId); | ||
|
||
List<Studio> findAllByDeletedAtIsNull(); | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/io/oduck/api/domain/studio/repository/StudioRepositoryCustom.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,6 @@ | ||
package io.oduck.api.domain.studio.repository; | ||
|
||
public interface StudioRepositoryCustom { | ||
|
||
boolean existsByName(String name); | ||
} |
Oops, something went wrong.