diff --git a/CHANGELOG.MD b/CHANGELOG.MD index f19e24f4..9720ce76 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -2,6 +2,13 @@ 更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。 +# 0.17.5 + +## 优化 + +- 优化标签创建逻辑 +- 其它的一些简单优化 + # 0.17.4 ## 新特性 diff --git a/gradle.properties b/gradle.properties index fd31ec85..8f55517b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.17.4 +version=0.17.5 diff --git a/server/src/main/java/run/ikaros/server/core/episode/EpisodeUpdateListener.java b/server/src/main/java/run/ikaros/server/core/episode/EpisodeAttachmentUpdateEventListener.java similarity index 79% rename from server/src/main/java/run/ikaros/server/core/episode/EpisodeUpdateListener.java rename to server/src/main/java/run/ikaros/server/core/episode/EpisodeAttachmentUpdateEventListener.java index bd66ac83..c7ec7c49 100644 --- a/server/src/main/java/run/ikaros/server/core/episode/EpisodeUpdateListener.java +++ b/server/src/main/java/run/ikaros/server/core/episode/EpisodeAttachmentUpdateEventListener.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Component; import org.thymeleaf.context.Context; import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; import run.ikaros.api.infra.properties.IkarosProperties; import run.ikaros.api.infra.utils.StringUtils; import run.ikaros.server.core.attachment.event.EpisodeAttachmentUpdateEvent; @@ -18,7 +19,7 @@ @Slf4j @Component -public class EpisodeUpdateListener { +public class EpisodeAttachmentUpdateEventListener { private final AttachmentRepository attachmentRepository; private final EpisodeRepository episodeRepository; private final SubjectRepository subjectRepository; @@ -30,10 +31,11 @@ public class EpisodeUpdateListener { /** * Construct. */ - public EpisodeUpdateListener(AttachmentRepository attachmentRepository, - EpisodeRepository episodeRepository, - SubjectRepository subjectRepository, - NotifyService notifyService, IkarosProperties ikarosProperties) { + public EpisodeAttachmentUpdateEventListener(AttachmentRepository attachmentRepository, + EpisodeRepository episodeRepository, + SubjectRepository subjectRepository, + NotifyService notifyService, + IkarosProperties ikarosProperties) { this.attachmentRepository = attachmentRepository; this.episodeRepository = episodeRepository; this.subjectRepository = subjectRepository; @@ -46,12 +48,14 @@ public EpisodeUpdateListener(AttachmentRepository attachmentRepository, */ @EventListener(EpisodeAttachmentUpdateEvent.class) public Mono onEpisodeAttachmentUpdateEvent(EpisodeAttachmentUpdateEvent event) { + log.debug("receive episode attachment update event: {}", event); if (!event.getNotify()) { return Mono.empty(); } final Long attachmentId = event.getAttachmentId(); final Long episodeId = event.getEpisodeId(); return Mono.just(new Context()) + .subscribeOn(Schedulers.boundedElastic()) .flatMap(context -> attachmentRepository.findById(attachmentId) .map(entity -> { context.setVariable("attachment", entity); @@ -109,17 +113,17 @@ public Mono onEpisodeAttachmentUpdateEvent(EpisodeAttachmentUpdateEvent ev return Mono.empty(); } - StringBuilder sb = new StringBuilder("番剧《"); - sb.append(StringUtils.isBlank(subjectEntity.getNameCn()) - ? subjectEntity.getName() : subjectEntity.getNameCn()) - .append("》第") - .append(episodeEntity.getSequence()) - .append("集 [") - .append(StringUtils.isBlank(episodeEntity.getNameCn()) - ? episodeEntity.getName() : episodeEntity.getNameCn()) - .append("] 更新了"); + String sb = "番剧《" + + (StringUtils.isBlank(subjectEntity.getNameCn()) + ? subjectEntity.getName() : subjectEntity.getNameCn()) + + "》第" + + episodeEntity.getSequence() + + "集 [" + + (StringUtils.isBlank(episodeEntity.getNameCn()) + ? episodeEntity.getName() : episodeEntity.getNameCn()) + + "] 更新了"; - return notifyService.send(sb.toString(), "mail/anime_update", context); + return notifyService.send(sb, "mail/anime_update", context); }); } } diff --git a/server/src/main/java/run/ikaros/server/core/tag/DefaultTagService.java b/server/src/main/java/run/ikaros/server/core/tag/DefaultTagService.java index 32f0181c..da3be7a9 100644 --- a/server/src/main/java/run/ikaros/server/core/tag/DefaultTagService.java +++ b/server/src/main/java/run/ikaros/server/core/tag/DefaultTagService.java @@ -94,8 +94,13 @@ public Mono create(Tag tag) { Assert.notNull(tag.getType(), "'type' must not null."); Assert.isTrue(tag.getMasterId() >= 0, "'masterId' must >=0."); Assert.hasText(tag.getName(), "'name' must has text."); - return Mono.just(tag) - .flatMap(t -> copyProperties(t, new TagEntity())) + if (Objects.isNull(tag.getUserId())) { + tag.setUserId(-1L); + } + return tagRepository.existsByTypeAndMasterIdAndName( + tag.getType(), tag.getMasterId(), tag.getName()) + .filter(exists -> !exists) + .flatMap(exists -> copyProperties(tag, new TagEntity())) .flatMap(tagRepository::save) .flatMap(tagEntity -> copyProperties(tagEntity, tag)); } diff --git a/server/src/main/java/run/ikaros/server/store/repository/TagRepository.java b/server/src/main/java/run/ikaros/server/store/repository/TagRepository.java index ac695afe..ca3a54a1 100644 --- a/server/src/main/java/run/ikaros/server/store/repository/TagRepository.java +++ b/server/src/main/java/run/ikaros/server/store/repository/TagRepository.java @@ -1,9 +1,12 @@ package run.ikaros.server.store.repository; import org.springframework.data.r2dbc.repository.R2dbcRepository; +import reactor.core.publisher.Mono; +import run.ikaros.api.store.enums.TagType; import run.ikaros.server.store.entity.TagEntity; public interface TagRepository extends R2dbcRepository { + Mono existsByTypeAndMasterIdAndName(TagType type, Long masterId, String name); } diff --git a/server/src/main/resources/templates/temp/app-link-to.html b/server/src/main/resources/templates/temp/app-link-to.html index 6b2131c6..1b59ab46 100644 --- a/server/src/main/resources/templates/temp/app-link-to.html +++ b/server/src/main/resources/templates/temp/app-link-to.html @@ -6,16 +6,12 @@
-
+

番剧: 《

- 前往app观看: -

点击 跳转到app条目页面

- -

番剧简介:

@@ -24,6 +20,9 @@

封面:

URL无法访问
+ + 前往app观看: +

点击 跳转到app条目页面