|
|
@@ -15,10 +15,10 @@ const TEST_USER_ID = '1';
|
|
|
const router = new Router();
|
|
|
|
|
|
/**
|
|
|
- * GET /api/book-generator/albums
|
|
|
+ * GET /api/book-generator/books
|
|
|
* 获取专辑列表
|
|
|
*/
|
|
|
-router.get('/albums', async (ctx: Context) => {
|
|
|
+router.get('/books', async (ctx: Context) => {
|
|
|
try {
|
|
|
const books = await bookStore.getAllByUser();
|
|
|
// 只返回基本信息
|
|
|
@@ -104,10 +104,10 @@ router.get('/list', optionalAuth, async (ctx: Context) => {
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * POST /api/book-generator/albums
|
|
|
+ * POST /api/book-generator/books
|
|
|
* 创建专辑
|
|
|
*/
|
|
|
-router.post('/albums', async (ctx: Context) => {
|
|
|
+router.post('/books', async (ctx: Context) => {
|
|
|
try {
|
|
|
const body = ctx.request.body as {
|
|
|
title: string;
|
|
|
@@ -143,10 +143,10 @@ router.post('/albums', async (ctx: Context) => {
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * GET /api/book-generator/albums/:id
|
|
|
+ * GET /api/book-generator/books/:id
|
|
|
* 获取单个书籍详情(用于编辑页面回填)
|
|
|
*/
|
|
|
-router.get('/albums/:id', optionalAuth, async (ctx: Context) => {
|
|
|
+router.get('/books/:id', optionalAuth, async (ctx: Context) => {
|
|
|
try {
|
|
|
const bookId = parseInt(ctx.params.id as string);
|
|
|
const book = await prisma.book.findUnique({
|
|
|
@@ -189,10 +189,10 @@ router.get('/albums/:id', optionalAuth, async (ctx: Context) => {
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * PUT /api/book-generator/albums/:id
|
|
|
+ * PUT /api/book-generator/books/:id
|
|
|
* 更新书籍(书名、描述等)
|
|
|
*/
|
|
|
-router.put('/albums/:id', optionalAuth, async (ctx: Context) => {
|
|
|
+router.put('/books/:id', optionalAuth, async (ctx: Context) => {
|
|
|
try {
|
|
|
const bookId = parseInt(ctx.params.id as string);
|
|
|
const body = ctx.request.body as {
|
|
|
@@ -233,12 +233,12 @@ router.put('/albums/:id', optionalAuth, async (ctx: Context) => {
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * GET /api/book-generator/albums/:id/chapters
|
|
|
+ * GET /api/book-generator/books/:id/chapters
|
|
|
* 获取专辑章节列表
|
|
|
* 返回章(level=1)的列表,每个章包含其下所有小节的合并音频
|
|
|
* 过滤规则:公开的音频 + 当前用户自己的音频
|
|
|
*/
|
|
|
-router.get('/albums/:id/chapters', optionalAuth, async (ctx: Context) => {
|
|
|
+router.get('/books/:id/chapters', optionalAuth, async (ctx: Context) => {
|
|
|
try {
|
|
|
const bookId = ctx.params.id as string;
|
|
|
const userId = ctx.state.user?.userId || TEST_USER_ID;
|
|
|
@@ -391,10 +391,10 @@ router.get('/albums/:id/chapters', optionalAuth, async (ctx: Context) => {
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * POST /api/book-generator/albums/:id/chapters/:chapterId/merge-audio
|
|
|
+ * POST /api/book-generator/books/:id/chapters/:chapterId/merge-audio
|
|
|
* 合并章下所有小节音频为单个文件
|
|
|
*/
|
|
|
-router.post('/albums/:id/chapters/:chapterId/merge-audio', optionalAuth, async (ctx: Context) => {
|
|
|
+router.post('/books/:id/chapters/:chapterId/merge-audio', optionalAuth, async (ctx: Context) => {
|
|
|
try {
|
|
|
const bookId = ctx.params.id as string;
|
|
|
const chapterId = parseInt(ctx.params.chapterId as string);
|
|
|
@@ -478,10 +478,10 @@ router.post('/albums/:id/chapters/:chapterId/merge-audio', optionalAuth, async (
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * GET /api/book-generator/albums/chapters/:id
|
|
|
+ * GET /api/book-generator/books/chapters/:id
|
|
|
* 获取单个章节详情
|
|
|
*/
|
|
|
-router.get('/albums/chapters/:id', optionalAuth, async (ctx: Context) => {
|
|
|
+router.get('/books/chapters/:id', optionalAuth, async (ctx: Context) => {
|
|
|
try {
|
|
|
const chapterId = parseInt(ctx.params.id as string);
|
|
|
|