feat: update area management to implement hard delete and adjust related references
This commit is contained in:
@@ -444,7 +444,9 @@ Json::Value AdminService::deleteArea(const auth::UserContext &user,
|
||||
{
|
||||
return failure("area_not_found");
|
||||
}
|
||||
db->execSqlSync("UPDATE areas SET active = FALSE WHERE id = ?", areaId);
|
||||
db->execSqlSync("UPDATE teams SET area_id = NULL WHERE area_id = ?", areaId);
|
||||
db->execSqlSync("UPDATE reports SET area_id = NULL WHERE area_id = ?", areaId);
|
||||
db->execSqlSync("DELETE FROM areas WHERE id = ?", areaId);
|
||||
return success();
|
||||
}
|
||||
|
||||
@@ -474,12 +476,6 @@ Json::Value AdminService::updateArea(const auth::UserContext &user,
|
||||
body["description"].asString(),
|
||||
areaId);
|
||||
}
|
||||
if (isActiveField(body))
|
||||
{
|
||||
db->execSqlSync("UPDATE areas SET active = ? WHERE id = ?",
|
||||
body["active"].asBool(),
|
||||
areaId);
|
||||
}
|
||||
if (body["boundary_geojson"].isObject())
|
||||
{
|
||||
if (!isAreaInsideAllowedBoundary(body["boundary_geojson"]))
|
||||
|
||||
@@ -107,7 +107,7 @@ std::optional<long long> findArea(double latitude, double longitude)
|
||||
{
|
||||
const auto result = drogon::app().getDbClient()->execSqlSync(
|
||||
"SELECT id, JSON_UNQUOTE(JSON_EXTRACT(boundary_geojson, '$')) AS geojson "
|
||||
"FROM areas WHERE active = TRUE");
|
||||
"FROM areas");
|
||||
|
||||
Json::CharReaderBuilder builder;
|
||||
for (const auto &row : result)
|
||||
@@ -647,8 +647,7 @@ Json::Value ReportService::listAreas()
|
||||
{
|
||||
auto response = success();
|
||||
response["areas"] = repositories::resultToJson(
|
||||
drogon::app().getDbClient()->execSqlSync(
|
||||
"SELECT * FROM areas WHERE active = TRUE ORDER BY name"));
|
||||
drogon::app().getDbClient()->execSqlSync("SELECT * FROM areas ORDER BY name"));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user