financial—resource—user—user_resource.py
定义资源类
class IsExistPhone(Resource):
'''
判断手机号是否存在
'''
def post(self): # 如果是post请求,请求的参数往往会封装成json对象
phone = request.form.get('phone')
user = User.query.filter(User.phone == phone).first()
if user:
return {'message': '此手机号已经注册过,请更换手机号码', 'code': 201}
return {'msg': 'success'}
加载资源类
from financial.resource.user.user_resource import *
user_api.add_resource(IsExistPhone,'/isExist',endpoint='isExist')
验证接口