From ac250d86916066c0fe22cbf5257462db5ab24a38 Mon Sep 17 00:00:00 2001 From: CharlesDDDD <10185101155@stu.ecnu.edu.cn> Date: Mon, 11 Jan 2021 20:39:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86like=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP/view/collection.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/APP/view/collection.py b/APP/view/collection.py index 62fdf54..9f92032 100644 --- a/APP/view/collection.py +++ b/APP/view/collection.py @@ -114,17 +114,28 @@ def islike(): @bp_collection.route("/like", methods=["POST"]) def get_like(): id = request.form.get('collection_id') + phonenum = request.form.get('phonenum') """ 增加点赞数 更新用户的点赞状态 """ ret = {'msg': 'succuss'} + try: + s = UserLike(phonenum=phonenum, collection_id=id, state=1) + db_session.add(s) + db_session.query(Collection).filter(Collection.id == id).update({Collection.like: Collection.like + 1}) + db_session.commit() + except BaseException as e: + print(str(e)) + ret = {'msg': 'failed!'} + return json_util.dumps(ret) return json_util.dumps(ret) @bp_collection.route("/unlike", methods=["POST"]) def get_unlike(): id = request.form.get('colllection_id') + phonenum = request.form.get('phonenum') """ 减少点赞数 更新用户的点赞状态