有子节点不可删除
This commit is contained in:
1 parent
b2aa177ed2
commit
7bb0124bbe
1 file changed
+9
-1
+9
-1
@@ -118,12 +118,20 @@ def delete_note():
|
|||||||
|
|
||||||
note_id = data.get('id')
|
note_id = data.get('id')
|
||||||
|
|
||||||
if not note_id:
|
if note_id:
|
||||||
|
|
||||||
return jsonify({"error": "Note ID is required"}), 400
|
return jsonify({"error": "Note ID is required"}), 400
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
|
||||||
|
notes = Note.query.filter(Note.pid == int(note_id))
|
||||||
|
|
||||||
|
# 有子节点的情况不可删除
|
||||||
|
if not notes:
|
||||||
|
|
||||||
|
return jsonify({'error': 'this node has a child'}), 400
|
||||||
|
|
||||||
|
|
||||||
note = Note.query.get(note_id)
|
note = Note.query.get(note_id)
|
||||||
|
|
||||||
if note:
|
if note:
|
||||||
|
|||||||
Reference in new issue
Block a user