feat: enhance validation and serialization with fiscal code checks and JSON schema support

This commit is contained in:
gabdevele
2026-06-14 21:09:05 +02:00 Unverified
parent feef498d9a
commit 002f89bd73
10 changed files with 282 additions and 32 deletions
+24 -2
View File
@@ -10,6 +10,9 @@ namespace visione::services
{
namespace
{
using repositories::JsonFieldType;
using repositories::JsonRowSchema;
Json::Value failure(const std::string &code)
{
Json::Value body;
@@ -56,6 +59,23 @@ int boundedPerPage(const std::optional<std::string> &value)
return 50;
}
}
const JsonRowSchema &notificationSchema()
{
static const JsonRowSchema schema{
{"id", JsonFieldType::UInt64},
{"report_id", JsonFieldType::UInt64}};
return schema;
}
const JsonRowSchema &rewardEventSchema()
{
static const JsonRowSchema schema{
{"id", JsonFieldType::UInt64},
{"report_id", JsonFieldType::UInt64},
{"points", JsonFieldType::Int64}};
return schema;
}
} // namespace
Json::Value UserService::listNotifications(
@@ -77,7 +97,8 @@ Json::Value UserService::listNotifications(
"ORDER BY created_at DESC LIMIT ? OFFSET ?",
user.id,
perPageValue,
offset));
offset),
notificationSchema());
return response;
}
@@ -122,7 +143,8 @@ Json::Value UserService::rewards(const auth::UserContext &user,
"ORDER BY created_at DESC LIMIT ? OFFSET ?",
user.id,
perPageValue,
offset));
offset),
rewardEventSchema());
return response;
}