From 3f009dc1f9b81e74b8fc4cc322d0bdd0cdaf8780 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Mon, 21 Apr 2025 21:47:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=8F=E8=AF=B4=E5=B0=81=E9=9D=A2?= =?UTF-8?q?=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java2nb/novel/core/cache/CacheKey.java | 4 ++ .../novel/controller/AuthorController.java | 8 +++ .../java2nb/novel/service/BookService.java | 5 ++ .../novel/service/impl/BookServiceImpl.java | 6 ++ .../resources/templates/author/index.html | 60 ++++++++++--------- 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/novel-common/src/main/java/com/java2nb/novel/core/cache/CacheKey.java b/novel-common/src/main/java/com/java2nb/novel/core/cache/CacheKey.java index 750c53f..7f938e4 100644 --- a/novel-common/src/main/java/com/java2nb/novel/core/cache/CacheKey.java +++ b/novel-common/src/main/java/com/java2nb/novel/core/cache/CacheKey.java @@ -69,4 +69,8 @@ public interface CacheKey { * 测试爬虫规则缓存 */ String BOOK_TEST_PARSE = "testParse"; + /** + * AI生成图片 + * */ + String AI_GEN_PIC = "aiGenPic"; } diff --git a/novel-front/src/main/java/com/java2nb/novel/controller/AuthorController.java b/novel-front/src/main/java/com/java2nb/novel/controller/AuthorController.java index 54e24aa..510deee 100644 --- a/novel-front/src/main/java/com/java2nb/novel/controller/AuthorController.java +++ b/novel-front/src/main/java/com/java2nb/novel/controller/AuthorController.java @@ -238,6 +238,14 @@ public class AuthorController extends BaseController { } + /** + * 查询AI生成图片 + */ + @GetMapping("queryAiGenPic") + public RestResult queryAiGenPic(@RequestParam("bookId") Long bookId) { + return RestResult.ok(bookService.queryAiGenPic(bookId)); + } + /** * AI扩写 */ diff --git a/novel-front/src/main/java/com/java2nb/novel/service/BookService.java b/novel-front/src/main/java/com/java2nb/novel/service/BookService.java index 7759811..eff1a61 100644 --- a/novel-front/src/main/java/com/java2nb/novel/service/BookService.java +++ b/novel-front/src/main/java/com/java2nb/novel/service/BookService.java @@ -290,4 +290,9 @@ public interface BookService { * @param authorId */ void updateBookPic(Long bookId, String bookPic, Long authorId); + + /** + * 查询AI生成图片 + */ + String queryAiGenPic(Long bookId); } diff --git a/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java b/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java index ccb878f..9e2b2bb 100644 --- a/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java +++ b/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java @@ -559,6 +559,7 @@ public class BookServiceImpl implements BookService { .where(id, isEqualTo(book.getId())) .build() .render(RenderingStrategies.MYBATIS3)); + cacheService.set(CacheKey.AI_GEN_PIC + book.getId(), picUrl, 60 * 60); }); } } @@ -882,5 +883,10 @@ public class BookServiceImpl implements BookService { .render(RenderingStrategies.MYBATIS3)); } + @Override + public String queryAiGenPic(Long bookId) { + return cacheService.get(CacheKey.AI_GEN_PIC + bookId); + } + } diff --git a/novel-front/src/main/resources/templates/author/index.html b/novel-front/src/main/resources/templates/author/index.html index 1a3c3da..00a6c63 100644 --- a/novel-front/src/main/resources/templates/author/index.html +++ b/novel-front/src/main/resources/templates/author/index.html @@ -51,8 +51,7 @@