generated from Sithas/conan_template
Переименование GUID на UUID
This commit is contained in:
@@ -53,7 +53,7 @@
|
||||
```
|
||||
{
|
||||
"user": {
|
||||
"guid": "51351bb1-7563-479d-a8e9-201d0ff934c2"
|
||||
"uuid": "51351bb1-7563-479d-a8e9-201d0ff934c2"
|
||||
"login": "ivan_89"
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@
|
||||
* `400 BAD_REQUEST` — сервер не смог десереализовать JSON
|
||||
|
||||
### 10. Используемые сущности ДБ
|
||||
* users(guid(PK), login(unique), hashed_password)
|
||||
* users(uuid(PK), login(unique), hashed_password)
|
||||
|
||||
## UseCase №2
|
||||
### 1.Название: Авторизация пользователя
|
||||
@@ -126,7 +126,7 @@ null
|
||||
```
|
||||
|
||||
### 10. Используемые сущности ДБ
|
||||
* users(guid(PK), login(unique), hashed_password)
|
||||
* users(uuid(PK), login(unique), hashed_password)
|
||||
|
||||
## UseCase №3
|
||||
### 1.Название: Переход на главную страницу
|
||||
@@ -160,7 +160,7 @@ null
|
||||
{
|
||||
diaries: [
|
||||
{
|
||||
"guid": "e89b6a0c-4b0f-4722-a410-1e0c1864bf8a",
|
||||
"uuid": "e89b6a0c-4b0f-4722-a410-1e0c1864bf8a",
|
||||
"time": "10.08.2025",
|
||||
"mania_level": 1,
|
||||
"depression_level": 2,
|
||||
@@ -170,12 +170,12 @@ null
|
||||
"dream_level": 6,
|
||||
"anxiety_level": 7,
|
||||
"treatment_scheme": {
|
||||
"guid": "bf6d1555-39e9-4d73-8928-4763627f4dd5",
|
||||
"uuid": "bf6d1555-39e9-4d73-8928-4763627f4dd5",
|
||||
"treatment_name": "Bipolar I Scheme",
|
||||
"instructions": "Контроль лития в крови раз в 2 месяца. Анализ крови через вену."
|
||||
"medications": [
|
||||
{
|
||||
"guid": "8af2dfa9-3add-413c-9a0e-ff605088f1d5",
|
||||
"uuid": "8af2dfa9-3add-413c-9a0e-ff605088f1d5",
|
||||
"name": "Litii Carbonate",
|
||||
"dose": 1800,
|
||||
"unit": "mg",
|
||||
@@ -198,12 +198,12 @@ null
|
||||
{
|
||||
"treatment_schemes": [
|
||||
{
|
||||
"guid": "248313cb-a75e-4331-8379-d3f2fc36b68d"
|
||||
"uuid": "248313cb-a75e-4331-8379-d3f2fc36b68d"
|
||||
"treatment_name": "Bipolar I Scheme Urgent",
|
||||
"instructions": "Схема для бытрого и жесткого купирования психозов. Аминазин пить каждый день.",
|
||||
"medications": [
|
||||
{
|
||||
"guid": "eda5a5f7-167a-44b9-900d-c5c6acfc249b",
|
||||
"uuid": "eda5a5f7-167a-44b9-900d-c5c6acfc249b",
|
||||
"name": "Aminazin",
|
||||
"dose": 100,
|
||||
"unit": "mg",
|
||||
@@ -220,7 +220,7 @@ null
|
||||
* `500 DATA_LOAD_FAILED` — ошибка при загрузке данных (B1)
|
||||
|
||||
### 10. Используемые сущности ДБ
|
||||
* diaries(guid(PK), time , mania_level , depression_level , mood_level , activity_level , appetite_level , dream_level , anxiety_level, user_treatment_schemes_guid)
|
||||
* diaries(uuid(PK), time , mania_level , depression_level , mood_level , activity_level , appetite_level , dream_level , anxiety_level, user_treatment_schemes_uuid)
|
||||
* mania(level(PK))
|
||||
* depressions(level(PK))
|
||||
* moods(level(PK))
|
||||
@@ -228,6 +228,6 @@ null
|
||||
* appetites(level(PK))
|
||||
* dreams(level(PK))
|
||||
* anxiety(level(PK))
|
||||
* treatment_schemes(user_treatment_schemes_guid(PK), medication_guid(PK))
|
||||
* user_treatment_schemes(guid(PK), user_guid, treatment_name, instructions)
|
||||
* medications(guid(PK), name, dose, unit, is_urgent)
|
||||
* treatment_schemes(user_treatment_schemes_uuid(PK), medication_uuid(PK))
|
||||
* user_treatment_schemes(uuid(PK), user_uuid, treatment_name, instructions)
|
||||
* medications(uuid(PK), name, dose, unit, is_urgent)
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
CREATE SCHEMA `up_and_down` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
CREATE TABLE `up_and_down`.`users` (
|
||||
`guid` CHAR(36) NOT NULL,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`login` VARCHAR(128) UNIQUE NOT NULL,
|
||||
`hashed_password` TEXT NOT NULL,
|
||||
PRIMARY KEY (`guid`),
|
||||
UNIQUE INDEX `guid_UNIQUE` (`guid` ASC)
|
||||
PRIMARY KEY (`uuid`),
|
||||
UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`mania` (
|
||||
@@ -53,17 +53,17 @@ CREATE TABLE `up_and_down`.`anxiety` (
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`user_treatment_schemes` (
|
||||
`guid` CHAR(36) NOT NULL,
|
||||
`user_guid` CHAR(36) NOT NULL,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`user_uuid` CHAR(36) NOT NULL,
|
||||
`treatment_name` TEXT NOT NULL,
|
||||
`instructions` TEXT,
|
||||
PRIMARY KEY (`guid`),
|
||||
FOREIGN KEY (`user_guid`) REFERENCES `users`(`guid`)
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`diaries` (
|
||||
`guid` CHAR(36) NOT NULL,
|
||||
`user_guid` CHAR(36) NOT NULL,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`user_uuid` CHAR(36) NOT NULL,
|
||||
`time` DATETIME NOT NULL,
|
||||
`mania_level` INT1 NOT NULL,
|
||||
`depression_level` INT1 NOT NULL,
|
||||
@@ -72,9 +72,9 @@ CREATE TABLE `up_and_down`.`diaries` (
|
||||
`appetite_level` INT1 NOT NULL,
|
||||
`dream_level` INT1 NOT NULL,
|
||||
`anxiety_level` INT1 NOT NULL,
|
||||
`user_treatment_schemes_guid` CHAR(36),
|
||||
PRIMARY KEY (`guid`),
|
||||
FOREIGN KEY (`user_guid`) REFERENCES `users`(`guid`),
|
||||
`user_treatment_schemes_uuid` CHAR(36),
|
||||
PRIMARY KEY (`uuid`),
|
||||
FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`),
|
||||
FOREIGN KEY (`mania_level`) REFERENCES `mania`(`level`),
|
||||
FOREIGN KEY (`depression_level`) REFERENCES `depressions`(`level`),
|
||||
FOREIGN KEY (`mood_level`) REFERENCES `moods`(`level`),
|
||||
@@ -82,24 +82,24 @@ CREATE TABLE `up_and_down`.`diaries` (
|
||||
FOREIGN KEY (`appetite_level`) REFERENCES `appetites`(`level`),
|
||||
FOREIGN KEY (`dream_level`) REFERENCES `dreams`(`level`),
|
||||
FOREIGN KEY (`anxiety_level`) REFERENCES `anxiety`(`level`),
|
||||
FOREIGN KEY (`user_treatment_schemes_guid`) REFERENCES `user_treatment_schemes`(`guid`)
|
||||
FOREIGN KEY (`user_treatment_schemes_uuid`) REFERENCES `user_treatment_schemes`(`uuid`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`medications` (
|
||||
`guid` CHAR(36) NOT NULL,
|
||||
`uuid` CHAR(36) NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`dose` int8 NOT NULL,
|
||||
`unit` CHAR(30),
|
||||
`is_urgent` BOOL NOT NULL,
|
||||
PRIMARY KEY (`guid`)
|
||||
PRIMARY KEY (`uuid`)
|
||||
);
|
||||
|
||||
CREATE TABLE `up_and_down`.`treatment_schemes` (
|
||||
`user_treatment_schemes_guid` CHAR(36) NOT NULL,
|
||||
`medication_guid` CHAR(36) NOT NULL,
|
||||
PRIMARY KEY (`user_treatment_schemes_guid`, `medication_guid`),
|
||||
FOREIGN KEY (`user_treatment_schemes_guid`) REFERENCES `user_treatment_schemes`(`guid`),
|
||||
FOREIGN KEY (`medication_guid`) REFERENCES `medications`(`guid`)
|
||||
`user_treatment_schemes_uuid` CHAR(36) NOT NULL,
|
||||
`medication_uuid` CHAR(36) NOT NULL,
|
||||
PRIMARY KEY (`user_treatment_schemes_uuid`, `medication_uuid`),
|
||||
FOREIGN KEY (`user_treatment_schemes_uuid`) REFERENCES `user_treatment_schemes`(`uuid`),
|
||||
FOREIGN KEY (`medication_uuid`) REFERENCES `medications`(`uuid`)
|
||||
);
|
||||
|
||||
-- insert constants
|
||||
@@ -181,8 +181,8 @@ INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (9, 'Тре
|
||||
INSERT INTO `up_and_down`.`anxiety` (`level`, `description`) VALUES (10, 'Тревога X');
|
||||
|
||||
-- Заполнение пользователями
|
||||
INSERT INTO `up_and_down`.`users` (`guid`, `login`, `hashed_password`) VALUES ('ab555fcb-b9ee-45f4-9de8-8f16daa5d03b', 'login1', 'Qwerty12345');
|
||||
INSERT INTO `up_and_down`.`users` (`guid`, `login`, `hashed_password`) VALUES ('56b7c993-392f-41f8-adb1-9766842dc5fd', 'login2', 'AVALON123456');
|
||||
INSERT INTO `up_and_down`.`users` (`guid`, `login`, `hashed_password`) VALUES ('a243b5f2-e265-4c25-82a9-dde4cc70643f', 'login3', 'Zxcvb123456');
|
||||
INSERT INTO `up_and_down`.`users` (`guid`, `login`, `hashed_password`) VALUES ('51351bb1-7563-479d-a8e9-201d0ff934c2', 'login4', 'Sadly846612');
|
||||
INSERT INTO `up_and_down`.`users` (`guid`, `login`, `hashed_password`) VALUES ('c792bbe6-2bf2-4fe0-a781-ba96bfeaa3b6', 'login5', 'Qwerty12345');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('ab555fcb-b9ee-45f4-9de8-8f16daa5d03b', 'login1', 'Qwerty12345');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('56b7c993-392f-41f8-adb1-9766842dc5fd', 'login2', 'AVALON123456');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('a243b5f2-e265-4c25-82a9-dde4cc70643f', 'login3', 'Zxcvb123456');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('51351bb1-7563-479d-a8e9-201d0ff934c2', 'login4', 'Sadly846612');
|
||||
INSERT INTO `up_and_down`.`users` (`uuid`, `login`, `hashed_password`) VALUES ('c792bbe6-2bf2-4fe0-a781-ba96bfeaa3b6', 'login5', 'Qwerty12345');
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ class IUserDAO
|
||||
public:
|
||||
virtual std::string Create(const User& created_user) = 0;
|
||||
|
||||
virtual std::optional<User> GetByGUID(std::string guid) = 0;
|
||||
virtual std::optional<User> GetByUUID(std::string uuid) = 0;
|
||||
|
||||
virtual std::optional<User> GetByLogin(std::string login) = 0;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ string MySQLUserDAO::Create(const User& created_user)
|
||||
return ""s;
|
||||
}
|
||||
|
||||
optional<User> MySQLUserDAO::GetByGUID(string guid)
|
||||
optional<User> MySQLUserDAO::GetByUUID(string uuid)
|
||||
{
|
||||
mysqlx::SqlResult sql_result = session_.sql("SELECT * FROM `up_and_down`.`users` WHERE (guid = '" + guid + "') LIMIT 1;"s).execute();
|
||||
mysqlx::SqlResult sql_result = session_.sql("SELECT * FROM `up_and_down`.`users` WHERE (uuid = '" + uuid + "') LIMIT 1;"s).execute();
|
||||
|
||||
return GetSingleUserBySQLResult(std::move(sql_result));
|
||||
}
|
||||
@@ -58,13 +58,13 @@ std::optional<User> MySQLUserDAO::GetSingleUserBySQLResult(mysqlx::SqlResult&& s
|
||||
|
||||
auto row_data = *rows.begin();
|
||||
|
||||
string user_guid = row_data[0].get<string>();
|
||||
string user_uuid = row_data[0].get<string>();
|
||||
string user_login = row_data[1].get<string>();
|
||||
string user_hashed_password = row_data[2].get<string>();
|
||||
|
||||
User user;
|
||||
|
||||
user.SetGUID(user_guid);
|
||||
user.SetUUID(user_uuid);
|
||||
user.SetLogin(user_login);
|
||||
user.SetHashedPassword(user_hashed_password);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
|
||||
std::string Create(const User& created_user) override;
|
||||
|
||||
std::optional<User> GetByGUID(std::string guid) override;
|
||||
std::optional<User> GetByUUID(std::string uuid) override;
|
||||
|
||||
std::optional<User> GetByLogin(std::string login) override;
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@ using namespace std;
|
||||
|
||||
namespace uad
|
||||
{
|
||||
const string& User::GetGUID() const noexcept
|
||||
const string& User::GetUUID() const noexcept
|
||||
{
|
||||
return guid_;
|
||||
return uuid_;
|
||||
}
|
||||
|
||||
void User::SetGUID(const string& new_guid)
|
||||
void User::SetUUID(const string& new_uuid)
|
||||
{
|
||||
guid_ = new_guid;
|
||||
uuid_ = new_uuid;
|
||||
}
|
||||
|
||||
const string& User::GetLogin() const noexcept
|
||||
|
||||
+3
-3
@@ -8,13 +8,13 @@ namespace uad
|
||||
{
|
||||
class User
|
||||
{
|
||||
std::string guid_;
|
||||
std::string uuid_;
|
||||
std::string login_;
|
||||
std::string hashed_password_;
|
||||
public:
|
||||
[[nodiscard]] const std::string& GetGUID() const noexcept;
|
||||
[[nodiscard]] const std::string& GetUUID() const noexcept;
|
||||
|
||||
void SetGUID(const std::string& new_guid);
|
||||
void SetUUID(const std::string& new_uuid);
|
||||
|
||||
[[nodiscard]] const std::string& GetLogin() const noexcept;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user