Browse Source

增加了swap集锦功能

master
邓淳远 4 years ago
parent
commit
a0c2e25ebd
1 changed files with 15 additions and 1 deletions
  1. +15
    -1
      APP/view/collection.py

+ 15
- 1
APP/view/collection.py View File

@ -15,7 +15,7 @@ def add_collection():
try:
count = Collection.query.count()
print(count)
c = Collection(id=count + 1, name=name, tag=tag, phonenum=phonenum)
c = Collection(id=count, name=name, tag=tag, phonenum=phonenum)
db_session.add(c)
db_session.commit()
except BaseException as e:
@ -170,6 +170,20 @@ def swap():
id的collection和顺序是order的collection交换
"""
try:
item1 = db_session.query(Collection).filter(Collection.id == id).first()
item2 = db_session.query(Collection).filter(Collection.order == order).first()
order1 = item1.order
# order2 = item2.order
id2 = item2.id
db_session.query(Collection).filter(Collection.id == id).update({Collection.order: order})
db_session.query(Collection).filter(Collection.id == id2).update({Collection.order: order1})
db_session.commit()
except BaseException as e:
print(str(e))
ret = {'msg': 'failed!'}
return json_util.dumps(ret)
ret = {'msg': 'succuss'}
return json_util.dumps(ret)

Loading…
Cancel
Save