feat: 优化界面,增加AI依赖
This commit is contained in:
@@ -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<Item>();
|
||||
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) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user