generated from Sithas/conan_template
Ручка PostUserTreatmentScheme.h
This commit is contained in:
@@ -67,4 +67,46 @@ std::vector<user_treatment_scheme_dto> MySQLUserTreatmentSchemesDAO::FindByUserU
|
||||
|
||||
return std::move(schemes);
|
||||
}
|
||||
|
||||
void MySQLUserTreatmentSchemesDAO::CreateUserTreatmentScheme(
|
||||
const std::string& user_uuid,
|
||||
const user_treatment_scheme_dto& dto)
|
||||
{
|
||||
session_.startTransaction();
|
||||
|
||||
try {
|
||||
session_.sql(R"(
|
||||
INSERT INTO up_and_down.user_treatment_schemes (
|
||||
uuid,
|
||||
user_uuid,
|
||||
treatment_name,
|
||||
instructions
|
||||
) VALUES (?, ?, ?, ?)
|
||||
)")
|
||||
.bind(
|
||||
dto.uuid,
|
||||
user_uuid,
|
||||
dto.treatment_name,
|
||||
dto.instructions
|
||||
)
|
||||
.execute();
|
||||
|
||||
for (const auto& medication_uuid : dto.medication_uuids) {
|
||||
session_.sql(R"(
|
||||
INSERT INTO up_and_down.treatment_schemes (
|
||||
user_treatment_schemes_uuid,
|
||||
medication_uuid
|
||||
) VALUES (?, ?)
|
||||
)")
|
||||
.bind(dto.uuid, medication_uuid)
|
||||
.execute();
|
||||
}
|
||||
|
||||
session_.commit();
|
||||
}
|
||||
catch (...) {
|
||||
session_.rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
} // uad
|
||||
|
||||
Reference in New Issue
Block a user