From e0e7d21d448c8ec63226451a1c1454ffdfc678ed Mon Sep 17 00:00:00 2001 From: "1152958806@qq.com" <1152958806@qq.com> Date: Sun, 30 Jun 2024 00:57:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D2.17.0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/DoubanServiceImpl.java | 35 +++++++++---------- src/main/resources/plugin.yaml | 2 +- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/java/la/moony/douban/service/impl/DoubanServiceImpl.java b/src/main/java/la/moony/douban/service/impl/DoubanServiceImpl.java index ee98fa5..457a924 100644 --- a/src/main/java/la/moony/douban/service/impl/DoubanServiceImpl.java +++ b/src/main/java/la/moony/douban/service/impl/DoubanServiceImpl.java @@ -131,7 +131,7 @@ public void addDouban(String DOUBAN_ID){ var listOptions = new ListOptions(); var query = and(equal("spec.type", type1),equal("spec.id", id)); listOptions.setFieldSelector(FieldSelector.of(query)); - Flux list = reactiveClient.listAll(DoubanMovie.class, listOptions, null); + Flux list = reactiveClient.listAll(DoubanMovie.class, listOptions, Sort.by("faves.createTime")); Mono booleanMono = list.hasElements(); Date finalDate = date; String finalScore = score; @@ -140,21 +140,19 @@ public void addDouban(String DOUBAN_ID){ Date finalDate1 = date; booleanMono.flatMap(hasValue -> { if (hasValue) { - list.next() - .flatMap(doubanMovie -> { - if(StringUtils.isNotEmpty(doubanMovie.getFaves().getStatus())){ - if (doubanMovie.getFaves().getStatus().equals(status1)){ - confition.set(false); - return Mono.empty(); - } + return list.next().flatMap(doubanMovie -> { + if (StringUtils.isNotEmpty(doubanMovie.getFaves().getStatus())) { + if (doubanMovie.getFaves().getStatus().equals(status1)) { + confition.set(false); + return Mono.empty(); } - doubanMovie.getFaves().setCreateTime(finalDate.toInstant()); - doubanMovie.getFaves().setRemark(remark); - doubanMovie.getFaves().setScore(finalScore); - doubanMovie.getFaves().setStatus(status1); - reactiveClient.update(doubanMovie).subscribe(); - return Mono.empty(); - }).subscribe(); + } + doubanMovie.getFaves().setCreateTime(finalDate.toInstant()); + doubanMovie.getFaves().setRemark(remark); + doubanMovie.getFaves().setScore(finalScore); + doubanMovie.getFaves().setStatus(status1); + return reactiveClient.update(doubanMovie); + }); } else { DoubanMovie doubanMovie = new DoubanMovie(); doubanMovie.setMetadata(new Metadata()); @@ -176,9 +174,8 @@ public void addDouban(String DOUBAN_ID){ doubanMovie.getFaves().setRemark(remark); doubanMovie.getFaves().setScore(score); doubanMovie.getFaves().setStatus(status1); - reactiveClient.create(doubanMovie).subscribe(); + return reactiveClient.create(doubanMovie); } - return Mono.empty(); }).subscribe(); } i.set(i.get()+1); @@ -290,7 +287,7 @@ public Mono tmdbDetail(String type,String id,String apiKey){ var listOptions = new ListOptions(); var query = and(equal("spec.type", type),equal("spec.id", id),equal("spec.dataType", "tmdb")); listOptions.setFieldSelector(FieldSelector.of(query)); - Flux list = reactiveClient.listAll(DoubanMovie.class, listOptions, null); + Flux list = reactiveClient.listAll(DoubanMovie.class, listOptions, Sort.by("faves.createTime")); Mono booleanMono = list.hasElements(); return booleanMono.flatMap(hasValue ->{ if (hasValue){ @@ -347,7 +344,7 @@ public Mono doubanDetail(String type,String id){ var listOptions = new ListOptions(); var query = and(equal("spec.type", type),equal("spec.id", id)); listOptions.setFieldSelector(FieldSelector.of(query)); - Flux list = reactiveClient.listAll(DoubanMovie.class, listOptions, null); + Flux list = reactiveClient.listAll(DoubanMovie.class, listOptions, Sort.by("faves.createTime")); Mono booleanMono = list.hasElements(); return this.settingFetcher.get("base").flatMap(base ->booleanMono .flatMap(hasValue ->{ diff --git a/src/main/resources/plugin.yaml b/src/main/resources/plugin.yaml index 779b9e8..7206638 100644 --- a/src/main/resources/plugin.yaml +++ b/src/main/resources/plugin.yaml @@ -4,7 +4,7 @@ metadata: name: plugin-douban spec: enabled: true - requires: ">=2.14.0" + requires: ">=2.15.0" author: name: 困困鱼 website: https://github.com/chengzhongxue