Skip to content

Commit 58b43dc

Browse files
author
pedro
committed
fix: 修复软删除带来的查询问题
1 parent 5826529 commit 58b43dc

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

app/api/cms/notify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from lin import db
1111
from lin.core import route_meta, Event
12-
from lin.exception import NotFound, Success
12+
from lin.exception import NotFound, Success, Forbidden
1313
from lin.jwt import group_required, admin_required
1414
from lin.redprint import Redprint
1515
from lin.notify import MESSAGE_EVENTS
@@ -51,7 +51,7 @@ def create_events():
5151
form = EventsForm().validate_for_api()
5252
event = Event.query.filter_by(group_id=form.group_id.data, soft=False).first()
5353
if event:
54-
raise NotFound(msg='当前权限组已存在推送项')
54+
raise Forbidden(msg='当前权限组已存在推送项')
5555
with db.auto_commit():
5656
ev = Event()
5757
ev.group_id = form.group_id.data

app/api/v1/book.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
@login_required
2424
@Notify(template='{user.nickname}查询了一本图书', event='queryBook')
2525
def get_book(id):
26-
book = Book.query.filter_by(id=id).first() # 通过Book模型在数据库中查询id=`id`的书籍
26+
book = Book.query.filter_by(soft=True, id=id).first() # 通过Book模型在数据库中查询id=`id`的书籍
2727
if book is None:
2828
raise NotFound(msg='没有找到相关书籍') # 如果书籍不存在,返回一个异常给前端
2929
return jsonify(book) # 如果存在,返回该数据的信息

0 commit comments

Comments
 (0)