From b6320805fd1bb9cfd3cb0d1735b4e1b78b36ed19 Mon Sep 17 00:00:00 2001 From: CharlesDDDD <10185101155@stu.ecnu.edu.cn> Date: Mon, 11 Jan 2021 19:50:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP/view/collection.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/APP/view/collection.py b/APP/view/collection.py index 205e016..3eb9735 100644 --- a/APP/view/collection.py +++ b/APP/view/collection.py @@ -43,6 +43,20 @@ def get_collection(): collections.append({'id': '2', 'name': 'mingg','like':2}) collections.append({'id': '3', 'name': 'wnqian','like':3}) """ + try: + row = db_session.query(Collection).filter(Collection.name.like('%'+name+'%'), Collection.phonenum == phonenum).all() + for item in row: + collection_tmp = {} + collection_tmp['id'] = item.id + collection_tmp['name'] = item.name + collection_tmp['like'] = item.like + collection_tmp['tag'] = item.tag + collections.append(collection_tmp) + + except BaseException as e: + print(str(e)) + ret = {'msg': 'failed!'} + return json_util.dumps(ret) ret = {'collections': collections, 'msg': 'succuss'} return json_util.dumps(ret) @@ -56,6 +70,20 @@ def recommand_collection(): collections.append({'id': '2', 'name': 'mingg','like':2}) collections.append({'id': '3', 'name': 'wnqian','like':3}) """ + try: + row = db_session.query(Collection).filter(Collection.name.like('%'+name+'%'), Collection.phonenum == phonenum).all() + for item in row: + collection_tmp = {} + collection_tmp['id'] = item.id + collection_tmp['name'] = item.name + collection_tmp['like'] = item.like + collection_tmp['tag'] = item.tag + collections.append(collection_tmp) + + except BaseException as e: + print(str(e)) + ret = {'msg': 'failed!'} + return json_util.dumps(ret) ret = {'collections': collections, 'msg': 'succuss'} return json_util.dumps(ret)