修复内容库分页:返回总数而非当前页数量

- 新增 get_articles_count 函数获取总数
- 列表API返回总数用于分页计算
This commit is contained in:
2026-07-14 00:50:11 +08:00
parent 127654a558
commit 981b3c9c5c
2 changed files with 10 additions and 1 deletions
+8
View File
@@ -198,6 +198,14 @@ class Database:
cursor.execute('DELETE FROM articles WHERE id = ?', (article_id,))
conn.commit()
return cursor.rowcount > 0
def get_articles_count(self):
"""获取文章总数"""
with self.get_connection() as conn:
cursor = conn.cursor()
cursor.execute('SELECT COUNT(*) as count FROM articles')
row = cursor.fetchone()
return row['count'] if row else 0
# ========== 待处理产品操作 ==========
def add_pending_product(self, product_name, category=None, subcategory=None, priority=0, source='manual'):