From ce603c6598e70ac2f874a40f9ff59fc0d6431bed Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Fri, 28 Nov 2025 15:02:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0AI=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/book/Book.tsx | 3 +- client/src/pages/book/Bookshelf.tsx | 6 ++- client/src/pages/book/Chapter.tsx | 1 + pom.xml | 12 +++++ .../bookstore/BookStoreApplication.java | 49 ------------------- src/main/resources/application.yml | 7 +++ 6 files changed, 26 insertions(+), 52 deletions(-) diff --git a/client/src/pages/book/Book.tsx b/client/src/pages/book/Book.tsx index 55d88a3..14260eb 100644 --- a/client/src/pages/book/Book.tsx +++ b/client/src/pages/book/Book.tsx @@ -203,7 +203,6 @@ function Book() { { name: 'description', label: '描述', - width: 250, }, { label: '创建时间', @@ -223,6 +222,7 @@ function Book() { type: 'action', label: '详情', level: 'link', + size: 'sm', onEvent: { click: { actions: [ @@ -250,6 +250,7 @@ function Book() { type: 'action', label: '删除', level: 'link', + size: 'sm', actionType: 'ajax', api: `get:${commonInfo.baseUrl}/chapter/remove/\${id}`, confirmText: '确认删除章节${name}?', diff --git a/client/src/pages/book/Bookshelf.tsx b/client/src/pages/book/Bookshelf.tsx index 1cfc2a2..aadbfdf 100644 --- a/client/src/pages/book/Bookshelf.tsx +++ b/client/src/pages/book/Bookshelf.tsx @@ -107,7 +107,7 @@ function Bookshelf() { { name: 'description', label: '描述', - width: 250, + width: 500, }, { name: 'source', @@ -130,13 +130,14 @@ function Bookshelf() { { type: 'operation', label: '操作', - width: 150, + width: 180, fixed: 'right', buttons: [ { type: 'action', label: '详情', level: 'link', + size: 'sm', onEvent: { click: { actions: [ @@ -172,6 +173,7 @@ function Bookshelf() { type: 'action', label: '删除', level: 'link', + size: 'sm', actionType: 'ajax', api: `get:${commonInfo.baseUrl}/book/remove/\${id}`, confirmText: '确认删除书籍${name}?', diff --git a/client/src/pages/book/Chapter.tsx b/client/src/pages/book/Chapter.tsx index e5c3026..5790399 100644 --- a/client/src/pages/book/Chapter.tsx +++ b/client/src/pages/book/Chapter.tsx @@ -159,6 +159,7 @@ function Chapter() { type: 'action', label: '删除', level: 'link', + size: 'sm', actionType: 'ajax', api: `get:${commonInfo.baseUrl}/line/remove/\${id}`, confirmText: '确认删除行?', diff --git a/pom.xml b/pom.xml index b6352f0..3f6ffea 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ 3.5.0 2025.0.0 + 1.1.0 6.6.15.Final 7.0 @@ -38,6 +39,10 @@ org.springframework.boot spring-boot-starter-data-jpa + + org.springframework.ai + spring-ai-starter-model-openai + org.projectlombok @@ -94,6 +99,13 @@ pom import + + org.springframework.ai + spring-ai-bom + ${spring-ai.version} + pom + import + org.seleniumhq.selenium selenium-dependencies-bom diff --git a/src/main/java/com/lanyuanxiaoyao/bookstore/BookStoreApplication.java b/src/main/java/com/lanyuanxiaoyao/bookstore/BookStoreApplication.java index 048d1ae..9383c59 100644 --- a/src/main/java/com/lanyuanxiaoyao/bookstore/BookStoreApplication.java +++ b/src/main/java/com/lanyuanxiaoyao/bookstore/BookStoreApplication.java @@ -1,22 +1,9 @@ package com.lanyuanxiaoyao.bookstore; -import cn.hutool.core.io.FileUtil; import com.blinkfox.fenix.EnableFenix; -import com.lanyuanxiaoyao.bookstore.entity.Chapter; -import com.lanyuanxiaoyao.bookstore.service.BookService; -import com.lanyuanxiaoyao.bookstore.service.ChapterService; -import com.lanyuanxiaoyao.bookstore.service.LineService; -import jakarta.annotation.Resource; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Comparator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.event.EventListener; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; /** @@ -30,43 +17,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @EnableFenix @EnableConfigurationProperties public class BookStoreApplication { - @Resource - private BookService bookService; - @Resource - private ChapterService chapterService; - @Resource - private LineService lineService; - public static void main(String[] args) { SpringApplication.run(BookStoreApplication.class, args); } - - @EventListener(ApplicationReadyEvent.class) - public void importIntoDatabase() throws IOException { - var items = new ArrayList(); - Files.list(Path.of("out")) - .sorted(Comparator.comparing(path -> FileUtil.lastModifiedTime(path.toFile()))) - .forEach(path -> { - try { - items.add(new Item( - path.getFileName().toString(), - Files.readString(path) - )); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - for (var item : items) { - var chapter = new Chapter(); - chapter.setSequence(chapterService.latestSequence(3608359126886400L) + 1); - chapter.setName(null); - chapter.setDescription(null); - chapter.setBook(bookService.detailOrThrow(3608359126886400L)); - var chapterId = chapterService.save(chapter); - lineService.load(chapterId, item.content()); - } - } - - private record Item(String title, String content) { - } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index b9f3a71..e5e72a6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -19,6 +19,13 @@ spring: ddl-auto: update main: banner-mode: off + ai: + openai: + base-url: https://openrouter.ai/api/v1 + api-key: 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 + chat: + options: + model: "x-ai/grok-4.1-fast:free" fenix: print-banner: false liteflow: