feat: enhance validation and serialization with fiscal code checks and JSON schema support
This commit is contained in:
+24
-2
@@ -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 ¬ificationSchema()
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user