mirror of
https://github.com/Kakune55/ComiPy.git
synced 2025-09-15 11:49:47 +08:00
feat:添加评论删除功能
This commit is contained in:
@@ -2,6 +2,14 @@ import time
|
||||
import db.util as util
|
||||
|
||||
|
||||
# 查找评论
|
||||
def getById(id: str):
|
||||
"通过id查找所有评论"
|
||||
conn = util.getConn()
|
||||
c = conn.cursor()
|
||||
cursor = c.execute("SELECT * FROM Comments WHERE id = ?", (id,))
|
||||
return cursor.fetchone()
|
||||
|
||||
# 查找评论
|
||||
def listByBookid(id: str):
|
||||
"通过bookid查找所有评论"
|
||||
@@ -74,3 +82,16 @@ def new(bookid: str, from_uid: int, score: str, content=""):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return
|
||||
|
||||
# 查找评论
|
||||
def remove(id:int)->bool:
|
||||
"通过id删除评论"
|
||||
conn = util.getConn()
|
||||
c = conn.cursor()
|
||||
c.execute("DELETE FROM Comments WHERE id = ?", (id,))
|
||||
conn.commit()
|
||||
changes = conn.total_changes
|
||||
conn.close()
|
||||
if changes == 0:
|
||||
return False
|
||||
return True
|
||||
|
Reference in New Issue
Block a user