diff --git a/app/__init__.py b/app/__init__.py index a63eaf7..fd25c26 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -66,7 +66,9 @@ def ep_healthcheck(): @app.route("/reset_users_because_postman_is_dumb_like_that") def ep_reset(): - return {} + db.session.query(UserModel).delete() + db.session.commit() + return {}, 200 @app.route("/users", methods = ["GET"]) def ep_users_get(): @@ -75,12 +77,12 @@ def ep_users_get(): @app.route("/user/", methods = ["GET"]) def ep_user_get(user_id): - user = ldb.get_user(user_id) + result = db.session.query(UserModel).filter(UserModel.uuid == user_id).all() - if 'uuid' in user: - return user + if len(result) == 1: + return user_schema.dumps(result[0]), 200 else: - return user, 404 + return {}, 404 @app.route("/user", methods = ["POST"]) def ep_user_post(): @@ -112,12 +114,18 @@ def ep_user_post(): @app.route("/user/", methods = ["DELETE"]) def ep_user_delete(user_id): - r = ldb.del_user(user_id) + try: + result = db.session.query(UserModel).filter(UserModel.uuid == user_id).all() + except Exception as e: + return {}, 403 - if 'uuid' in r: - return r - else: - return r, 403 + if len(result) == 0: + return {}, 404 + + db.session.query(UserModel).filter(UserModel.uuid == user_id).delete() + db.session.commit() + + return user_schema.dumps(result[0]), 200 @app.route("/category", methods = ["GET"]) def ep_category_get():