def my_bookshelf(): data = json.loads(request.get_data("").decode("utf-8")) user_account = data["user_account"] tokens = data["tokens"] if not token.certify_token(user_account, tokens): return jsonify({"status": -1, "message": "not login", "data": ""}) user_id = sql_query_user_id(user_account) result = db_user_activity.sql_my_bookshelf(user_id) if not result[0]: return jsonify({"status": -1, "message": result[1]}) return jsonify({"status": 0, "message": "success", "data": result[1]})
def query_user_info(): data = json.loads(request.get_data("").decode("utf-8")) user_account = data["user_account"] tokens = data["tokens"] if not token.certify_token(user_account, tokens): return jsonify({"status": -1, "message": "not login", "data": ""}) user_id = sql_query_user_id(user_account) result = db_user.sql_query_user_info(user_id) C = Condition() result[1][0]['user_sex'] = C.sex(result[1][0]['user_sex']) if not result: return jsonify({"status": -1, "message": "fail"}) return jsonify({"status": 0, "message": "success", "data": result[1]})
def count_book(): data = json.loads(request.get_data("").decode("utf-8")) if not data["user_account"]: return jsonify({"status": -1, "message": "fail", "data": []}) account = data["user_account"] tokens = data["tokens"] if not token.certify_token(account, tokens): return jsonify({"status": -1, "message": "not login", "data": ""}) user_id = sql_query_user_id(account) result = {} result["bookshelf"], result["borrowing"], result["borrow"], result["img"] = db_user_activity.sql_count_book(user_id) result["img"] = "http://47.96.139.19:6868/library/img1/" + result["img"] return jsonify({"status": 0, "message": "success", "data": result})
def query_return_book_info(): data = json.loads(request.get_data("").decode("utf-8")) user_name = data["user_name"] book_name = data["book_name"] user_id = db_book.sql_query_user_id(user_name) result = db_manage.sql_query_book_info_1(book_name, user_id) if not result[0]: return jsonify({"status": -1, "message": result[1]}) for i in range(len(result[1])): result[1][i][ "book_img_path"] = "http://47.96.139.19:6868/library/img/" + result[ 1][i]["book_img_path"] return jsonify({"status": 0, "message": "success", "data": result[1]})
def get_feedback(): data = json.loads(request.get_data("").decode("utf-8")) if not data["user_name"]: return jsonify({"status": -1, "message": "fail"}) user_name = data["user_name"] user_id = sql_query_user_id(user_name) result = db_user.sql_get_feedback(user_id) if not result[0]: return jsonify({"status": -1, "message": "fail"}) C = Condition() if result[1]: for i in range(len(result[1])): result[1][i]["state"] = C.feed(result[1][i]["state"]) return jsonify({"status": 0, "message": "success", "data": result[1]})
def feedback(): data = json.loads(request.get_data("").decode("utf-8")) user_name = data["user_name"] feedbacks = data["feedbacks"] reader = data["reader"] phone = data["phone"] tokens = data["tokens"] if not token.certify_token(user_name, tokens): return jsonify({"status": -1, "message": "not login", "data": ""}) user_id = sql_query_user_id(user_name) result = db_user.sql_feedbacks(user_id, reader, phone, feedbacks) if not result: return jsonify({"status": -1, "message": "fail"}) return jsonify({"status": 0, "message": "success"})