Ejemplo n.º 1
0
def tool_tip_category_and_author():
    """
    根据书名获取详细信息
    :return:
    """
    response_body = {"status": False, "data": {"detail": None}}
    request_body = json.loads(request.data)
    # request_body = request.get_json()
    try:
        token = request.headers['Authorization']
        token = base64.b64decode(bytes(token.encode('utf8')))
        print("save-token: ", token)
        de_token = rsa_utils.decrypt_by_PKS1_OAEP(token)
        print("save-detoken ", de_token)
        if b'admin' != de_token:
            response_body['status'] = False
            response_body['data']['message'] = '非法请求'
            return jsonify(response_body)
        origin_name_book = request_body.get('origin_name_book', None)
        dimension_note_reading = db.session.query(DimensionNoteReading).filter(
            DimensionNoteReading.origin_name_book == origin_name_book).all()

        # for item in dimension_note_reading:
        #     print(item.category)
        # print(dimension_note_reading[0].origin_name_book)
        response_body['status'] = True
        response_body['data']['detail'] = {
            'origin_name_book': dimension_note_reading[0].origin_name_book,
            'origin_author_book': dimension_note_reading[0].origin_author_book,
            'category': dimension_note_reading[0].category
        }
    except Exception as e:
        print(e)
    return jsonify(response_body)
Ejemplo n.º 2
0
def tool_tip_input():
    """
    获取数目类别
    :return:
    """
    response_body = {"status": False, "data": {"message": None}}
    request_body = json.loads(request.data)
    # request_body = request.get_json()
    try:
        token = request.headers['Authorization']
        token = base64.b64decode(bytes(token.encode('utf8')))
        print("save-token: ", token)
        de_token = rsa_utils.decrypt_by_PKS1_OAEP(token)
        print("save-detoken ", de_token)
        if b'admin' != de_token:
            response_body['status'] = False
            response_body['data']['message'] = '非法请求'
            return jsonify(response_body)

        exist_list_origin_author_book = db.session.query(
            DimensionNoteReading.origin_name_book).distinct().all()
        print(exist_list_origin_author_book)
        response_body['status'] = True
        response_body['data']['data'] = exist_list_origin_author_book
        response_body['data']['message'] = "Ok!"

    except Exception as e:
        print(e)
    return jsonify(response_body)
Ejemplo n.º 3
0
def note_reading_save():
    """

    :return:
    """
    response_body = {"status": False, "data": {'message': ''}}
    request_body = json.loads(request.data)
    # request_body = request.get_json()
    try:
        token = request.headers['Authorization']
        token = base64.b64decode(bytes(token.encode('utf8')))
        print('save token->', token)
        de_token = rsa_utils.decrypt_by_PKS1_OAEP(token)
        print('save decrypt->', de_token)
        print(b'admin' == de_token)
        if b'admin' != de_token:
            response_body['status'] = False
            response_body['data']['message'] = '非法请求'
            return jsonify(response_body)

        origin_name_book = request_body.get('origin_name_book', '###')
        category = request_body.get('category', '###')
        origin_author_book = request_body.get('origin_author_book', '###')
        origin_page_book = request_body.get('origin_page_book', '###')
        note = request_body.get('note', '###')
        dimension_note_reading = DimensionNoteReading(
            origin_name_book=origin_name_book,
            category=category,
            origin_page_book=origin_page_book,
            origin_author_book=origin_author_book,
            note=note,
            modified=datetime.now(),
            create=datetime.now())
        db.session.add(dimension_note_reading)
        db.session.commit()
        response_body['status'] = True
        response_body['data']['message'] = f"ok!--{datetime.now()}"
    except Exception as e:
        print(e)
        db.session.rollback()
    return jsonify(response_body)
Ejemplo n.º 4
0
def login():
    """
    登录
    :return:
    """
    response_body = {
        "status": False,
        "data": {
            "message": "温馨提示:请重新核对账号与密码 ^_^"
        }
    }

    request_body = json.loads(request.data)
    print(request_body)
    # password=rsa_utils.decrypt(request_data.get("en_password"))
    # print("明文密码",password)

    account = request_body.get("account")  # 请求中携带的用户名
    en_password = request_body.get("en_password")  # 请求中携带的加过密的密码
    password = rsa_utils.decrypt_by_PKCS1_v1_5(en_password)  # 解密之后的 bytes 类型密码
    user_info = db.session.query(UserInfo).filter(
        UserInfo.account == account).one_or_none()  # 查询数据中是否有该用户

    if user_info:  # 不存在该用户
        db_password = rsa_utils.decrypt_by_PKS1_OAEP(
            user_info.password)  # 数据中用户密码解密后的明文
        if password == db_password:  # 密码是否正确
            response_body["status"] = True
            response_body["data"]["message"] = "登陆成功!"
            token = rsa_utils.encrypt_by_PKCS1_OAEP(
                bytes(account.encode('utf8')))
            token = str(base64.b64encode(token), 'utf8')
            response_body["data"]["token"] = token
        else:
            response_body["status"] = False
    else:
        response_body["status"] = False
    return jsonify(response_body)
Ejemplo n.º 5
0
def token():
    """

    :return:
    """
    response_body = {"status": False, "data": None}
    request_body = json.loads(request.data)
    # request_body = request.get_json()
    try:
        my_request = request
        token = request.headers["Authorization"]
        token = base64.b64decode(bytes(token.encode("utf8")))
        print("token->", token)

        de_token = rsa_utils.decrypt_by_PKS1_OAEP(token)
        print("decrypt->", de_token)
        print(b'admin' == de_token)

        response_body['status'] = True
        response_body['data'] = None
    except Exception as e:
        print(e)
    return jsonify(response_body)