Переименование GUID на UUID

This commit is contained in:
Антон
2025-08-30 08:31:03 +03:00
parent 5e18a1d2a9
commit ec3817fad6
7 changed files with 50 additions and 50 deletions
+12 -12
View File
@@ -53,7 +53,7 @@
``` ```
{ {
"user": { "user": {
"guid": "51351bb1-7563-479d-a8e9-201d0ff934c2" "uuid": "51351bb1-7563-479d-a8e9-201d0ff934c2"
"login": "ivan_89" "login": "ivan_89"
} }
} }
@@ -65,7 +65,7 @@
* `400 BAD_REQUEST` — сервер не смог десереализовать JSON * `400 BAD_REQUEST` — сервер не смог десереализовать JSON
### 10. Используемые сущности ДБ ### 10. Используемые сущности ДБ
* users(guid(PK), login(unique), hashed_password) * users(uuid(PK), login(unique), hashed_password)
## UseCase №2 ## UseCase №2
### 1.Название: Авторизация пользователя ### 1.Название: Авторизация пользователя
@@ -126,7 +126,7 @@ null
``` ```
### 10. Используемые сущности ДБ ### 10. Используемые сущности ДБ
* users(guid(PK), login(unique), hashed_password) * users(uuid(PK), login(unique), hashed_password)
## UseCase №3 ## UseCase №3
### 1.Название: Переход на главную страницу ### 1.Название: Переход на главную страницу
@@ -160,7 +160,7 @@ null
{ {
diaries: [ diaries: [
{ {
"guid": "e89b6a0c-4b0f-4722-a410-1e0c1864bf8a", "uuid": "e89b6a0c-4b0f-4722-a410-1e0c1864bf8a",
"time": "10.08.2025", "time": "10.08.2025",
"mania_level": 1, "mania_level": 1,
"depression_level": 2, "depression_level": 2,
@@ -170,12 +170,12 @@ null
"dream_level": 6, "dream_level": 6,
"anxiety_level": 7, "anxiety_level": 7,
"treatment_scheme": { "treatment_scheme": {
"guid": "bf6d1555-39e9-4d73-8928-4763627f4dd5", "uuid": "bf6d1555-39e9-4d73-8928-4763627f4dd5",
"treatment_name": "Bipolar I Scheme", "treatment_name": "Bipolar I Scheme",
"instructions": "Контроль лития в крови раз в 2 месяца. Анализ крови через вену." "instructions": "Контроль лития в крови раз в 2 месяца. Анализ крови через вену."
"medications": [ "medications": [
{ {
"guid": "8af2dfa9-3add-413c-9a0e-ff605088f1d5", "uuid": "8af2dfa9-3add-413c-9a0e-ff605088f1d5",
"name": "Litii Carbonate", "name": "Litii Carbonate",
"dose": 1800, "dose": 1800,
"unit": "mg", "unit": "mg",
@@ -198,12 +198,12 @@ null
{ {
"treatment_schemes": [ "treatment_schemes": [
{ {
"guid": "248313cb-a75e-4331-8379-d3f2fc36b68d" "uuid": "248313cb-a75e-4331-8379-d3f2fc36b68d"
"treatment_name": "Bipolar I Scheme Urgent", "treatment_name": "Bipolar I Scheme Urgent",
"instructions": "Схема для бытрого и жесткого купирования психозов. Аминазин пить каждый день.", "instructions": "Схема для бытрого и жесткого купирования психозов. Аминазин пить каждый день.",
"medications": [ "medications": [
{ {
"guid": "eda5a5f7-167a-44b9-900d-c5c6acfc249b", "uuid": "eda5a5f7-167a-44b9-900d-c5c6acfc249b",
"name": "Aminazin", "name": "Aminazin",
"dose": 100, "dose": 100,
"unit": "mg", "unit": "mg",
@@ -220,7 +220,7 @@ null
* `500 DATA_LOAD_FAILED` — ошибка при загрузке данных (B1) * `500 DATA_LOAD_FAILED` — ошибка при загрузке данных (B1)
### 10. Используемые сущности ДБ ### 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)) * mania(level(PK))
* depressions(level(PK)) * depressions(level(PK))
* moods(level(PK)) * moods(level(PK))
@@ -228,6 +228,6 @@ null
* appetites(level(PK)) * appetites(level(PK))
* dreams(level(PK)) * dreams(level(PK))
* anxiety(level(PK)) * anxiety(level(PK))
* treatment_schemes(user_treatment_schemes_guid(PK), medication_guid(PK)) * treatment_schemes(user_treatment_schemes_uuid(PK), medication_uuid(PK))
* user_treatment_schemes(guid(PK), user_guid, treatment_name, instructions) * user_treatment_schemes(uuid(PK), user_uuid, treatment_name, instructions)
* medications(guid(PK), name, dose, unit, is_urgent) * medications(uuid(PK), name, dose, unit, is_urgent)
+25 -25
View File
@@ -3,11 +3,11 @@
CREATE SCHEMA `up_and_down` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; CREATE SCHEMA `up_and_down` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
CREATE TABLE `up_and_down`.`users` ( CREATE TABLE `up_and_down`.`users` (
`guid` CHAR(36) NOT NULL, `uuid` CHAR(36) NOT NULL,
`login` VARCHAR(128) UNIQUE NOT NULL, `login` VARCHAR(128) UNIQUE NOT NULL,
`hashed_password` TEXT NOT NULL, `hashed_password` TEXT NOT NULL,
PRIMARY KEY (`guid`), PRIMARY KEY (`uuid`),
UNIQUE INDEX `guid_UNIQUE` (`guid` ASC) UNIQUE INDEX `uuid_UNIQUE` (`uuid` ASC)
); );
CREATE TABLE `up_and_down`.`mania` ( CREATE TABLE `up_and_down`.`mania` (
@@ -53,17 +53,17 @@ CREATE TABLE `up_and_down`.`anxiety` (
); );
CREATE TABLE `up_and_down`.`user_treatment_schemes` ( CREATE TABLE `up_and_down`.`user_treatment_schemes` (
`guid` CHAR(36) NOT NULL, `uuid` CHAR(36) NOT NULL,
`user_guid` CHAR(36) NOT NULL, `user_uuid` CHAR(36) NOT NULL,
`treatment_name` TEXT NOT NULL, `treatment_name` TEXT NOT NULL,
`instructions` TEXT, `instructions` TEXT,
PRIMARY KEY (`guid`), PRIMARY KEY (`uuid`),
FOREIGN KEY (`user_guid`) REFERENCES `users`(`guid`) FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`)
); );
CREATE TABLE `up_and_down`.`diaries` ( CREATE TABLE `up_and_down`.`diaries` (
`guid` CHAR(36) NOT NULL, `uuid` CHAR(36) NOT NULL,
`user_guid` CHAR(36) NOT NULL, `user_uuid` CHAR(36) NOT NULL,
`time` DATETIME NOT NULL, `time` DATETIME NOT NULL,
`mania_level` INT1 NOT NULL, `mania_level` INT1 NOT NULL,
`depression_level` INT1 NOT NULL, `depression_level` INT1 NOT NULL,
@@ -72,9 +72,9 @@ CREATE TABLE `up_and_down`.`diaries` (
`appetite_level` INT1 NOT NULL, `appetite_level` INT1 NOT NULL,
`dream_level` INT1 NOT NULL, `dream_level` INT1 NOT NULL,
`anxiety_level` INT1 NOT NULL, `anxiety_level` INT1 NOT NULL,
`user_treatment_schemes_guid` CHAR(36), `user_treatment_schemes_uuid` CHAR(36),
PRIMARY KEY (`guid`), PRIMARY KEY (`uuid`),
FOREIGN KEY (`user_guid`) REFERENCES `users`(`guid`), FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`),
FOREIGN KEY (`mania_level`) REFERENCES `mania`(`level`), FOREIGN KEY (`mania_level`) REFERENCES `mania`(`level`),
FOREIGN KEY (`depression_level`) REFERENCES `depressions`(`level`), FOREIGN KEY (`depression_level`) REFERENCES `depressions`(`level`),
FOREIGN KEY (`mood_level`) REFERENCES `moods`(`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 (`appetite_level`) REFERENCES `appetites`(`level`),
FOREIGN KEY (`dream_level`) REFERENCES `dreams`(`level`), FOREIGN KEY (`dream_level`) REFERENCES `dreams`(`level`),
FOREIGN KEY (`anxiety_level`) REFERENCES `anxiety`(`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` ( CREATE TABLE `up_and_down`.`medications` (
`guid` CHAR(36) NOT NULL, `uuid` CHAR(36) NOT NULL,
`name` TEXT NOT NULL, `name` TEXT NOT NULL,
`dose` int8 NOT NULL, `dose` int8 NOT NULL,
`unit` CHAR(30), `unit` CHAR(30),
`is_urgent` BOOL NOT NULL, `is_urgent` BOOL NOT NULL,
PRIMARY KEY (`guid`) PRIMARY KEY (`uuid`)
); );
CREATE TABLE `up_and_down`.`treatment_schemes` ( CREATE TABLE `up_and_down`.`treatment_schemes` (
`user_treatment_schemes_guid` CHAR(36) NOT NULL, `user_treatment_schemes_uuid` CHAR(36) NOT NULL,
`medication_guid` CHAR(36) NOT NULL, `medication_uuid` CHAR(36) NOT NULL,
PRIMARY KEY (`user_treatment_schemes_guid`, `medication_guid`), PRIMARY KEY (`user_treatment_schemes_uuid`, `medication_uuid`),
FOREIGN KEY (`user_treatment_schemes_guid`) REFERENCES `user_treatment_schemes`(`guid`), FOREIGN KEY (`user_treatment_schemes_uuid`) REFERENCES `user_treatment_schemes`(`uuid`),
FOREIGN KEY (`medication_guid`) REFERENCES `medications`(`guid`) FOREIGN KEY (`medication_uuid`) REFERENCES `medications`(`uuid`)
); );
-- insert constants -- 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`.`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` (`uuid`, `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` (`uuid`, `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` (`uuid`, `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` (`uuid`, `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 ('c792bbe6-2bf2-4fe0-a781-ba96bfeaa3b6', 'login5', 'Qwerty12345');
+1 -1
View File
@@ -12,7 +12,7 @@ class IUserDAO
public: public:
virtual std::string Create(const User& created_user) = 0; 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; virtual std::optional<User> GetByLogin(std::string login) = 0;
+4 -4
View File
@@ -16,9 +16,9 @@ string MySQLUserDAO::Create(const User& created_user)
return ""s; 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)); return GetSingleUserBySQLResult(std::move(sql_result));
} }
@@ -58,13 +58,13 @@ std::optional<User> MySQLUserDAO::GetSingleUserBySQLResult(mysqlx::SqlResult&& s
auto row_data = *rows.begin(); 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_login = row_data[1].get<string>();
string user_hashed_password = row_data[2].get<string>(); string user_hashed_password = row_data[2].get<string>();
User user; User user;
user.SetGUID(user_guid); user.SetUUID(user_uuid);
user.SetLogin(user_login); user.SetLogin(user_login);
user.SetHashedPassword(user_hashed_password); user.SetHashedPassword(user_hashed_password);
+1 -1
View File
@@ -12,7 +12,7 @@ public:
std::string Create(const User& created_user) override; 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; std::optional<User> GetByLogin(std::string login) override;
+4 -4
View File
@@ -7,14 +7,14 @@ using namespace std;
namespace uad 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 const string& User::GetLogin() const noexcept
+3 -3
View File
@@ -8,13 +8,13 @@ namespace uad
{ {
class User class User
{ {
std::string guid_; std::string uuid_;
std::string login_; std::string login_;
std::string hashed_password_; std::string hashed_password_;
public: 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; [[nodiscard]] const std::string& GetLogin() const noexcept;