#!/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())