rest: use integer for repository ID

ID is integer, fix inconsistency in dc68d0f ('rest: add POST /client/repo')
master
OpenGnSys Support Team 2024-09-09 16:02:24 +02:00
parent 4567bce90b
commit 568d709361
1 changed files with 7 additions and 7 deletions

View File

@ -1896,16 +1896,15 @@ static int og_cmd_get_client_setup(json_t *element,
return 0; return 0;
} }
static int og_dbi_update_client_repo(struct og_dbi *dbi, static int og_dbi_update_client_repo(struct og_dbi *dbi, const char *mac,
const char *mac, uint32_t repo_id)
const char *repo_id)
{ {
const char *msglog; const char *msglog;
dbi_result result; dbi_result result;
result = dbi_conn_queryf(dbi->conn, result = dbi_conn_queryf(dbi->conn,
"UPDATE ordenadores SET idrepositorio=%s " "UPDATE ordenadores SET idrepositorio=%u "
"WHERE mac='%s'", "WHERE mac='%u'",
repo_id, mac); repo_id, mac);
if (!result) { if (!result) {
@ -1928,6 +1927,7 @@ static int og_cmd_post_client_repo(json_t *element,
int ips_str_len = 0; int ips_str_len = 0;
struct og_dbi *dbi; struct og_dbi *dbi;
dbi_result result; dbi_result result;
uint32_t repo_id;
int err = 0, i; int err = 0, i;
json_t *value; json_t *value;
@ -1935,7 +1935,7 @@ static int og_cmd_post_client_repo(json_t *element,
if (!strcmp(key, "clients")) { if (!strcmp(key, "clients")) {
err = og_json_parse_clients(value, params); err = og_json_parse_clients(value, params);
} else if (!strcmp(key, "id")) { } else if (!strcmp(key, "id")) {
err = og_json_parse_string(value, &params->id); err = og_json_parse_uint(value, &repo_id);
params->flags |= OG_REST_PARAM_ID; params->flags |= OG_REST_PARAM_ID;
} }
@ -1974,7 +1974,7 @@ static int og_cmd_post_client_repo(json_t *element,
while (dbi_result_next_row(result)) { while (dbi_result_next_row(result)) {
mac = dbi_result_get_string(result, "mac"); mac = dbi_result_get_string(result, "mac");
err = og_dbi_update_client_repo(dbi, mac, params->id); err = og_dbi_update_client_repo(dbi, mac, repo_id);
if (err != 0) { if (err != 0) {
dbi_result_free(result); dbi_result_free(result);
og_dbi_close(dbi); og_dbi_close(dbi);