feat: enhance validation and serialization with fiscal code checks and JSON schema support
This commit is contained in:
@@ -12,6 +12,9 @@ namespace visione::services
|
||||
{
|
||||
namespace
|
||||
{
|
||||
using repositories::JsonFieldType;
|
||||
using repositories::JsonRowSchema;
|
||||
|
||||
Json::Value failure(const std::string &code)
|
||||
{
|
||||
Json::Value body;
|
||||
@@ -58,6 +61,27 @@ int boundedPerPage(const std::optional<std::string> &value)
|
||||
return 50;
|
||||
}
|
||||
}
|
||||
|
||||
const JsonRowSchema &moderationFlagSchema()
|
||||
{
|
||||
static const JsonRowSchema schema{
|
||||
{"id", JsonFieldType::UInt64},
|
||||
{"report_id", JsonFieldType::UInt64},
|
||||
{"message_id", JsonFieldType::UInt64},
|
||||
{"created_by_user_id", JsonFieldType::UInt64},
|
||||
{"resolved_by_user_id", JsonFieldType::UInt64}};
|
||||
return schema;
|
||||
}
|
||||
|
||||
const JsonRowSchema &adminUserSchema()
|
||||
{
|
||||
static const JsonRowSchema schema{
|
||||
{"id", JsonFieldType::UInt64},
|
||||
{"points", JsonFieldType::Int64},
|
||||
{"banned", JsonFieldType::Bool},
|
||||
{"must_change_password", JsonFieldType::Bool}};
|
||||
return schema;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Json::Value AdminService::listCategories()
|
||||
@@ -229,7 +253,8 @@ Json::Value AdminService::listModeration(
|
||||
statusValue,
|
||||
statusValue,
|
||||
perPageValue,
|
||||
offset));
|
||||
offset),
|
||||
moderationFlagSchema());
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -317,7 +342,8 @@ Json::Value AdminService::listUsers(const auth::UserContext &user)
|
||||
"LEFT JOIN roles r ON r.id = ur.role_id "
|
||||
"GROUP BY u.id, u.first_name, u.last_name, u.email, u.fiscal_code, "
|
||||
"u.phone, u.points, u.banned, u.must_change_password "
|
||||
"ORDER BY u.created_at DESC LIMIT 200"));
|
||||
"ORDER BY u.created_at DESC LIMIT 200"),
|
||||
adminUserSchema());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user