Skip to content

Commit b9383cb

Browse files
committed
refactor: 调整book, log视图返回值
1 parent bf9e439 commit b9383cb

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

app/api/cms/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ def get_users_for_log():
7373
.having(text("count(username) > 0"))
7474
.all()
7575
)
76-
return StringList.parse_obj([u.username for u in usernames])
76+
return [u.username for u in usernames]

app/api/v1/book.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_book(id):
3636
"""
3737
book = Book.get(id=id)
3838
if book:
39-
return BookOutSchema.parse_obj(book)
39+
return book
4040
raise BookNotFound
4141

4242

@@ -49,8 +49,7 @@ def get_books():
4949
"""
5050
获取图书列表
5151
"""
52-
books = Book.get(one=False)
53-
return BookSchemaList.parse_obj(books)
52+
return Book.get(one=False)
5453

5554

5655
@book_api.route("/search")
@@ -63,11 +62,9 @@ def search():
6362
"""
6463
关键字搜索图书
6564
"""
66-
books = Book.query.filter(
65+
return Book.query.filter(
6766
Book.title.like("%" + g.q + "%"), Book.delete_time == None
6867
).all()
69-
if books:
70-
return BookSchemaList.parse_obj(books)
7168

7269

7370
@book_api.route("", methods=["POST"])

0 commit comments

Comments
 (0)