增加周榜,月榜,日榜搜索和批量下载
This commit is contained in:
@@ -162,6 +162,65 @@ router.post('/artist/:id', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 下载排行榜作品
|
||||
* POST /api/download/ranking
|
||||
*/
|
||||
router.post('/ranking', async (req, res) => {
|
||||
try {
|
||||
const {
|
||||
mode = 'day',
|
||||
type = 'art',
|
||||
limit = 50,
|
||||
size = 'original',
|
||||
quality = 'high',
|
||||
format = 'auto'
|
||||
} = req.body;
|
||||
|
||||
// 验证参数
|
||||
if (!['day', 'week', 'month'].includes(mode)) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
error: 'Invalid mode. Must be day, week, or month'
|
||||
});
|
||||
}
|
||||
|
||||
if (!['art', 'manga', 'novel'].includes(type)) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
error: 'Invalid type. Must be art, manga, or novel'
|
||||
});
|
||||
}
|
||||
|
||||
const downloadService = req.backend.getDownloadService();
|
||||
const result = await downloadService.downloadRankingArtworks({
|
||||
mode,
|
||||
type,
|
||||
limit: parseInt(limit),
|
||||
size,
|
||||
quality,
|
||||
format
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
res.json({
|
||||
success: true,
|
||||
data: result.data
|
||||
});
|
||||
} else {
|
||||
res.status(400).json({
|
||||
success: false,
|
||||
error: result.error
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
success: false,
|
||||
error: error.message
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取任务进度
|
||||
* GET /api/download/progress/:taskId
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
const express = require('express');
|
||||
const ArtworkService = require('../services/artwork');
|
||||
const ResponseUtil = require('../utils/response');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
/**
|
||||
* 获取排行榜数据
|
||||
* GET /api/ranking
|
||||
* 参数: mode (day/week/month), type (art/manga/novel), offset, limit
|
||||
*/
|
||||
router.get('/', async (req, res) => {
|
||||
try {
|
||||
const { mode = 'day', type = 'art', offset = 0, limit = 30 } = req.query;
|
||||
|
||||
// 验证参数
|
||||
if (!['day', 'week', 'month'].includes(mode)) {
|
||||
return res.status(400).json(ResponseUtil.error('无效的时间模式'));
|
||||
}
|
||||
|
||||
if (!['art', 'manga', 'novel'].includes(type)) {
|
||||
return res.status(400).json(ResponseUtil.error('无效的作品类型'));
|
||||
}
|
||||
|
||||
// 创建作品服务实例,传入认证信息
|
||||
const artworkService = new ArtworkService(req.backend.auth);
|
||||
|
||||
const result = await artworkService.getRankingArtworks({
|
||||
mode,
|
||||
content: type,
|
||||
offset: parseInt(offset),
|
||||
limit: parseInt(limit)
|
||||
});
|
||||
|
||||
res.json(ResponseUtil.success(result));
|
||||
} catch (error) {
|
||||
console.error('获取排行榜失败:', error);
|
||||
res.status(500).json(ResponseUtil.error(error.message));
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user