feat: add adult content flag to manga model and related services #47
@ -57,7 +57,8 @@ public interface AniListClient {
|
|||||||
List<String> genres,
|
List<String> genres,
|
||||||
FuzzyDate startDate,
|
FuzzyDate startDate,
|
||||||
FuzzyDate endDate,
|
FuzzyDate endDate,
|
||||||
StaffConnection staff) {
|
StaffConnection staff,
|
||||||
|
Boolean isAdult) {
|
||||||
|
|
||||||
public record Title(
|
public record Title(
|
||||||
String romaji, String english, @JsonProperty("native") String nativeTitle) {}
|
String romaji, String english, @JsonProperty("native") String nativeTitle) {}
|
||||||
|
|||||||
@ -47,7 +47,8 @@ public interface JikanClient {
|
|||||||
Integer chapters,
|
Integer chapters,
|
||||||
PublishData published,
|
PublishData published,
|
||||||
List<AuthorData> authors,
|
List<AuthorData> authors,
|
||||||
List<GenreData> genres) {
|
List<GenreData> genres,
|
||||||
|
List<ExplicitGenreData> explicit_genres) {
|
||||||
public record ImageData(ImageUrls jpg) {
|
public record ImageData(ImageUrls jpg) {
|
||||||
public record ImageUrls(String large_image_url) {}
|
public record ImageUrls(String large_image_url) {}
|
||||||
}
|
}
|
||||||
@ -57,6 +58,8 @@ public interface JikanClient {
|
|||||||
public record AuthorData(Long mal_id, String name) {}
|
public record AuthorData(Long mal_id, String name) {}
|
||||||
|
|
||||||
public record GenreData(Long mal_id, String name) {}
|
public record GenreData(Long mal_id, String name) {}
|
||||||
|
|
||||||
|
public record ExplicitGenreData(Long mal_id, String name) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,8 @@ public record MangaDTO(
|
|||||||
@NotNull List<MangaProviderDTO> providers,
|
@NotNull List<MangaProviderDTO> providers,
|
||||||
@NotNull Integer chapterCount,
|
@NotNull Integer chapterCount,
|
||||||
@NotNull Boolean favorite,
|
@NotNull Boolean favorite,
|
||||||
@NotNull Boolean following) {
|
@NotNull Boolean following,
|
||||||
|
@NotNull Boolean adult) {
|
||||||
public static MangaDTO from(Manga manga, Boolean favorite, Boolean following) {
|
public static MangaDTO from(Manga manga, Boolean favorite, Boolean following) {
|
||||||
return new MangaDTO(
|
return new MangaDTO(
|
||||||
manga.getId(),
|
manga.getId(),
|
||||||
@ -48,7 +49,8 @@ public record MangaDTO(
|
|||||||
manga.getMangaContentProviders().stream().map(MangaProviderDTO::from).toList(),
|
manga.getMangaContentProviders().stream().map(MangaProviderDTO::from).toList(),
|
||||||
manga.getChapterCount(),
|
manga.getChapterCount(),
|
||||||
favorite,
|
favorite,
|
||||||
following);
|
following,
|
||||||
|
manga.getAdult());
|
||||||
}
|
}
|
||||||
|
|
||||||
public record MangaProviderDTO(
|
public record MangaProviderDTO(
|
||||||
|
|||||||
@ -14,6 +14,7 @@ public record MangaDataDTO(
|
|||||||
OffsetDateTime publishedFrom,
|
OffsetDateTime publishedFrom,
|
||||||
OffsetDateTime publishedTo,
|
OffsetDateTime publishedTo,
|
||||||
Integer chapterCount,
|
Integer chapterCount,
|
||||||
|
Boolean adult,
|
||||||
List<String> authors,
|
List<String> authors,
|
||||||
List<String> genres,
|
List<String> genres,
|
||||||
List<String> alternativeTitles,
|
List<String> alternativeTitles,
|
||||||
|
|||||||
@ -20,7 +20,8 @@ public record MangaListDTO(
|
|||||||
@NotNull List<String> genres,
|
@NotNull List<String> genres,
|
||||||
@NotNull List<String> authors,
|
@NotNull List<String> authors,
|
||||||
@NotNull Double score,
|
@NotNull Double score,
|
||||||
@NotNull Boolean favorite) {
|
@NotNull Boolean favorite,
|
||||||
|
@NotNull Boolean adult) {
|
||||||
public static MangaListDTO from(Manga manga, boolean favorite) {
|
public static MangaListDTO from(Manga manga, boolean favorite) {
|
||||||
return new MangaListDTO(
|
return new MangaListDTO(
|
||||||
manga.getId(),
|
manga.getId(),
|
||||||
@ -35,6 +36,7 @@ public record MangaListDTO(
|
|||||||
.map(mangaAuthor -> mangaAuthor.getAuthor().getName())
|
.map(mangaAuthor -> mangaAuthor.getAuthor().getName())
|
||||||
.toList(),
|
.toList(),
|
||||||
manga.getScore(),
|
manga.getScore(),
|
||||||
favorite);
|
favorite,
|
||||||
|
manga.getAdult());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,5 @@ public record MangaListFilterDTO(
|
|||||||
List<Long> genreIds,
|
List<Long> genreIds,
|
||||||
List<String> statuses,
|
List<String> statuses,
|
||||||
Boolean userFavorites,
|
Boolean userFavorites,
|
||||||
Double score) {}
|
Double score,
|
||||||
|
Boolean adult) {}
|
||||||
|
|||||||
@ -53,6 +53,8 @@ public class Manga {
|
|||||||
|
|
||||||
@Builder.Default private Integer chapterCount = 0;
|
@Builder.Default private Integer chapterCount = 0;
|
||||||
|
|
||||||
|
@Builder.Default private Boolean adult = false;
|
||||||
|
|
||||||
@Builder.Default private Boolean follow = false;
|
@Builder.Default private Boolean follow = false;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@ -71,8 +73,6 @@ public class Manga {
|
|||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<MangaGenre> mangaGenres = new ArrayList<>();
|
private List<MangaGenre> mangaGenres = new ArrayList<>();
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "manga", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "manga", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private List<MangaAlternativeTitle> alternativeTitles = new ArrayList<>();
|
private List<MangaAlternativeTitle> alternativeTitles = new ArrayList<>();
|
||||||
|
|||||||
@ -90,6 +90,7 @@ public class AniListService {
|
|||||||
? media.coverImage().extraLarge()
|
? media.coverImage().extraLarge()
|
||||||
: media.coverImage().large())
|
: media.coverImage().large())
|
||||||
.status(mapStatus(media.status()))
|
.status(mapStatus(media.status()))
|
||||||
|
.adult(nonNull(media.isAdult()) ? media.isAdult() : false)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ public class AniListService {
|
|||||||
chapters
|
chapters
|
||||||
coverImage { large, extraLarge }
|
coverImage { large, extraLarge }
|
||||||
genres
|
genres
|
||||||
|
isAdult
|
||||||
staff {
|
staff {
|
||||||
edges {
|
edges {
|
||||||
role
|
role
|
||||||
|
|||||||
@ -130,6 +130,7 @@ public class MangaUpdateService {
|
|||||||
manga.setPublishedFrom(mangaData.publishedFrom());
|
manga.setPublishedFrom(mangaData.publishedFrom());
|
||||||
manga.setPublishedTo(mangaData.publishedTo());
|
manga.setPublishedTo(mangaData.publishedTo());
|
||||||
manga.setChapterCount(mangaData.chapterCount());
|
manga.setChapterCount(mangaData.chapterCount());
|
||||||
|
manga.setAdult(mangaData.adult());
|
||||||
manga.setState(MangaState.AVAILABLE);
|
manga.setState(MangaState.AVAILABLE);
|
||||||
manga.updateAlternativeTitles(alternativeTitles);
|
manga.updateAlternativeTitles(alternativeTitles);
|
||||||
manga.updateGenres(genres);
|
manga.updateGenres(genres);
|
||||||
|
|||||||
@ -73,6 +73,7 @@ public class MyAnimeListService {
|
|||||||
.alternativeTitles(alternativeTitles)
|
.alternativeTitles(alternativeTitles)
|
||||||
.coverImageUrl(responseData.images().jpg().large_image_url())
|
.coverImageUrl(responseData.images().jpg().large_image_url())
|
||||||
.status(mapStatus(responseData.status()))
|
.status(mapStatus(responseData.status()))
|
||||||
|
.adult(nonNull(responseData.explicit_genres()) && !responseData.explicit_genres().isEmpty())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.magamochi.common.config;
|
package com.magamochi.common.config;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
||||||
import org.springframework.boot.info.GitProperties;
|
import org.springframework.boot.info.GitProperties;
|
||||||
@ -9,16 +8,23 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class GitInfoLogger {
|
public class GitInfoLogger {
|
||||||
private final GitProperties gitProperties;
|
private final GitProperties gitProperties;
|
||||||
|
|
||||||
|
public GitInfoLogger(GitProperties gitProperties) {
|
||||||
|
this.gitProperties = gitProperties;
|
||||||
|
}
|
||||||
|
|
||||||
@EventListener(ApplicationStartedEvent.class)
|
@EventListener(ApplicationStartedEvent.class)
|
||||||
public void logGitInfo() {
|
public void logGitInfo() {
|
||||||
log.info(
|
if (gitProperties != null) {
|
||||||
"Git Info :: commit {} ({}) :: built at {}",
|
log.info(
|
||||||
gitProperties.getShortCommitId(),
|
"Git Info :: commit {} ({}) :: built at {}",
|
||||||
gitProperties.getBranch(),
|
gitProperties.getShortCommitId(),
|
||||||
gitProperties.getCommitTime());
|
gitProperties.getBranch(),
|
||||||
|
gitProperties.getCommitTime());
|
||||||
|
} else {
|
||||||
|
log.info("Git Info :: not available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.magamochi.model.specification;
|
package com.magamochi.model.specification;
|
||||||
|
|
||||||
|
import static java.util.Objects.isNull;
|
||||||
import static java.util.Objects.nonNull;
|
import static java.util.Objects.nonNull;
|
||||||
|
|
||||||
import com.magamochi.catalog.model.dto.MangaListFilterDTO;
|
import com.magamochi.catalog.model.dto.MangaListFilterDTO;
|
||||||
@ -63,6 +64,10 @@ public class MangaSpecification {
|
|||||||
predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("score"), filterDTO.score()));
|
predicates.add(criteriaBuilder.greaterThanOrEqualTo(root.get("score"), filterDTO.score()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isNull(filterDTO.adult()) || !filterDTO.adult()) {
|
||||||
|
predicates.add(criteriaBuilder.equal(root.get("adult"), false));
|
||||||
|
}
|
||||||
|
|
||||||
query.distinct(true);
|
query.distinct(true);
|
||||||
|
|
||||||
return criteriaBuilder.and(predicates.toArray(Predicate[]::new));
|
return criteriaBuilder.and(predicates.toArray(Predicate[]::new));
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE mangas
|
||||||
|
ADD COLUMN adult BOOLEAN NOT NULL DEFAULT FALSE;
|
||||||
Loading…
x
Reference in New Issue
Block a user