def put(self): id = request.form.get('id') user = queryById(User, id) user.name = request.form.get('name') user.phone = request.form.get('phone') add(user) return {"state": 'ok', "msg": user.name + '更新成功'}
def delete(self): id = request.args.get('id') user = queryById(User, id) delete(user) return {'state': 'ok', 'msg': '删除{}成功!'.format(user.name)}
def put(self): id = request.form.get('id') user = queryById(User, id) user.name = request.form.get('name') user.phone = request.form.get('phone') add(user) return {'state': 'ok', 'msg': user.name + '更新成功!'}
def patch(self): id = request.form['id'] name = request.form['name'] phone = request.form['phone'] # print(id,name,phone) qs = queryById(User, id) if qs: qs.name = name qs.phone = phone add(qs) return {'state': 'ok', 'msg': '{}修改成功'.format(qs.name)} return {'state': 'fail', 'msg': '{}修改失败'}