You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/07/19 16:34:34
'''
from flask import jsonify, request, Blueprint, g
from Common.auth import token_auth
from Common.Utils import Utils
from db_logic.user import BllUser
user_router = Blueprint('user', __name__)
# class LoginBase(BaseModel):
# user_name: str
# password: str
@user_router.route("/login", methods=["POST"])
# @token_auth.login_required
# @doc_siwa.doc(body=LoginBase)
def user_login():
user_name = request.values.get("user_name")
password = request.values.get('password')
# user_name = body.user_name
# password = body.password
user_obj = BllUser().login(user_name=user_name, password=password)
if user_obj:
return jsonify(Utils.true_return(msg="登陆成功", data={"token":user_obj}))
else:
return jsonify(Utils.false_return(status=201, msg="登陆失败"))
@user_router.route("/get_user_power", methods=["GET"])
@token_auth.login_required
def get_user_power():
print(g.current_user.user_id)
return jsonify(Utils.true_return())