diff --git a/README.md b/README.md index fdd9449..545ade4 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ - Покрыть тестами класс User и AuthRegistrationExecutor - ~~Добавить clang-format(через CLion)~~ - Перевести GetByUUID GetByLogin на const ref/string_view в IUserDAO - также не vector, а span(погуглить) -- Привести к единоу виду функции IUserDAO -- Пройтись по коду и максимально наставить const +- Привести к единому виду функции IUserDAO +- ~~Пройтись по коду и максимально наставить const~~ - Указать возможные исключения в интерфейсах DAO - Вынести User в структуру. Hashed Password структура должна изначально состоять в другой структуре - SharedPtr - передавать по константной ссылке. diff --git a/src/DAO/IUserDAO.h b/src/DAO/IUserDAO.h index 991ff8c..f00f998 100644 --- a/src/DAO/IUserDAO.h +++ b/src/DAO/IUserDAO.h @@ -13,15 +13,15 @@ class IUserDAO public: virtual std::string Create(const User& created_user) = 0; - virtual std::optional GetByUUID(std::string uuid) = 0; + virtual std::optional GetByUUID(const std::string& uuid) = 0; - virtual std::optional GetByLogin(std::string login) = 0; + virtual std::optional GetByLogin(const std::string& login) = 0; virtual std::pair> GetAll(size_t limit, size_t offset) = 0; virtual bool Update(const User& u) = 0; - virtual bool Delete(std::string uuid) = 0; + virtual bool Delete(const std::string& uuid) = 0; virtual ~IUserDAO() = default; }; diff --git a/src/DAO/MySQLUserDAO.cpp b/src/DAO/MySQLUserDAO.cpp index e6e84d9..0cb958e 100644 --- a/src/DAO/MySQLUserDAO.cpp +++ b/src/DAO/MySQLUserDAO.cpp @@ -29,7 +29,7 @@ string MySQLUserDAO::Create(const User& created_user) return uuid_str; } -optional MySQLUserDAO::GetByUUID(string uuid) +optional MySQLUserDAO::GetByUUID(const string& uuid) { mysqlx::SqlResult sql_result = session_. sql("SELECT * FROM `up_and_down`.`users` WHERE (uuid = '" + uuid + @@ -38,7 +38,7 @@ optional MySQLUserDAO::GetByUUID(string uuid) return GetSingleUserBySQLResult(std::move(sql_result)); } -optional MySQLUserDAO::GetByLogin(string login) +optional MySQLUserDAO::GetByLogin(const string& login) { mysqlx::SqlResult sql_result = session_. sql("SELECT * FROM `up_and_down`.`users` WHERE (login = '" + login @@ -105,7 +105,7 @@ bool MySQLUserDAO::Update(const User& u) return !!res.getAffectedItemsCount(); } -bool MySQLUserDAO::Delete(string uuid) +bool MySQLUserDAO::Delete(const string& uuid) { auto schema = session_.getSchema("up_and_down"); auto table = schema.getTable("users"); diff --git a/src/DAO/MySQLUserDAO.h b/src/DAO/MySQLUserDAO.h index b397bd1..03378d6 100644 --- a/src/DAO/MySQLUserDAO.h +++ b/src/DAO/MySQLUserDAO.h @@ -12,15 +12,15 @@ public: std::string Create(const User& created_user) override; - std::optional GetByUUID(std::string uuid) override; + std::optional GetByUUID(const std::string& uuid) override; - std::optional GetByLogin(std::string login) override; + std::optional GetByLogin(const std::string& login) override; std::pair> GetAll(size_t limit, size_t offset) override; bool Update(const User& u) override; - bool Delete(std::string uuid) override; + bool Delete(const std::string& uuid) override; private: std::optional GetSingleUserBySQLResult(mysqlx::SqlResult&& sql_result);