diff --git a/backend/src/module/api/rss.py b/backend/src/module/api/rss.py index b1317203..d2d98331 100644 --- a/backend/src/module/api/rss.py +++ b/backend/src/module/api/rss.py @@ -30,6 +30,15 @@ async def add_rss(rss: RSSItem, current_user=Depends(get_current_user)): return u_response(result) +@router.post(path="/enable/many", response_model=APIResponse) +async def enable_many_rss(rss_ids: list[int], current_user=Depends(get_current_user)): + if not current_user: + raise UNAUTHORIZED + with RSSEngine() as engine: + result = engine.enable_list(rss_ids) + return u_response(result) + + @router.delete(path="/delete/{rss_id}", response_model=APIResponse) async def delete_rss(rss_id: int, current_user=Depends(get_current_user)): if not current_user: @@ -47,6 +56,15 @@ async def delete_rss(rss_id: int, current_user=Depends(get_current_user)): ) +@router.post(path="/delete/many", response_model=APIResponse) +async def delete_many_rss(rss_ids: list[int], current_user=Depends(get_current_user)): + if not current_user: + raise UNAUTHORIZED + with RSSEngine() as engine: + result = engine.delete_list(rss_ids) + return u_response(result) + + @router.patch(path="/disable/{rss_id}", response_model=APIResponse) async def disable_rss(rss_id: int, current_user=Depends(get_current_user)): if not current_user: @@ -69,16 +87,8 @@ async def disable_many_rss(rss_ids: list[int], current_user=Depends(get_current_ if not current_user: raise UNAUTHORIZED with RSSEngine() as engine: - if engine.disable_list(rss_ids): - return JSONResponse( - status_code=200, - content={"msg_en": "Disable RSS successfully.", "msg_zh": "禁用 RSS 成功。"}, - ) - else: - return JSONResponse( - status_code=406, - content={"msg_en": "Disable RSS failed.", "msg_zh": "禁用 RSS 失败。"}, - ) + result = engine.disable_list(rss_ids) + return u_response(result) @router.patch(path="/update/{rss_id}", response_model=APIResponse) diff --git a/backend/src/module/database/rss.py b/backend/src/module/database/rss.py index 5c4dce81..cfc229b2 100644 --- a/backend/src/module/database/rss.py +++ b/backend/src/module/database/rss.py @@ -44,6 +44,17 @@ def update(self, _id: int, data: RSSUpdate): self.session.refresh(db_data) return True + def enable(self, _id: int): + statement = select(RSSItem).where(RSSItem.id == _id) + db_data = self.session.exec(statement).first() + if not db_data: + return False + db_data.enabled = True + self.session.add(db_data) + self.session.commit() + self.session.refresh(db_data) + return True + def disable(self, _id: int): statement = select(RSSItem).where(RSSItem.id == _id) db_data = self.session.exec(statement).first() diff --git a/backend/src/module/rss/engine.py b/backend/src/module/rss/engine.py index 744176a4..b5731230 100644 --- a/backend/src/module/rss/engine.py +++ b/backend/src/module/rss/engine.py @@ -62,6 +62,32 @@ def add_rss(self, rss_link: str, name: str | None = None, aggregate: bool = True def disable_list(self, rss_id_list: list[int]): for rss_id in rss_id_list: self.rss.disable(rss_id) + return ResponseModel( + status=True, + status_code=200, + msg_en="Disable RSS successfully.", + msg_zh="禁用 RSS 成功。", + ) + + def enable_list(self, rss_id_list: list[int]): + for rss_id in rss_id_list: + self.rss.enable(rss_id) + return ResponseModel( + status=True, + status_code=200, + msg_en="Enable RSS successfully.", + msg_zh="启用 RSS 成功。", + ) + + def delete_list(self, rss_id_list: list[int]): + for rss_id in rss_id_list: + self.rss.delete(rss_id) + return ResponseModel( + status=True, + status_code=200, + msg_en="Delete RSS successfully.", + msg_zh="删除 RSS 成功。", + ) def pull_rss(self, rss_item: RSSItem) -> list[Torrent]: torrents = self._get_torrents(rss_item) diff --git a/webui/src/api/rss.ts b/webui/src/api/rss.ts index 282673df..c92b0889 100644 --- a/webui/src/api/rss.ts +++ b/webui/src/api/rss.ts @@ -38,6 +38,11 @@ export const apiRSS = { return data!; }, + async enableMany(rss_list: number[]) { + const { data } = await axios.post(`api/v1/rss/enable/many`, rss_list); + return data!; + }, + async refreshAll() { const { data } = await axios.get('api/v1/rss/refresh/all'); return data!; diff --git a/webui/src/components/ab-bangumi-card.vue b/webui/src/components/ab-bangumi-card.vue index 8ea950cd..6b3c24c3 100644 --- a/webui/src/components/ab-bangumi-card.vue +++ b/webui/src/components/ab-bangumi-card.vue @@ -65,6 +65,7 @@ defineEmits(['click']);
{{ name }}
@@ -90,6 +91,7 @@ defineEmits(['click']);
- + diff --git a/webui/src/components/ab-rss-item.vue b/webui/src/components/ab-rss-item.vue index 7c0ad175..d9100100 100644 --- a/webui/src/components/ab-rss-item.vue +++ b/webui/src/components/ab-rss-item.vue @@ -10,11 +10,13 @@ withDefaults( parser: string; }>(), { - enable: false, + aggregate: false, } ); -const select = ref(false); +defineEmits(['on-select']); + +const checked = ref(false);