-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
каркас сервера posts #5
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
часть с постами пока совсем сырая, почти ничего нет
server_posts/CMakeLists.txt
Outdated
set(CMAKE_CXX_STANDARD 20) | ||
|
||
# set(CMAKE_CXX_FLAGS "-g -Wall -lpthread -lgtest -L/usr/local/lib") | ||
set(CMAKE_CXX_FLAGS "-g -Wall -lpthread -lgtest -L/usr/local/lib -lpqxx -lpq") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
попробуй сделать через cmake большую часть флагов, например find_package(PostgreSQL)
server_posts/CMakeLists.txt
Outdated
|
||
add_library(server_posts STATIC | ||
${SRC_DIR}/main.cpp | ||
${SRC_DIR}/database.cpp include/post.h) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в библиотеке не может быть функции main()
server_posts/include/database.h
Outdated
std::vector<Post> get_all_posts(); | ||
std::vector<Post> get_user_posts(int user_id); | ||
std::vector<Post> get_posts_for_user(int fuser_id); | ||
Post& get_one_post(int post_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
методы, которые не изменяют поведения объекты, должны иметь префикс const
std::vector<Post> get_posts_for_user(int fuser_id) const
// Table Posts_; | ||
pqxx::connection database_; | ||
void do_modifying_request(const std::string& sql_request); | ||
pqxx::result do_select_request(const std::string& sql_request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для работы с БД надо создать wrapper, в которые надо инкапсулировать функции
#include <pqxx/pqxx> | ||
#include <map> | ||
#include <iostream> | ||
#include <boost/format.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
много лишних include в хедере
server_posts/include/server.h
Outdated
} | ||
io::io_context& io_context; | ||
tcp::acceptor acceptor; | ||
std::optional<tcp::socket> socket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему socket optional???
server_posts/include/server.h
Outdated
accept(); | ||
}); | ||
} | ||
io::io_context& io_context; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем тут ссылка?
server_posts/include/session.h
Outdated
void start() { | ||
write("POSTS server is ready to serve"); | ||
write(); | ||
read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
мне не реализация этой функции
server_posts/include/session.h
Outdated
} | ||
} else { | ||
response << "404"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
слишком большая вложенность, вложенность больше 3-х плохо читается
No description provided.